[ACORD-18] CORD 3.0 integration for monitoring service
Adding the new files
-Updating models 
-Fixing synchronizer

Change-Id: I148e06d421a42acdeb8366a7816d0589f8a39e54
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..3bed526
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,27 @@
+
+FROM xosproject/xos-synchronizer-base:candidate
+
+ADD . /opt/xos/synchronizers/monitoring
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/monitoring"
+
+# Label image
+ARG org_label_schema_schema_version=1.0
+ARG org_label_schema_name=monitoring-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
+
+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
+
+CMD bash -c "cd /opt/xos/synchronizers/monitoring; ./run-from-api.sh"
diff --git a/xos/synchronizer/Makefile b/xos/synchronizer/Makefile
new file mode 100644
index 0000000..37a6958
--- /dev/null
+++ b/xos/synchronizer/Makefile
@@ -0,0 +1,5 @@
+synchronizer:
+        sudo docker build --rm -f Dockerfile.synchronizer -t xosproject/monitoring-synchronizer .
+
+up:
+        docker-compose -p monitoring up -d
diff --git a/xos/synchronizer/monitoring-synchronizer.py b/xos/synchronizer/monitoring-synchronizer.py
new file mode 100644
index 0000000..b37ac34
--- /dev/null
+++ b/xos/synchronizer/monitoring-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()
\ No newline at end of file
diff --git a/xos/synchronizer/monitoring_from_api_config b/xos/synchronizer/monitoring_from_api_config
new file mode 100644
index 0000000..611f14e
--- /dev/null
+++ b/xos/synchronizer/monitoring_from_api_config
@@ -0,0 +1,29 @@
+# Sets options for the synchronizer
+[db]
+name=xos
+user=postgres
+password=password
+host=xos_db
+port=5432
+
+[observer]
+name=monitoring_service
+dependency_graph=/opt/xos/synchronizers/monitoring/model-deps
+steps_dir=/opt/xos/synchronizers/monitoring/steps
+sys_dir=/opt/xos/synchronizers/monitoring/sys
+#logfile=/var/log/xos_backend.log
+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/monitoring/credentials/xosadmin@opencord.org
+required_models=CeilometerService, MonitoringChannel, MonitoringPublisher, OpenStackServiceMonitoringPublisher, ONOSServiceMonitoringPublisher, UserServiceMonitoringPublisher, InfraMonitoringAgentInfo, MonitoringCollectorPluginInfo, SFlowService, SFlowTenant, 
+
+[networking]
+use_vtn=True
diff --git a/xos/synchronizer/monitoring_synchronizer.py b/xos/synchronizer/monitoring_synchronizer.py
deleted file mode 100755
index 84bec4f..0000000
--- a/xos/synchronizer/monitoring_synchronizer.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-# This imports and runs ../../xos-observer.py
-
-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)
-mod = importlib.import_module("xos-synchronizer")
-mod.main()
diff --git a/xos/synchronizer/monitoring_synchronizer_config b/xos/synchronizer/monitoring_synchronizer_config
deleted file mode 100644
index e1ac6fe..0000000
--- a/xos/synchronizer/monitoring_synchronizer_config
+++ /dev/null
@@ -1,44 +0,0 @@
-
-[plc]
-name=plc
-deployment=VICCI
-
-[db]
-name=xos
-user=postgres
-password=password
-host=xos_db
-port=5432
-
-[api]
-host=128.112.171.237
-port=8000
-ssl_key=None
-ssl_cert=None
-ca_ssl_cert=None
-ratelimit_enabled=0
-omf_enabled=0
-mail_support_address=support@localhost
-nova_enabled=True
-
-[observer]
-name=monitoring_service
-dependency_graph=/opt/xos/synchronizers/monitoring/model-deps
-steps_dir=/opt/xos/synchronizers/monitoring/steps
-sys_dir=/opt/xos/synchronizers/monitoring/sys
-deleters_dir=/opt/xos/synchronizers/monitoring/deleters
-log_file=console
-driver=None
-pretend=False
-backoff_disabled=True
-save_ansible_output=True
-# set proxy_ssh to false on cloudlab
-full_setup=True
-proxy_ssh=True
-proxy_ssh_key=/opt/cord_profile/node_key
-proxy_ssh_user=root
-enable_watchers=True
-
-[feefie]
-client_id='vicci_dev_central'
-user_id='pl'
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..8cfa16d
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python monitoring-synchronizer.py  -C $XOS_DIR/synchronizers/monitoring/monitoring_from_api_config
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
deleted file mode 100755
index 5c9c2d6..0000000
--- a/xos/synchronizer/run.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#if [[ ! -e ./vcpe-observer.py ]]; then
-#    ln -s ../../xos-observer.py vcpe-observer.py
-#fi
-
-export XOS_DIR=/opt/xos
-python monitoring_synchronizer.py  -C $XOS_DIR/synchronizers/monitoring/monitoring_synchronizer_config
diff --git a/xos/synchronizer/steps/sync_ceilometerservice.py b/xos/synchronizer/steps/sync_ceilometerservice.py
index fe59f4a..2a9ee11 100644
--- a/xos/synchronizer/steps/sync_ceilometerservice.py
+++ b/xos/synchronizer/steps/sync_ceilometerservice.py
@@ -11,11 +11,12 @@
 #from sshtunnel import SSHTunnelForwarder
 from django.db.models import F, Q
 from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from synchronizers.base.ansible_helper import run_template_ssh
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-from core.models import Service, Slice
-from services.monitoring.models import CeilometerService, MonitoringChannel
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.ansible_helper import run_template_ssh
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+#from services.monitoring.models import CeilometerService, MonitoringChannel
+#from core.models import Service, Slice
+from modelaccessor import *
 from xos.logger import Logger, logging
 
 parentdir = os.path.join(os.path.dirname(__file__),"..")
