[CORD-1445] Refactored vPGWC for CORD-3.0
Change-Id: I6024d0e4eae62ffbce84d6deef0be5c8918f7986
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..be0b17d
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,40 @@
+# xosproject/vpgwc-synchronizer
+
+FROM xosproject/xos-synchronizer-base:candidate
+
+COPY . /opt/xos/synchronizers/vpgwc
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/vpgwc"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=vpgwc-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/vpgwc; ./run-from-api.sh"
\ No newline at end of file
diff --git a/xos/synchronizer/__init__.py b/xos/synchronizer/__init__.py
deleted file mode 100755
index e69de29..0000000
--- a/xos/synchronizer/__init__.py
+++ /dev/null
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
deleted file mode 100644
index dc78252..0000000
--- a/xos/synchronizer/manifest
+++ /dev/null
@@ -1,9 +0,0 @@
-__init__.py
-manifest
-model-deps
-run.sh
-steps/sync_vpgwc.py
-steps/sync_vpgwc.yaml
-stop.sh
-vpgwc-synchronizer.py
-vpgwc_config
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..db371d5
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1 @@
+python vpgwc-synchronizer.py
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
deleted file mode 100755
index 821e149..0000000
--- a/xos/synchronizer/run.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-# Runs the XOS observer using helloworldservice_config
-export XOS_DIR=/opt/xos
-python vpgwc-synchronizer.py -C $XOS_DIR/synchronizers/vpgwc/vpgwc_config
diff --git a/xos/synchronizer/stop.sh b/xos/synchronizer/stop.sh
deleted file mode 100755
index 299641a..0000000
--- a/xos/synchronizer/stop.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-# Kill the observer
-pkill -9 -f vpgwc-synchronizer.py
diff --git a/xos/synchronizer/vpgwc-synchronizer.py b/xos/synchronizer/vpgwc-synchronizer.py
index 95f4081..361ad7f 100755
--- a/xos/synchronizer/vpgwc-synchronizer.py
+++ b/xos/synchronizer/vpgwc-synchronizer.py
@@ -1,13 +1,17 @@
#!/usr/bin/env python
-# This imports and runs ../../xos-observer.py
-# Runs the standard XOS observer
+# Runs the standard XOS synchronizer
import importlib
import os
import sys
-observer_path = os.path.join(os.path.dirname(
- os.path.realpath(__file__)), "../../synchronizers/base")
-sys.path.append(observer_path)
+from xosconfig import Config
+
+config_file = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + '/vpgwc_config.yaml')
+Config.init(config_file, 'synchronizer-config-schema.yaml')
+
+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()
+mod.main()
\ No newline at end of file
diff --git a/xos/synchronizer/vpgwc_config b/xos/synchronizer/vpgwc_config
deleted file mode 100755
index 7e00dd8..0000000
--- a/xos/synchronizer/vpgwc_config
+++ /dev/null
@@ -1,41 +0,0 @@
-# Required by XOS
-[db]
-name=xos
-user=postgres
-password=password
-host=xos_db
-port=5432
-
-# Required by XOS
-[api]
-nova_enabled=True
-
-
-# Sets options for the synchronizer
-[observer]
-# Optional name
-name=vpgwc
-# This is the location to the dependency graph you generate
-dependency_graph=/opt/xos/synchronizers/vpgwc/model-deps
-# The location of your SyncSteps
-steps_dir=/opt/xos/synchronizers/vpgwc/steps
-# A temporary directory that will be used by ansible
-sys_dir=/opt/xos/synchronizers/vpgwc/sys
-# Location of the file to save logging messages to the backend log is often used
-logfile=/var/log/xos_backend.log
-# If this option is true, then nothing will change, we simply pretend to run
-pretend=False
-# If this is False then XOS will use an exponential backoff when the observer
-# fails, since we will be waiting for an instance, we don't want this.
-backoff_disabled=True
-# We want the output from ansible to be logged
-save_ansible_output=True
-# This determines how we SSH to a client, if this is set to True then we try
-# to ssh using the instance name as a proxy, if this is disabled we ssh using
-# the NAT IP of the instance. On CloudLab the first option will fail so we must
-# set this to False
-proxy_ssh=True
-proxy_ssh_key=/root/setup/id_rsa
-proxy_ssh_user=root
-[networking]
-use_vtn=True
diff --git a/xos/synchronizer/vpgwc_config.yaml b/xos/synchronizer/vpgwc_config.yaml
new file mode 100755
index 0000000..0d6e5d1
--- /dev/null
+++ b/xos/synchronizer/vpgwc_config.yaml
@@ -0,0 +1,13 @@
+name: vpgwc-synchronizer
+accessor:
+ username: xosadmin@opencord.org
+ password: "@/opt/xos/services/vpgwc/credentials/xosadmin@opencord.org"
+required_models:
+ - VPGWCService
+ - VPGWCTenant
+ - ServiceDependency
+ - ServiceMonitoringAgentInfo
+dependency_graph: "/opt/xos/synchronizers/vpgwc/model-deps"
+steps_dir: "/opt/xos/synchronizers/vpgwc/steps"
+sys_dir: "/opt/xos/synchronizers/vpgwc/sys"
+model_policies_dir: "/opt/xos/synchronizers/vpgwc/model_policies"
\ No newline at end of file