CORD-1008: Add wrappers for vrouterservice, add get_composable_networks, add run_tests.sh

Change-Id: I542822dc6fbdbe3c91b217c2b1a4dcb29abf3a3b
diff --git a/xos/coreapi/tests/cham_slice_crud.sh b/xos/coreapi/tests/cham_slice_crud.sh
index 1f7ce6b..02c4435 100644
--- a/xos/coreapi/tests/cham_slice_crud.sh
+++ b/xos/coreapi/tests/cham_slice_crud.sh
@@ -1,4 +1,4 @@
-source /opt/xos/grpc/tests/testconfig-chameleon.sh
+source /opt/xos/coreapi/tests/testconfig-chameleon.sh
 
 RESPONSE=`curl -X POST -H "Content-Type: application/json" -d "{\"username\": \"$USERNAME\", \"password\": \"$PASSWORD\"}" http://$HOSTNAME:8080/xosapi/v1/utility/login`
 SESSIONID=`echo $RESPONSE | python -c "import json,sys; print json.load(sys.stdin)['sessionid']"`
diff --git a/xos/coreapi/tests/run_tests.sh b/xos/coreapi/tests/run_tests.sh
new file mode 100644
index 0000000..4e4b167
--- /dev/null
+++ b/xos/coreapi/tests/run_tests.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+# Helper script for running chameleon tests from inside prod vm
+
+PUB_IP=`dig +short myip.opendns.com @resolver1.opendns.com`
+PW=`cat /opt/cord/build/platform-install/credentials/xosadmin@opencord.org`
+
+CONTAINER_NAME=rcord_xos_core_1
+
+echo "HOSTNAME=$PUB_IP" > testconfig-chameleon.sh
+echo "USERNAME=xosadmin@opencord.org" >> testconfig-chameleon.sh
+echo "PASSWORD=$PW" >> testconfig-chameleon.sh
+
+# chameleon_list_test.sh is autogenerated inside of the core api container,
+# so we have to run the test from inside the container.
+
+docker cp testconfig-chameleon.sh $CONTAINER_NAME:/opt/xos/coreapi/tests/
+docker exec -it $CONTAINER_NAME bash /opt/xos/coreapi/tests/chameleon_list_test.sh
+docker exec -it $CONTAINER_NAME bash /opt/xos/coreapi/tests/cham_slice_crud.sh
diff --git a/xos/xos_client/xosapi/convenience/service.py b/xos/xos_client/xosapi/convenience/service.py
index 02d8c4d..965314b 100644
--- a/xos/xos_client/xosapi/convenience/service.py
+++ b/xos/xos_client/xosapi/convenience/service.py
@@ -9,4 +9,18 @@
             attrs[attr.name] = attr.value
         return attrs
 
+    def get_composable_networks(self):
+	SUPPORTED_VTN_SERVCOMP_KINDS = ['VSG','PRIVATE']
+
+        nets = []
+        for slice in self.slices.all():
+            for net in slice.networks.all():
+                if (net.template.vtn_kind not in SUPPORTED_VTN_SERVCOMP_KINDS) or (net.owner != slice):
+                    continue
+
+                if not net.controllernetworks.exists():
+                    continue
+                nets.append(net)
+        return nets
+
 register_convenience_wrapper("Service", ORMWrapperService)
diff --git a/xos/xos_client/xosapi/convenience/vrouterservice.py b/xos/xos_client/xosapi/convenience/vrouterservice.py
new file mode 100644
index 0000000..c1a38f5
--- /dev/null
+++ b/xos/xos_client/xosapi/convenience/vrouterservice.py
@@ -0,0 +1,15 @@
+import json
+from xosapi.orm import ORMWrapper, register_convenience_wrapper
+from xosapi.convenience.service import ORMWrapperService
+
+class ORMWrapperVRouterService(ORMWrapperService):
+    def get_gateways(self):
+        gateways = []
+
+        aps = self.addresspools.all()
+        for ap in aps:
+            gateways.append({"gateway_ip": ap.gateway_ip, "gateway_mac": ap.gateway_mac})
+
+        return gateways
+
+register_convenience_wrapper("VRouterService", ORMWrapperVRouterService)
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index 53d214e..463f2f8 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -447,6 +447,7 @@
 import convenience.cordsubscriberroot
 import convenience.volttenant
 import convenience.vsgtenant
+import convenience.vrouterservice
 import convenience.vroutertenant
 import convenience.vrouterapp
 import convenience.service