diff --git a/xos/synchronizer/steps/sync_monitoringchannel.py b/xos/synchronizer/steps/sync_monitoringchannel.py
index 49a1962..45c72a6 100644
--- a/xos/synchronizer/steps/sync_monitoringchannel.py
+++ b/xos/synchronizer/steps/sync_monitoringchannel.py
@@ -11,11 +11,12 @@
 #from sshtunnel import SSHTunnelForwarder
 from django.db.models import F, Q
 from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from synchronizers.base.ansible_helper import run_template_ssh
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-from core.models import Service, Slice, ModelLink
-from services.monitoring.models import CeilometerService, MonitoringChannel
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.ansible_helper import run_template_ssh
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from modelaccessor import *
+#from core.models import Service, Slice, ModelLink
+#from services.monitoring.models import CeilometerService, MonitoringChannel
 from xos.logger import Logger, logging
 
 parentdir = os.path.join(os.path.dirname(__file__),"..")
@@ -216,4 +217,3 @@
             #Save the monitoring channel object to reflect the newly updated slice
             obj.save()
         pass
-
diff --git a/xos/synchronizer/steps/sync_openstackmonitoringpublisher.py b/xos/synchronizer/steps/sync_openstackmonitoringpublisher.py
index 6cd51cb..142d2b2 100644
--- a/xos/synchronizer/steps/sync_openstackmonitoringpublisher.py
+++ b/xos/synchronizer/steps/sync_openstackmonitoringpublisher.py
@@ -12,12 +12,13 @@
 #from sshtunnel import SSHTunnelForwarder
 from django.db.models import F, Q
 from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from synchronizers.base.ansible_helper import run_template
-from synchronizers.base.ansible_helper import run_template_ssh
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-from core.models import Service, Slice
-from services.monitoring.models import CeilometerService, OpenStackServiceMonitoringPublisher
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.ansible_helper import run_template
+from synchronizers.new_base.ansible_helper import run_template_ssh
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from modelaccessor import *
+#from core.models import Service, Slice
+#from services.monitoring.models import CeilometerService, OpenStackServiceMonitoringPublisher
 from xos.logger import Logger, logging
 
 parentdir = os.path.join(os.path.dirname(__file__),"..")
diff --git a/xos/synchronizer/steps/sync_sflowservice.py b/xos/synchronizer/steps/sync_sflowservice.py
index d43cb34..f7002f6 100644
--- a/xos/synchronizer/steps/sync_sflowservice.py
+++ b/xos/synchronizer/steps/sync_sflowservice.py
@@ -6,11 +6,12 @@
 import time
 from django.db.models import F, Q
 from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from synchronizers.base.ansible_helper import run_template_ssh
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-from core.models import Service, Slice
-from services.monitoring.models import SFlowService
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.ansible_helper import run_template_ssh
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from modelaccessor import *
+#from core.models import Service, Slice
+#from services.monitoring.models import SFlowService
 from xos.logger import Logger, logging
 
 # hpclibrary will be in steps/..
diff --git a/xos/synchronizer/steps/sync_sflowtenant.py b/xos/synchronizer/steps/sync_sflowtenant.py
index e189fde..9114f4a 100644
--- a/xos/synchronizer/steps/sync_sflowtenant.py
+++ b/xos/synchronizer/steps/sync_sflowtenant.py
@@ -9,11 +9,12 @@
 import json
 from django.db.models import F, Q
 from xos.config import Config
-from synchronizers.base.syncstep import SyncStep
-from synchronizers.base.ansible_helper import run_template_ssh
-from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
-from core.models import Service, Slice, ControllerSlice, ControllerUser
-from services.monitoring.models import SFlowService, SFlowTenant
+from synchronizers.new_base.syncstep import SyncStep
+from synchronizers.new_base.ansible_helper import run_template_ssh
+from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+from modelaccessor import *
+#from core.models import Service, Slice, ControllerSlice, ControllerUser
+#from services.monitoring.models import SFlowService, SFlowTenant
 from xos.logger import Logger, logging
 
 # hpclibrary will be in steps/..