ngic dynamic config

Change-Id: I628ba303e89ca9005b051531371d072e465523ee
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
deleted file mode 100644
index 42602f4..0000000
--- a/xos/synchronizer/manifest
+++ /dev/null
@@ -1,8 +0,0 @@
-model-deps
-manifest
-run.sh
-stop.sh
-vsgwc-synchronizer.py
-vsgwc_config
-steps/sync_vsgwc.py
-steps/sync_vsgwc.yaml
diff --git a/xos/synchronizer/steps/roles/ngic_config/tasks/main.yml b/xos/synchronizer/steps/roles/ngic_config/tasks/main.yml
new file mode 100644
index 0000000..dddf113
--- /dev/null
+++ b/xos/synchronizer/steps/roles/ngic_config/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+- name: create config directory for cp_config file
+  file:
+    path: /var/tmp/config
+    state: directory
+    mode: 0755
+
+- name: save control plane configuration information in vSGWC VM
+  template:
+    src=cp_config.cfg.j2
+    dest=/var/tmp/config/cp_config.cfg
diff --git a/xos/synchronizer/steps/roles/ngic_config/templates/cp_config.cfg.j2 b/xos/synchronizer/steps/roles/ngic_config/templates/cp_config.cfg.j2
new file mode 100644
index 0000000..f6bb725
--- /dev/null
+++ b/xos/synchronizer/steps/roles/ngic_config/templates/cp_config.cfg.j2
@@ -0,0 +1,10 @@
+{% set date = ansible_date_time['date'] ~ '_' ~ ansible_date_time['hour'] ~ '_' ~ ansible_date_time['minute'] %}
+NOW={{ date }}
+FILE="logs/cp_{{ date }}.log"
+S11_SGW_IP={{ sgwc_shared_ip }}
+S11_MME_IP={{ mme_shared_ip }}
+S1U_SGW_IP={{ sgwu_shared_ip }}
+IP_POOL_IP=16.0.0.0
+IP_POOL_MASK=255.0.0.0
+APN=apn1
+MEMORY=1024
diff --git a/xos/synchronizer/steps/sync_vsgwctenant.py b/xos/synchronizer/steps/sync_vsgwctenant.py
index d54262c..e738c0e 100644
--- a/xos/synchronizer/steps/sync_vsgwctenant.py
+++ b/xos/synchronizer/steps/sync_vsgwctenant.py
@@ -21,13 +21,37 @@
     def __init__(self, *args, **kwargs):
         super(SyncVSGWCTenant, self).__init__(*args, **kwargs)
 
-    def fetch_pending(self, deleted):
-        if (not deleted):
-            objs = VSGWCTenant.get_tenant_objects().filter(
-                Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
-        else:
-            # If this is a deletion we get all of the deleted tenants..
-            objs = VSGWCTenant.get_deleted_tenant_objects()
+#    def fetch_pending(self, deleted):
+#        if (not deleted):
+#            objs = VSGWCTenant.get_tenant_objects().filter(
+#                Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
+#        else:
+#            # If this is a deletion we get all of the deleted tenants..
+#            objs = VSGWCTenant.get_deleted_tenant_objects()
+#
+#        return objs
 
-        return objs
+    # Gets the attributes that are used by the Ansible template but are not
+    # part of the set of default attribtues.
+    def get_extra_attributes(self, o):
+        fields = {}
+        shared_net_id = Network.objects.get(name='shared_network').id
 
+	try:
+            fields['sgwc_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=o.instance_id).ip
+        except Exception:
+            print '{} does not have an instance'.format(o.name)
+
+        try:
+            mme = TenantWithContainer.objects.get(provider_service_id=Service.objects.get(name='vmme').id, subscriber_tenant_id=o.subscriber_tenant_id)
+            fields['mme_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=mme.instance_id).ip
+	except Exception:
+            print '{} does not have a VMME instance'.format(o.subscriber_tenant.name)
+	
+        try:
+            sgwu = TenantWithContainer.objects.get(provider_service_id=Service.objects.get(name='vsgwu').id, subscriber_tenant_id=o.subscriber_tenant_id)
+            fields['sgwu_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=sgwu.instance_id).ip
+        except Exception:
+            print '{} does not have a VSGWU instance'.format(o.subscriber_tenant.name)
+
+        return fields
diff --git a/xos/synchronizer/steps/vsgwctenant_playbook.yaml b/xos/synchronizer/steps/vsgwctenant_playbook.yaml
index 74ea6bb..8338582 100644
--- a/xos/synchronizer/steps/vsgwctenant_playbook.yaml
+++ b/xos/synchronizer/steps/vsgwctenant_playbook.yaml
@@ -1,9 +1,13 @@
 ---
 - hosts: {{ instance_name }}
-  gather_facts: False
+  gather_facts: True
   connection: ssh
   user: ubuntu
   sudo: yes
-  tasks:
   vars:
+    - sgwc_shared_ip: {{ sgwc_shared_ip }}
+    - mme_shared_ip: {{ mme_shared_ip }}
+    - sgwu_shared_ip: {{ sgwu_shared_ip }}
+  roles:
+    - ngic_config
 
diff --git a/xos/synchronizer/stop.sh b/xos/synchronizer/stop.sh
deleted file mode 100644
index 68fe7c4..0000000
--- a/xos/synchronizer/stop.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-# Kill the observer
-pkill -9 -f vsgwc-synchronizer.py
diff --git a/xos/tosca/custom_types/vsgwc.m4 b/xos/tosca/custom_types/vsgwc.m4
index a1e2911..8d1dbd5 100644
--- a/xos/tosca/custom_types/vsgwc.m4
+++ b/xos/tosca/custom_types/vsgwc.m4
@@ -28,6 +28,7 @@
         description: >
             VSGWC Vendor
         properties:
+            xos_base_props
             name:
                 type: string
                 required: true
diff --git a/xos/tosca/custom_types/vsgwc.yaml b/xos/tosca/custom_types/vsgwc.yaml
index 5d9db92..6012a51 100644
--- a/xos/tosca/custom_types/vsgwc.yaml
+++ b/xos/tosca/custom_types/vsgwc.yaml
@@ -98,6 +98,22 @@
         description: >
             VSGWC Vendor
         properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             name:
                 type: string
                 required: true