[CORD-1969] VSGWC migration from 3.0 to 4.1
Change-Id: I7c33f351e494ed8a0ba18bf2a0fbf2447442cf95
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..f6e9b8c
--- /dev/null
+++ b/xos/synchronizer/steps/roles/ngic_config/tasks/main.yml
@@ -0,0 +1,25 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+- 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_vsgw.py b/xos/synchronizer/steps/sync_vsgw.py
deleted file mode 100644
index 2f16a88..0000000
--- a/xos/synchronizer/steps/sync_vsgw.py
+++ /dev/null
@@ -1,57 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import os
-import sys
-from django.db.models import Q, F
-from services.vsgw.models import VSGWService, VSGWTenant
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-
-parentdir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.insert(0, parentdir)
-
-class SyncVSGWTenant(SyncInstanceUsingAnsible):
-
- provides = [VSGWTenant]
-
- observes = VSGWTenant
-
- requested_interval = 0
-
- template_name = "sync_vsgw.yaml"
-
- service_key_name = "/opt/xos/synchronizers/vsgw/vsgw_private_key"
-
- def __init__(self, *args, **kwargs):
- super(SyncVSGWTenant, self).__init__(*args, **kwargs)
-
- def fetch_pending(self, deleted):
-
- if (not deleted):
- objs = VSGWTenant.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 = VSGWTenant.get_deleted_tenant_objects()
-
- return objs
-
- def get_extra_attributes(self, o):
- fields = {}
- fields['tenant_message'] = o.tenant_message
- fields['image_name'] = o.image_name
- return fields
-
diff --git a/xos/synchronizer/steps/sync_vsgw.yaml b/xos/synchronizer/steps/sync_vsgw.yaml
deleted file mode 100644
index 0ad9397..0000000
--- a/xos/synchronizer/steps/sync_vsgw.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
----
-- hosts: {{ instance_name }}
- connection: ssh
- user: ubuntu
- become: yes
- gather_facts: no
- tasks:
-
- vars:
- - tenant_message: "{{ tenant_message }}"
-
-# - name: Write message
-# shell: echo "{{ tenant_message }}" > /var/tmp/index.html
-#
-# - name: setup s1u interface config
-# shell: ./start_3gpp_int.sh eth1 {{ s1u_sgw_tag }} {{ s1u_sgw_ip }}/24
-#
-# - name: setup s11 interface config
-# shell: ./start_3gpp_int.sh eth2 {{ s11_sgw_tag }} {{ s11_sgw_ip }}/24
-#
-# - name: setup s5s8 interface config
-# shell: ./start_3gpp_int.sh eth3 {{ s5s8_sgw_tag }} {{ s5s8_sgw_ip }}/24
-
-# roles:
-# - install_apache
-# - create_index
-
diff --git a/xos/synchronizer/steps/sync_vsgwctenant.py b/xos/synchronizer/steps/sync_vsgwctenant.py
new file mode 100644
index 0000000..cc1078c
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vsgwctenant.py
@@ -0,0 +1,71 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+from django.db.models import Q, F
+from synchronizers.new_base.modelaccessor import *
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncVSGWCTenant(SyncInstanceUsingAnsible):
+ provides = [VSGWCTenant]
+
+ observes = VSGWCTenant
+
+ requested_interval = 0
+
+ template_name = "vsgwctenant_playbook.yaml"
+
+ service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
+
+ 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()
+#
+# 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
new file mode 100644
index 0000000..ef1b986
--- /dev/null
+++ b/xos/synchronizer/steps/vsgwctenant_playbook.yaml
@@ -0,0 +1,27 @@
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+- hosts: {{ instance_name }}
+ gather_facts: True
+ connection: ssh
+ user: ubuntu
+ sudo: yes
+ vars:
+ - sgwc_shared_ip: {{ sgwc_shared_ip }}
+ - mme_shared_ip: {{ mme_shared_ip }}
+ - sgwu_shared_ip: {{ sgwu_shared_ip }}
+ roles:
+ - ngic_config
+