CORD-1008 Dockerfile and docker-compose for onos synchronizer

Change-Id: If345b5946282dee8035ee5bc51c0e73f72a469ed
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..eb50c97
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,9 @@
+FROM xosproject/xos-synchronizer-base
+
+ADD . /opt/xos/synchronizers/onos
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/onos"
+
+CMD bash -c "cd /opt/xos/synchronizers/onos; ./run-from-api.sh"
diff --git a/xos/synchronizer/Makefile b/xos/synchronizer/Makefile
new file mode 100644
index 0000000..464bb7c
--- /dev/null
+++ b/xos/synchronizer/Makefile
@@ -0,0 +1,5 @@
+synchronizer:
+	sudo docker build --rm -f Dockerfile.synchronizer -t xosproject/onos-synchronizer .
+
+up:
+	docker-compose -p onos up -d
diff --git a/xos/synchronizer/docker-compose.yml b/xos/synchronizer/docker-compose.yml
new file mode 100644
index 0000000..8dc4af3
--- /dev/null
+++ b/xos/synchronizer/docker-compose.yml
@@ -0,0 +1,23 @@
+version: '2'
+
+networks:
+  xos:
+    external: true
+
+services:
+  synchronizer:
+    image: xosproject/onos-synchronizer
+    networks:
+      - xos
+    #command: bash -c "sleep 86400"
+    volumes:
+        - /opt/cord_profile/key_import/onos_rsa:/opt/xos/services/onos/keys/onos_rsa:ro
+        - /opt/cord_profile/node_key:/opt/cord_profile/node_key:ro
+        - /opt/cord/build/platform-install/credentials/xosadmin@opencord.org:/opt/xos/services/onos/credentials/xosadmin@opencord.org
+    external_links: 
+        - rcordbs_xos_redis_1:redis
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
diff --git a/xos/synchronizer/onos_from_api_config b/xos/synchronizer/onos_from_api_config
new file mode 100644
index 0000000..5510aca
--- /dev/null
+++ b/xos/synchronizer/onos_from_api_config
@@ -0,0 +1,20 @@
+# Sets options for the synchronizer
+[observer]
+name=onos
+dependency_graph=/opt/xos/synchronizers/onos/model-deps
+steps_dir=/opt/xos/synchronizers/onos/steps
+sys_dir=/opt/xos/synchronizers/onos/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
+accessor_kind=api
+accessor_password=@/opt/xos/services/onos/credentials/xosadmin@opencord.org
+
+[networking]
+use_vtn=True
diff --git a/xos/synchronizer/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..5fe9bc9
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python onos-synchronizer.py  -C $XOS_DIR/synchronizers/onos/onos_from_api_config
diff --git a/xos/synchronizer/steps/sync_onosapp.py b/xos/synchronizer/steps/sync_onosapp.py
index cc5d25e..cba8290 100644
--- a/xos/synchronizer/steps/sync_onosapp.py
+++ b/xos/synchronizer/steps/sync_onosapp.py
@@ -101,6 +101,15 @@
             return cuser.kuser_id
 
     def write_configs(self, o):
+        if hasattr(o, "create_attr"):
+            # new API doesn't let us setattr for things that don't already exist
+            o.create_attr("config_fns")
+            o.create_attr("rest_configs")
+            o.create_attr("component_configs")
+            o.create_attr("files_dir")
+            o.create_attr("node_key_fn")
+            o.create_attr("early_rest_configs")
+
         o.config_fns = []
         o.rest_configs = []
         o.component_configs = []