CORD-772 Added make target and TOSCA spec for example UI extension

Change-Id: If26ccc840259e82edcec11df2949fd6798bcdfbc
diff --git a/common/Makefile b/common/Makefile
index 9dba3b3..3771b40 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -247,3 +247,14 @@
 	bash $(COMMON_DIR)/wait_for_onboarding_ready.sh $(XOS_BOOTSTRAP_PORT) xos
 	bash $(COMMON_DIR)/wait_for_xos_port.sh $(XOS_UI_PORT)
 
+xos_gui_sample_extension_c:
+	# this folder is cloned by repo
+	cd $(HOME_DIR)/xos-sample-gui-extension; sudo docker build --no-cache=${NO_DOCKER_CACHE} -t xosproject/xos-sample-gui-extension .
+
+ui-sample-extension: xos_gui_sample_extension_c
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/tosca/disable-onboarding.yaml
+	$(RUN_TOSCA_BOOTSTRAP) $(COMMON_DIR)/xos-gui-extension.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/xos-gui-extension.yaml b/common/xos-gui-extension.yaml
new file mode 100644
index 0000000..5b999cd
--- /dev/null
+++ b/common/xos-gui-extension.yaml
@@ -0,0 +1,37 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    # UI Container
+    xos-spa-gui:
+      type: tosca.nodes.Component
+      properties:
+        no-create: true
+        no-update: true
+        no-delete: true
+
+     # UI Extension Container
+    xos-sample-gui-extension:
+      type: tosca.nodes.Component
+      properties:
+        image: xosproject/xos-sample-gui-extension
+        ports: 4001:4000
+        # extra: '["xos-sample-gui-extension:4001/spa/vendor.js", "xos-sample-gui-extension:4001/spa/app.js"]'
+        extra: '["http://xos.dev:4001/spa/vendor.js", "http://xos.dev:4001/spa/app.js"]'
+
+    gui-to-extension:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: xos-sample-gui-extension
+          alias: xos-sample-gui-extension
+          kind: internal
+      requirements:
+          - xos:
+             node: xos-spa-gui
+             relationship: tosca.relationships.LinkOfComponent
\ No newline at end of file
diff --git a/cord-pod/xos-gui.yaml b/cord-pod/xos-gui.yaml
index 2dae32f..e05c999 100644
--- a/cord-pod/xos-gui.yaml
+++ b/cord-pod/xos-gui.yaml
@@ -12,8 +12,6 @@
     xos-spa-gui:
       type: tosca.nodes.Component
       properties:
-        # command: cd /var/www; BRAND=cord npm run build
-        name: xos-spa-gui
         image: xosproject/xos-gui
         ports: 4000:4000
 
diff --git a/cord-pod/xos-rest-gw.yaml b/cord-pod/xos-rest-gw.yaml
index 1132dd9..8c708ab 100644
--- a/cord-pod/xos-rest-gw.yaml
+++ b/cord-pod/xos-rest-gw.yaml
@@ -12,7 +12,6 @@
     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
diff --git a/frontend/Makefile b/frontend/Makefile
index 01439c7..3ee4296 100644
--- a/frontend/Makefile
+++ b/frontend/Makefile
@@ -112,4 +112,4 @@
 
 clean-config-folder:
 	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 rm -f /opt/xos/xos_configuration/xos_mcord_config
-	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 rm -f /opt/xos/xos_configuration/xos_cord_config
+	sudo docker exec $(DOCKER_PROJECT)_xos_ui_1 rm -f /opt/xos/xos_configuration/xos_cord_config
\ No newline at end of file
diff --git a/frontend/xos-gui.yaml b/frontend/xos-gui.yaml
index 5ae4ddd..0321d03 100644
--- a/frontend/xos-gui.yaml
+++ b/frontend/xos-gui.yaml
@@ -12,7 +12,6 @@
     xos-spa-gui:
       type: tosca.nodes.Component
       properties:
-        name: xos-spa-gui
         image: xosproject/xos-gui
         ports: 4000:4000
 
diff --git a/frontend/xos-rest-gw.yaml b/frontend/xos-rest-gw.yaml
index a4b1062..7e1f062 100644
--- a/frontend/xos-rest-gw.yaml
+++ b/frontend/xos-rest-gw.yaml
@@ -12,7 +12,6 @@
     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
