create xos-core container to hold grpc server (CORD-695)

Change-Id: I385d981c7ad04c7e4a03db710c219c68b38eb0b6
diff --git a/xos/grpc/certs/Makefile b/xos/grpc/certs/Makefile
index ad30dfc..f7cdc3a 100644
--- a/xos/grpc/certs/Makefile
+++ b/xos/grpc/certs/Makefile
@@ -10,7 +10,7 @@
 	openssl genrsa -passout pass:1111 -des3 -out server.key 4096
 
 server.csr: server.key
-	openssl req -passin pass:1111 -new -key server.key -out server.csr -subj  "/C=US/ST=CA/L=Cupertino/O=YourCompany/OU=YourApp/CN=localhost"
+	openssl req -passin pass:1111 -new -key server.key -out server.csr -subj  "/C=US/ST=CA/L=Cupertino/O=YourCompany/OU=YourApp/CN=xos-core.cord.lab"
 
 server.crt: ca.crt ca.key server.csr
 	openssl x509 -req -passin pass:1111 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt
diff --git a/xos/grpc/grpc_client.py b/xos/grpc/grpc_client.py
index c40e99f..db5745f 100644
--- a/xos/grpc/grpc_client.py
+++ b/xos/grpc/grpc_client.py
@@ -40,10 +40,10 @@
         self.stub = xos_pb2_grpc.xosStub(self.channel)
 
 def main():  # self-test
-    client = InsecureClient("localhost")
+    client = InsecureClient("xos-core.cord.lab")
     print client.stub.ListUser(Empty())
 
-    client = SecureClient("localhost", username="padmin@vicci.org", password="letmein")
+    client = SecureClient("xos-core.cord.lab", username="padmin@vicci.org", password="letmein")
     print client.stub.ListUser(Empty())
 
 if __name__=="__main__":
diff --git a/xos/grpc/list_test.py b/xos/grpc/list_test.py
index 1ff17a5..ddfd482 100644
--- a/xos/grpc/list_test.py
+++ b/xos/grpc/list_test.py
@@ -1,7 +1,7 @@
 import grpc_client
 from grpc_client import Empty
 
-c=grpc_client.InsecureClient("localhost")
+c=grpc_client.InsecureClient("xos-core.cord.lab")
 
 
 print "testing insecure ListServiceControllerResource...",
@@ -251,7 +251,7 @@
 c.stub.ListUser(Empty())
 print "Okay"
 
-c=grpc_client.SecureClient("localhost", username="padmin@vicci.org", password="letmein")
+c=grpc_client.SecureClient("xos-core.cord.lab", username="padmin@vicci.org", password="letmein")
 
 
 print "testing secure ListServiceControllerResource...",
diff --git a/xos/grpc/start_grpc_server.sh b/xos/grpc/start_grpc_server.sh
new file mode 100755
index 0000000..d5b2e6f
--- /dev/null
+++ b/xos/grpc/start_grpc_server.sh
@@ -0,0 +1,9 @@
+cd protos
+make rebuild-protos
+make
+cd ..
+cd certs
+make
+cd ..
+source env.sh
+python ./grpc_server.py
diff --git a/xos/synchronizers/onboarding/xosbuilder.py b/xos/synchronizers/onboarding/xosbuilder.py
index d352865..df584a6 100644
--- a/xos/synchronizers/onboarding/xosbuilder.py
+++ b/xos/synchronizers/onboarding/xosbuilder.py
@@ -333,26 +333,29 @@
         if xos.redis_container_name:
             external_links.append("%s:%s" % (xos.redis_container_name, "redis"))
 
+        # eventually xos_ui will go away, and only xos_core shall remain.
+
         containers["xos_ui"] = {
             "image": "xosproject/xos-ui",
             "command": "python /opt/xos/manage.py runserver 0.0.0.0:%d --insecure --makemigrations" % xos.ui_port,
             "networks": networks,
             "ports": {"%d" % xos.ui_port: "%d" % xos.ui_port},
-            # "links": ["xos_db"],
-            # "external_links": ["%s:%s" % (xos.db_container_name, "xos_db")],
+            "external_links": external_links,
+            "extra_hosts": extra_hosts,
+            "volumes": volume_list}
+
+        containers["xos_core"] = {
+            "image": "xosproject/xos-ui",
+            "command": 'bash -c "cd grpc; bash ./start_grpc_server.sh"',
+            "networks": networks,
+            "ports": {"50055": "50055", "50051" : "50051"},
             "external_links": external_links,
             "extra_hosts": extra_hosts,
             "volumes": volume_list}
 
         if xos.no_start:
             containers["xos_ui"]["command"] = "sleep 864000"
-
-#         containers["xos_bootstrap_ui"] = {"image": "xosproject/xos",
-#                             "command": "python /opt/xos/manage.py runserver 0.0.0.0:%d --insecure --makemigrations" % xos.bootstrap_ui_port,
-#                             "ports": {"%d"%xos.bootstrap_ui_port : "%d"%xos.bootstrap_ui_port},
-#                             #"external_links": ["%s:%s" % (xos.db_container_name, "xos_db")],
-#                             "links": ["xos_db"],
-#                             "volumes": volume_list}
+            containers["xos_core"]["command"] = "sleep 864000"
 
         # creating Component containers
         for c in XOSComponent.objects.all():
diff --git a/xos/tools/apigen/grpc_list_test.template.py b/xos/tools/apigen/grpc_list_test.template.py
index 320d9eb..fd22503 100644
--- a/xos/tools/apigen/grpc_list_test.template.py
+++ b/xos/tools/apigen/grpc_list_test.template.py
@@ -1,7 +1,7 @@
 import grpc_client
 from grpc_client import Empty
 
-c=grpc_client.InsecureClient("localhost")
+c=grpc_client.InsecureClient("xos-core.cord.lab")
 
 {% for object in generator.all() %}
 print "testing insecure List{{ object.camel() }}...",
@@ -9,7 +9,7 @@
 print "Okay"
 {%- endfor %}
 
-c=grpc_client.SecureClient("localhost", username="padmin@vicci.org", password="letmein")
+c=grpc_client.SecureClient("xos-core.cord.lab", username="padmin@vicci.org", password="letmein")
 
 {% for object in generator.all() %}
 print "testing secure List{{ object.camel() }}...",