Moved xos_ui to port 9000 and xos_bootstrap_ui to port 9001 for all config

Change-Id: I75ab78deb55b344b0b64b183dda2859936045e9c
diff --git a/common/Makedefs b/common/Makedefs
index c7a808d..72a4654 100644
--- a/common/Makedefs
+++ b/common/Makedefs
@@ -10,11 +10,12 @@
 XOS_DIR              ?= $(HOME_DIR)/xos
 SERVICE_DIR          ?= $(HOME_DIR)/xos_services
 LIBRARY_DIR          ?= $(HOME_DIR)/xos_libraries
-REST_GW_DIR          ?= $(HOME_DIR)/xos-rest-gw
-GUI_DIR              ?= $(HOME_DIR)/xos-gui
+# NOTE should we move xos-gui and xos-rest-gw to these folder instead that in libraries? In case update repo manifest accordingly
+# REST_GW_DIR          ?= $(HOME_DIR)/xos-rest-gw
+# GUI_DIR              ?= $(HOME_DIR)/xos-gui
 
-XOS_BOOTSTRAP_PORT   ?= 81
-XOS_UI_PORT          ?= 80
+XOS_BOOTSTRAP_PORT   ?= 9001
+XOS_UI_PORT          ?= 9000
 
 DOCKER_PROJECT       ?= unknown
 BOOTSTRAP_PROJECT    ?= $(DOCKER_PROJECT)bs
@@ -76,3 +77,9 @@
 
 GLOBALXOS_BRANCH ?= $(DEFAULT_BRANCH)
 GLOBALXOS_GIT_URL ?= $(CORD_BASE_GIT_URL)/globalxos.git
+
+XOS_REST_GW_BRANCH ?= $(DEFAULT_BRANCH)
+XOS_REST_GW_URL ?= $(CORD_BASE_GIT_URL)/xos-rest-gw.git
+
+XOS_GUI_BRANCH ?= $(DEFAULT_BRANCH)
+XOS_GUI_URL ?= $(CORD_BASE_GIT_URL)/xos-gui.git
diff --git a/common/Makefile b/common/Makefile
index 68567e1..c8b6b76 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -123,7 +123,9 @@
 	git -C $(SERVICE_DIR)/metronet-local pull
 
 cord_libraries: $(LIBRARY_DIR) \
-        $(LIBRARY_DIR)/ng-xos-lib
+        $(LIBRARY_DIR)/ng-xos-lib \
+        $(LIBRARY_DIR)/xos-rest-gw \
+        $(LIBRARY_DIR)/xos-gui
 
 $(LIBRARY_DIR):
 	mkdir -p $(LIBRARY_DIR)
@@ -131,6 +133,12 @@
 $(LIBRARY_DIR)/ng-xos-lib:
 	git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(NG_XOS_LIB_BRANCH) $(NG_XOS_LIB_URL)
 
+$(LIBRARY_DIR)/xos-rest-gw:
+	git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_REST_GW_BRANCH) $(XOS_REST_GW_URL)
+
+$(LIBRARY_DIR)/xos-gui:
+	git -C $(LIBRARY_DIR) $(GITOPTS) clone -b $(XOS_GUI_BRANCH) $(XOS_GUI_URL)
+
 # bootstrap the containers
 
 RUN_TOSCA_BOOTSTRAP ?= python $(COMMON_DIR)/run_tosca.py $(XOS_BOOTSTRAP_PORT) $(ADMIN_USERNAME) $(ADMIN_PASSWORD)
@@ -176,11 +184,11 @@
 
 xos_rest_gw_c:
 	# this folder is cloned by repo
-	cd $(REST_GW_DIR); docker build -t xosproject/xos-rest-gw .
+	cd $(LIBRARY_DIR)/xos-rest-gw; sudo docker build -t xosproject/xos-rest-gw .
 
 xos_gui_c:
 	# this folder is cloned by repo
-	cd $(GUI_DIR); docker build -t xosproject/xos-gui .
+	cd $(LIBRARY_DIR)/xos-gui; sudo docker build -t xosproject/xos-gui .
 
 
 # utilties/convenience targets
@@ -225,3 +233,17 @@
 django-restart:
 	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 touch /opt/xos/xos/settings.py
 
+rest-gw: xos_rest_gw_c
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/xos-rest-gw.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
+	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
+	bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
+
+ui: xos_gui_c
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(CONFIG_DIR)/xos-gui.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/enable-onboarding.yaml
+	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
+	bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
+
diff --git a/common/gateway-config.yml b/common/gateway-config.yml
new file mode 100644
index 0000000..0e70f01
--- /dev/null
+++ b/common/gateway-config.yml
@@ -0,0 +1,9 @@
+default:
+  xos:
+    host: xos
+    port: 9000
+  redis:
+    host: redis
+    port: 6379
+  gateway:
+    port: 3000
\ No newline at end of file
diff --git a/common/xos-rest-gw.yaml b/common/xos-rest-gw.yaml
new file mode 100644
index 0000000..a4b1062
--- /dev/null
+++ b/common/xos-rest-gw.yaml
@@ -0,0 +1,51 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    # API Gateway
+    xos-rest-gateway:
+      type: tosca.nodes.Component
+      properties:
+        name: xos-rest-gateway
+        image: xosproject/xos-rest-gw
+        command: npm start -- --config gateway-config.yml
+        ports: 3000:3000
+
+    # API Gateway config file
+    /var/www/src/config/gateway-config.yml:
+      type: tosca.nodes.ComponentVolume
+      properties:
+          host_path: { path_join: [ SELF, CONFIG_DIR, ./../common/gateway-config.yml, ENV_VAR ] }
+          read_only: false
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.VolumeOfComponent
+
+    gw-to-xos:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: xos_ui
+          alias: xos
+          kind: internal
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.LinkOfComponent
+
+    gw-to-redis:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: frontendbs_xos_redis_1
+          alias: redis
+          kind: external
+      requirements:
+          - xos:
+             node: xos-rest-gateway
+             relationship: tosca.relationships.LinkOfComponent
\ No newline at end of file