diff --git a/mcord/xos-gui.yaml b/mcord/xos-gui.yaml
index ac50a71..05baa56 100644
--- a/mcord/xos-gui.yaml
+++ b/mcord/xos-gui.yaml
@@ -13,7 +13,6 @@
       type: tosca.nodes.Component
       properties:
         # command: cd /var/www; BRAND=opencloud npm run build
-        name: xos-spa-gui
         image: xosproject/xos-gui
         ports: 4000:4000
         
diff --git a/mcord/xos-rest-gw.yaml b/mcord/xos-rest-gw.yaml
index 843e8fc..2d507af 100644
--- a/mcord/xos-rest-gw.yaml
+++ b/mcord/xos-rest-gw.yaml
@@ -12,7 +12,6 @@
     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
diff --git a/metronetwork/xos-gui.yaml b/metronetwork/xos-gui.yaml
index ac50a71..4cafd6d 100644
--- a/metronetwork/xos-gui.yaml
+++ b/metronetwork/xos-gui.yaml
@@ -12,8 +12,6 @@
     xos-spa-gui:
       type: tosca.nodes.Component
       properties:
-        # command: cd /var/www; BRAND=opencloud npm run build
-        name: xos-spa-gui
         image: xosproject/xos-gui
         ports: 4000:4000
         
diff --git a/metronetwork/xos-rest-gw.yaml b/metronetwork/xos-rest-gw.yaml
index dbedbcb..c933322 100644
--- a/metronetwork/xos-rest-gw.yaml
+++ b/metronetwork/xos-rest-gw.yaml
@@ -12,7 +12,6 @@
     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
diff --git a/opencloud/Makefile b/opencloud/Makefile
index 4b2e571..6078f14 100644
--- a/opencloud/Makefile
+++ b/opencloud/Makefile
@@ -11,7 +11,7 @@
 # Include common functions
 include $(COMMON_DIR)/Makefile
 
-xos: prereqs config_dirs xos_download opencloud_services bootstrap onboarding
+xos: prereqs config_dirs xos_download opencloud_services bootstrap onboarding rest-gw ui
 
 opencloud_services: $(SERVICE_DIR) \
 	$(SERVICE_DIR)/onos-service \
diff --git a/opencloud/ui-style-config.js b/opencloud/ui-style-config.js
new file mode 100644
index 0000000..e44a76d
--- /dev/null
+++ b/opencloud/ui-style-config.js
@@ -0,0 +1,18 @@
+angular.module('app')
+  .constant('StyleConfig', {
+    projectName: 'OpenCloud',
+    favicon: 'opencloud-favicon.png',
+    background: 'opencloud-bg.jpg',
+    payoff: 'Your OS resource manager',
+    logo: 'opencloud-logo.png',
+    routes: [
+        {
+            label: 'Slices',
+            state: 'xos.core.slices'
+        },
+        {
+            label: 'Sites',
+            state: 'xos.core.sites'
+        }
+    ]
+});
diff --git a/opencloud/xos-gui.yaml b/opencloud/xos-gui.yaml
new file mode 100644
index 0000000..0321d03
--- /dev/null
+++ b/opencloud/xos-gui.yaml
@@ -0,0 +1,38 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+
+    # UI Container
+    xos-spa-gui:
+      type: tosca.nodes.Component
+      properties:
+        image: xosproject/xos-gui
+        ports: 4000:4000
+
+    # UI Style Config
+    /var/www/dist/style.config.js:
+      type: tosca.nodes.ComponentVolume
+      properties:
+          host_path: { path_join: [ SELF, CONFIG_DIR, ./ui-style-config.js, ENV_VAR ] }
+          read_only: false
+      requirements:
+          - xos:
+             node: xos-spa-gui
+             relationship: tosca.relationships.VolumeOfComponent
+
+    gui-to-gw:
+      type: tosca.nodes.ComponentLink
+      properties:
+          container: xos-rest-gateway
+          alias: xos-rest-gw
+          kind: internal
+      requirements:
+          - xos:
+             node: xos-spa-gui
+             relationship: tosca.relationships.LinkOfComponent
\ No newline at end of file
diff --git a/opencloud/xos-rest-gw.yaml b/opencloud/xos-rest-gw.yaml
new file mode 100644
index 0000000..7e1f062
--- /dev/null
+++ b/opencloud/xos-rest-gw.yaml
@@ -0,0 +1,50 @@
+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:
+        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