CORD-1008 add dockerfile and docker-compose for vtr, eliminate unnecessary ansible fields
Change-Id: I8296b0c6410414410872ac0dcaf9df7d012bc038
diff --git a/xos/synchronizer/Dockerfile.synchronizer b/xos/synchronizer/Dockerfile.synchronizer
new file mode 100644
index 0000000..3521ad3
--- /dev/null
+++ b/xos/synchronizer/Dockerfile.synchronizer
@@ -0,0 +1,9 @@
+FROM xosproject/xos-synchronizer-base
+
+ADD . /opt/xos/synchronizers/vtr
+
+ENTRYPOINT []
+
+WORKDIR "/opt/xos/synchronizers/vtr"
+
+CMD bash -c "cd /opt/xos/synchronizers/vtr; ./run-from-api.sh"
diff --git a/xos/synchronizer/Makefile b/xos/synchronizer/Makefile
new file mode 100644
index 0000000..39a930a
--- /dev/null
+++ b/xos/synchronizer/Makefile
@@ -0,0 +1,5 @@
+synchronizer:
+ sudo docker build --rm -f Dockerfile.synchronizer -t xosproject/vtr-synchronizer .
+
+up:
+ docker-compose -p vtr up -d
diff --git a/xos/synchronizer/docker-compose.yml b/xos/synchronizer/docker-compose.yml
new file mode 100644
index 0000000..8e605fe
--- /dev/null
+++ b/xos/synchronizer/docker-compose.yml
@@ -0,0 +1,23 @@
+version: '2'
+
+networks:
+ xos:
+ external: true
+
+services:
+ synchronizer:
+ image: xosproject/vtr-synchronizer
+ networks:
+ - xos
+ #command: bash -c "sleep 86400"
+ volumes:
+ - /opt/cord_profile/key_import/vsg_rsa:/opt/xos/services/vtr/keys/vsg_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/vtr/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/run-from-api.sh b/xos/synchronizer/run-from-api.sh
new file mode 100755
index 0000000..b5abcf7
--- /dev/null
+++ b/xos/synchronizer/run-from-api.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python vtr-synchronizer.py -C $XOS_DIR/synchronizers/vtr/vtr_from_api_config
diff --git a/xos/synchronizer/steps/sync_vtrtenant.py b/xos/synchronizer/steps/sync_vtrtenant.py
index 0209d3f..2b91815 100644
--- a/xos/synchronizer/steps/sync_vtrtenant.py
+++ b/xos/synchronizer/steps/sync_vtrtenant.py
@@ -41,9 +41,10 @@
def get_target(self, o):
target = o.target
if target:
+ model_name = getattr(target, "model_name", target.__class__.__name__)
# CordSubscriberRoot is a Proxy object, and o.target will point to
# the base class... so fix it up.
- if target.__class__.__name__ == "TenantRoot":
+ if model_name == "TenantRoot":
target = CordSubscriberRoot.objects.get(id=target.id)
return target
return None
@@ -51,7 +52,7 @@
def get_vcpe_service(self, o):
target = self.get_target(o)
if target and target.volt and target.volt.vcpe:
- vcpes = VSGService.get_service_objects().filter(id=target.volt.vcpe.provider_service.id)
+ vcpes = VSGService.objects.filter(id=target.volt.vcpe.provider_service.id)
if not vcpes:
return None
return vcpes[0]
@@ -103,23 +104,22 @@
"c_tags": c_tags,
"isolation": instance.isolation,
"container_name": "vcpe-%s-%s" % (s_tags[0], c_tags[0]),
- "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")],
-
+# "dns_servers": [x.strip() for x in vcpe_service.dns_servers.split(",")],
"result_fn": "%s-vcpe-%s-%s" % (o.test, s_tags[0], c_tags[0]),
"resultcode_fn": "code-%s-vcpe-%s-%s" % (o.test, s_tags[0], c_tags[0]) }
# add in the sync_attributes that come from the vSG object
# this will be wan_ip, wan_mac, wan_container_ip, wan_container_mac, ...
- if target and target.volt and target.volt.vcpe:
- for attribute_name in target.volt.vcpe.sync_attributes:
- fields[attribute_name] = getattr(target.volt.vcpe, attribute_name)
+# if target and target.volt and target.volt.vcpe:
+# for attribute_name in target.volt.vcpe.sync_attributes:
+# fields[attribute_name] = getattr(target.volt.vcpe, attribute_name)
# add in the sync_attributes that come from the SubscriberRoot object
- if target and hasattr(target, "sync_attributes"):
- for attribute_name in target.sync_attributes:
- fields[attribute_name] = getattr(target, attribute_name)
+# if target and hasattr(target, "sync_attributes"):
+# for attribute_name in target.sync_attributes:
+# fields[attribute_name] = getattr(target, attribute_name)
- for attribute_name in o.sync_attributes:
+ for attribute_name in ["scope", "test", "argument"]: # o.sync_attributes:
fields[attribute_name] = getattr(o,attribute_name)
return fields
diff --git a/xos/synchronizer/steps/sync_vtrtenant.yaml b/xos/synchronizer/steps/sync_vtrtenant.yaml
index bd44264..886916e 100644
--- a/xos/synchronizer/steps/sync_vtrtenant.yaml
+++ b/xos/synchronizer/steps/sync_vtrtenant.yaml
@@ -6,13 +6,6 @@
become: yes
vars:
container_name: {{ container_name }}
- wan_container_ip: {{ wan_container_ip }}
- wan_container_netbits: {{ wan_container_netbits }}
- wan_container_mac: {{ wan_container_mac }}
- wan_container_gateway_ip: {{ wan_container_gateway_ip }}
- wan_vm_ip: {{ wan_vm_ip }}
- wan_vm_mac: {{ wan_vm_mac }}
-
scope: {{ scope }}
test: {{ test }}
argument: {{ argument }}
diff --git a/xos/synchronizer/vtr_from_api_config b/xos/synchronizer/vtr_from_api_config
new file mode 100644
index 0000000..1b20d7c
--- /dev/null
+++ b/xos/synchronizer/vtr_from_api_config
@@ -0,0 +1,20 @@
+# Sets options for the synchronizer
+[observer]
+name=vtr
+dependency_graph=/opt/xos/synchronizers/vtr/model-deps
+steps_dir=/opt/xos/synchronizers/vtr/steps
+sys_dir=/opt/xos/synchronizers/vtr/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/vtr/credentials/xosadmin@opencord.org
+
+[networking]
+use_vtn=True