add vPGWU services
Change-Id: Ide9597e59f124dc4b43f653c6cc301ff19464450
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..7a9fd9f
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,40 @@
+# xosproject/vpgwu-synchronizer
+
+FROM xosproject/xos-synchronizer-base:candidate
+
+COPY . /opt/xos/synchronizers/vpgwu
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/vpgwu"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=vpgwu-synchronizer
+ARG org_label_schema_version=unknown
+ARG org_label_schema_vcs_url=unknown
+ARG org_label_schema_vcs_ref=unknown
+ARG org_label_schema_build_date=unknown
+ARG org_opencord_vcs_commit_date=unknown
+ARG org_opencord_component_chameleon_version=unknown
+ARG org_opencord_component_chameleon_vcs_url=unknown
+ARG org_opencord_component_chameleon_vcs_ref=unknown
+ARG org_opencord_component_xos_version=unknown
+ARG org_opencord_component_xos_vcs_url=unknown
+ARG org_opencord_component_xos_vcs_ref=unknown
+
+LABEL org.label-schema.schema-version=$org_label_schema_schema_version \
+ org.label-schema.name=$org_label_schema_name \
+ org.label-schema.version=$org_label_schema_version \
+ org.label-schema.vcs-url=$org_label_schema_vcs_url \
+ org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
+ org.label-schema.build-date=$org_label_schema_build_date \
+ org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date \
+ org.opencord.component.chameleon.version=$org_opencord_component_chameleon_version \
+ org.opencord.component.chameleon.vcs-url=$org_opencord_component_chameleon_vcs_url \
+ org.opencord.component.chameleon.vcs-ref=$org_opencord_component_chameleon_vcs_ref \
+ org.opencord.component.xos.version=$org_opencord_component_xos_version \
+ org.opencord.component.xos.vcs-url=$org_opencord_component_xos_vcs_url \
+ org.opencord.component.xos.vcs-ref=$org_opencord_component_xos_vcs_ref
+
+CMD bash -c "cd /opt/xos/synchronizers/vpgwu; ./run-from-api.sh"
\ No newline at end of file
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..9d7ae4f
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python vpgwu-synchronizer.py -C $XOS_DIR/synchronizers/vpgwu/vpgwu_from_api_config
diff --git a/xos/synchronizer/steps/sync_vpgwutenant.py b/xos/synchronizer/steps/sync_vpgwutenant.py
new file mode 100644
index 0000000..b22438c
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vpgwutenant.py
@@ -0,0 +1,44 @@
+import os
+import sys
+from django.db.models import Q, F
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from synchronizers.new_base.modelaccessor import *
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncVPGWUTenant(SyncInstanceUsingAnsible):
+
+ provides = [VPGWUTenant]
+
+ observes = VPGWUTenant
+
+ requested_interval = 0
+
+ template_name = "vpgwutenant_playbook.yaml"
+
+ service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
+
+ def __init__(self, *args, **kwargs):
+ super(SyncVPGWUTenant, self).__init__(*args, **kwargs)
+
+ def fetch_pending(self, deleted):
+
+ if (not deleted):
+ objs = VPGWUTenant.get_tenant_objects().filter(
+ Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
+ else:
+
+ objs = VPGWUTenant.get_deleted_tenant_objects()
+
+ return objs
+
+ def get_extra_attributes(self, o):
+ fields = {}
+ fields['display_message'] = o.display_message
+ fields['s5s8_pgw_tag'] = o.s5s8_pgw_tag
+ fields['image_name'] = o.image_name
+ return fields
+
+ def delete_record(self, port):
+ pass
diff --git a/xos/synchronizer/steps/vpgwutenant_playbook.yaml b/xos/synchronizer/steps/vpgwutenant_playbook.yaml
new file mode 100644
index 0000000..455290c
--- /dev/null
+++ b/xos/synchronizer/steps/vpgwutenant_playbook.yaml
@@ -0,0 +1,13 @@
+---
+- hosts: {{ instance_name }}
+ gather_facts: False
+ connection: ssh
+ user: ubuntu
+ become: yes
+ tasks:
+
+ - name: write message
+ shell: echo "{{ display_message }}" > /var/tmp/index.html
+
+ - name: setup s5s8_pgw interface config
+ shell: ./start_3gpp_int.sh eth1 {{ s5s8_pgw_tag }} {{ s5s8_pgw_ip }}/24
diff --git a/xos/synchronizer/vpgwu-synchronizer.py b/xos/synchronizer/vpgwu-synchronizer.py
new file mode 100755
index 0000000..6db012f
--- /dev/null
+++ b/xos/synchronizer/vpgwu-synchronizer.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+# Runs the standard XOS synchronizer
+
+import importlib
+import os
+import sys
+
+synchronizer_path = os.path.join(os.path.dirname(
+ os.path.realpath(__file__)), "../../synchronizers/new_base")
+sys.path.append(synchronizer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
diff --git a/xos/synchronizer/vpgwu_from_api_config b/xos/synchronizer/vpgwu_from_api_config
new file mode 100644
index 0000000..baaaecd
--- /dev/null
+++ b/xos/synchronizer/vpgwu_from_api_config
@@ -0,0 +1,21 @@
+# Sets options for the synchronizer
+[observer]
+name=vpgwu
+dependency_graph=/opt/xos/synchronizers/vpgwu/model-deps
+steps_dir=/opt/xos/synchronizers/vpgwu/steps
+sys_dir=/opt/xos/synchronizers/vpgwu/sys
+log_file=console
+log_level=debug
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+proxy_ssh=True
+proxy_ssh_key=/opt/cord_profile/node_key
+proxy_ssh_user=root
+enable_watchers=True
+accessor_kind=api
+accessor_password=@/opt/xos/services/vpgwu/credentials/xosadmin@opencord.org
+#required_models=VPGWUService, VPGWUTenant, ServiceDependency
+[networking]
+use_vtn=True
+