CORD-1033 Pull all XOS containers from registry

Change-Id: Icd2ab199028b7f28750419fb560a5fd79102c9bd
diff --git a/deploy-xos-playbook.retry b/deploy-xos-playbook.retry
deleted file mode 100644
index 09f420c..0000000
--- a/deploy-xos-playbook.retry
+++ /dev/null
@@ -1 +0,0 @@
-mockrcord_xos_ui_1
diff --git a/deploy-xos-playbook.yml b/deploy-xos-playbook.yml
index f9cb4cf..1304c3e 100644
--- a/deploy-xos-playbook.yml
+++ b/deploy-xos-playbook.yml
@@ -20,6 +20,9 @@
 - include: ../../orchestration/xos/pull-xos-playbook.yml
 - include: ../../orchestration/xos/build-xos-playbook.yml
 
+# build XOS core
+- include: build-platform-install-playbook.yml
+
 - include: pki-install-playbook.yml
 
 - include: cord-profile-playbook.yml
diff --git a/launch-xos-playbook.yml b/launch-xos-playbook.yml
index 0af98bb..8b1a0fd 100644
--- a/launch-xos-playbook.yml
+++ b/launch-xos-playbook.yml
@@ -13,19 +13,10 @@
 # for docker, docker-compose
 - include: devel-tools-playbook.yml
 
-- name: Bootstrap XOS in docker
+- name: Bring up XOS containers
   hosts: head
   roles:
-    - xos-bootstrap
-
-- include: add-bootstrap-containers-playbook.yml
-
-- name: Onboard XOS services
-  hosts: xos_bootstrap_ui
-  connection: docker
-  roles:
-    - xos-onboarding
-    - xos-gui-extension-onboard
+    - xos-up
 
 - include: add-onboard-containers-playbook.yml
 
diff --git a/onboard-exampleservice-playbook.yml b/onboard-exampleservice-playbook.yml
index d167527..2ca492e 100644
--- a/onboard-exampleservice-playbook.yml
+++ b/onboard-exampleservice-playbook.yml
@@ -11,25 +11,7 @@
         - "profile_manifests/{{ cord_profile }}.yml"
         - profile_manifests/local_vars.yml
 
-- name: Create exampleservice config
+- name: Create exampleservice configuration
   hosts: head
   roles:
     - exampleservice-config
-
-- include: add-bootstrap-containers-playbook.yml
-
-- name: Onboard exampleservice services
-  hosts: xos_bootstrap_ui
-  connection: docker
-  roles:
-    - exampleservice-onboard
-
-- include: add-onboard-containers-playbook.yml
-
-- name: Check to see if XOS UI is ready
-  hosts: xos_ui
-  connection: docker
-  roles:
-    - xos-ready
-
-
diff --git a/profile_manifests/ecord.yml b/profile_manifests/ecord.yml
index 42f5cab..2dcdc8c 100644
--- a/profile_manifests/ecord.yml
+++ b/profile_manifests/ecord.yml
@@ -44,6 +44,7 @@
     path: orchestration/xos_services/openstack
   - name: onos
     path: orchestration/xos_services/onos-service
+    keypair: onos_rsa
   - name: vtn
     path: onos-apps/apps/vtn
   - name: fabric
@@ -52,14 +53,11 @@
     path: orchestration/xos_services/vrouter
   - name: veg
     path: orchestration/xos_services/vEG
+    keypair: veg_rsa
   - name: vnodlocal
     path: orchestration/xos_services/metronet-local
   - name: vee
     path: orchestration/xos_services/vEE
-  - name: veg_rsa
-    source_path: "/dev/null"
-  - name: veg_rsa.pub
-    source_path: "/dev/null"
 
 xos_service_sshkeys:
   - name: onos_rsa
diff --git a/profile_manifests/rcord.yml b/profile_manifests/rcord.yml
index 48cc057..c7d7cf5 100644
--- a/profile_manifests/rcord.yml
+++ b/profile_manifests/rcord.yml
@@ -51,25 +51,42 @@
 xos_services:
   - name: volt
     path: onos-apps/apps/olt
+    keypair: volt_rsa
+    synchronizer: false
   - name: vtn
     path: onos-apps/apps/vtn
+    keypair: vsg_rsa
+    synchronizer: true
   - name: openstack
     path: orchestration/xos_services/openstack
+    synchronizer: true
   - name: onos
     path: orchestration/xos_services/onos-service
+    keypair: onos_rsa
+    synchronizer: true
   - name: vrouter
     path: orchestration/xos_services/vrouter
+    synchronizer: true
   - name: vsg
     path: orchestration/xos_services/vsg
+    keypair: vsg_rsa
+    synchronizer: true
   - name: vtr
     path: orchestration/xos_services/vtr
+    keypair: vsg_rsa
+    synchronizer: true
   - name: fabric
     path: orchestration/xos_services/fabric
+    synchronizer: true
 # needed onboarding synchronizer doesn't require service code to be present when started
   - name: exampleservice
     path: orchestration/xos_services/exampleservice
+    keypair: exampleservice_rsa
+    synchronizer: true
   - name: monitoring
     path: orchestration/xos_services/monitoring
+    keypair: monitoringservice_rsa
+    synchronizer: false
 
 xos_service_sshkeys:
   - name: onos_rsa
diff --git a/roles/cord-profile/tasks/main.yml b/roles/cord-profile/tasks/main.yml
index 5e68101..f2965af 100644
--- a/roles/cord-profile/tasks/main.yml
+++ b/roles/cord-profile/tasks/main.yml
@@ -128,6 +128,7 @@
     - Dockerfile.xos
     - xos-gui-extensions-onboard.yml
     - xos-gui-extensions.yml
+    - docker-compose.yml
 
 - name: Create profile specific templated TOSCA config files
   template:
diff --git a/roles/cord-profile/templates/docker-compose.yml.j2 b/roles/cord-profile/templates/docker-compose.yml.j2
new file mode 100644
index 0000000..4939307
--- /dev/null
+++ b/roles/cord-profile/templates/docker-compose.yml.j2
@@ -0,0 +1,243 @@
+version: '2'
+
+# XOS docker compose
+# generated by platform-install/roles/cord-profile
+
+networks:
+{% for network in xos_docker_networks %}
+  {{ network }}:
+    external: true
+{% endfor %}
+
+services:
+  xos_db:
+    image: {{ deploy_docker_registry }}xosproject/xos-postgres:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+      - {{ network }}
+{% endfor %}
+    expose:
+      - "5432"
+    restart: unless-stopped
+
+{% if use_redis %}
+  xos_redis:
+    image: {{ deploy_docker_registry }}redis:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+{% endif %}
+
+  xos-spa-gui:
+    image: {{ deploy_docker_registry }}xosproject/xos-gui:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    ports:
+      - "4000:4000"
+    links:
+      - xos-rest-gateway:xos-rest-gw
+      - xos_chameleon:xos-chameleon
+    depends_on:
+      - xos-rest-gateway
+      - xos_chameleon
+    volumes:
+      - {{ cord_profile_dir }}/style.config.js:/var/www/dist/style.config.js
+      - {{ cord_profile_dir }}/app.config.js:/var/www/dist/app.config.js
+    volumes_from:
+      - gui-extensions-store
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+  xos_chameleon:
+    image: {{ deploy_docker_registry }}xosproject/chameleon:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: python chameleon/chameleon/main.py -R 9101 -G xos-core:50055
+    ports:
+      - "9101:9101"
+    links:
+      - xos_core:xos-core
+    depends_on:
+      - xos_core
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+  gui-extensions-store:
+    image: {{ deploy_docker_registry }}node:argon
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: /bin/true
+    volumes:
+      - /var/www/dist/extensions
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+
+  xos-rest-gateway:
+    image: {{ deploy_docker_registry }}xosproject/xos-rest-gw:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: npm start -- --config gateway-config.yml
+    ports:
+      - "3000:3000"
+    links:
+      - xos_ui:xos
+{% if use_redis %}
+      - xos_redis:redis
+{% endif %}
+    depends_on:
+      - xos_ui
+{% if use_redis %}
+      - xos_redis
+{% endif %}
+    volumes:
+      - {{ cord_profile_dir }}/gateway-config.yml:/var/www/src/config/gateway-config.yml
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+  xos_ui:
+    image: {{ deploy_docker_registry }}xosproject/xos-ui:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: python /opt/xos/manage.py runserver 0.0.0.0:9000 --insecure --makemigrations
+    ports:
+      - "9000:9000"
+    links:
+      - xos_db:xos_db
+{% if use_redis %}
+      - xos_redis:redis
+{% endif %}
+    depends_on:
+      - xos_db
+{% if use_redis %}
+      - xos_redis
+{% endif %}
+    volumes:
+      - {{ cord_profile_dir }}/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro
+      - {{ cord_profile_dir }}:/opt/cord_profile:ro
+      - {{ cord_dir }}/orchestration/xos_libraries/ng-xos-lib:/opt/xos_libraries/ng-xos-lib:ro
+      - {{ cord_profile_dir }}/im_cert_chain.pem:/usr/local/share/ca-certificates/local_certs.crt:ro
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+  xos_core:
+    image: {{ deploy_docker_registry }}xosproject/xos-ui:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: bash -c "cd coreapi; bash ./start_coreapi.sh"
+    ports:
+      - "50051:50051"
+      - "50055:50055"
+    links:
+      - xos_db:xos_db
+{% if use_redis %}
+      - xos_redis:redis
+{% endif %}
+    depends_on:
+      - xos_db
+{% if use_redis %}
+      - xos_redis
+{% endif %}
+    volumes:
+      - {{ cord_profile_dir }}/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro
+      - {{ cord_profile_dir }}:/opt/cord_profile:ro
+      - {{ cord_dir }}/orchestration/xos_libraries/ng-xos-lib:/opt/xos_libraries/ng-xos-lib:ro
+      - {{ cord_profile_dir }}/im_cert_chain.pem:/usr/local/share/ca-certificates/local_certs.crt:ro
+      - /var/run/docker.sock:/var/run/docker.sock
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+{% for ext in enabled_gui_extensions %}
+  gui-extension-{{ ext.name }}:
+    image: {{ deploy_docker_registry }}xosproject/gui-extension-{{ ext.name }}:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+    command: npm run build
+    volumes_from:
+      - gui-extensions-store
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+
+{% endfor %}
+
+{% if not frontend_only %}
+{% for svc in xos_services %}
+{% if svc.synchronizer is defined and svc.synchronizer %}
+  {{ svc.name }}-synchronizer:
+    image: {{ deploy_docker_registry }}xosproject/{{ svc.name }}-synchronizer:{{ deploy_docker_tag }}
+    networks:
+{% for network in xos_docker_networks %}
+     - {{ network }}
+{% endfor %}
+{% if use_redis %}
+    links:
+      - xos_redis:redis
+    depends_on:
+      - xos_redis
+{% endif %}
+    volumes:
+      - {{ cord_profile_dir }}/node_key:/opt/cord_profile/node_key:ro
+      - {{ cord_dir }}/build/platform-install/credentials/xosadmin@opencord.org:/opt/xos/services/{{ svc.name }}/credentials/xosadmin@opencord.org:ro
+      - {{ cord_profile_dir }}/im_cert_chain.pem:/usr/local/share/ca-certificates/local_certs.crt:ro
+{% if svc.keypair is defined %}
+      - {{ cord_profile_dir }}/key_import/{{ svc.keypair }}:/opt/xos/services/{{ svc.name }}/keys/{{ svc.keypair }}:ro
+{% endif %}
+{% if svc.name == "openstack" %}
+      - {{ cord_profile_dir }}/images:/opt/xos/images:ro
+{% endif %}
+    logging:
+      driver: "json-file"
+      options:
+        max-size: "1000k"
+        max-file: "5"
+    restart: unless-stopped
+
+{% endif %}
+{% endfor %}
+{% endif %}
diff --git a/roles/teardown-profile/tasks/main.yml b/roles/teardown-profile/tasks/main.yml
index 362a625..4cfd552 100644
--- a/roles/teardown-profile/tasks/main.yml
+++ b/roles/teardown-profile/tasks/main.yml
@@ -6,16 +6,7 @@
 - name: Stop and remove XOS containers
   docker_service:
     project_name: "{{ cord_profile | regex_replace('\\W','') }}"
-    project_src: "{{ cord_profile_dir }}/onboarding-docker-compose/"
-    state: absent
-    remove_images: local
-  ignore_errors: yes
-
-- name: Stop and remove XOS bootstrap containers
-  docker_service:
-    project_name: "{{ cord_profile | regex_replace('\\W','') }}bs"
     project_src: "{{ cord_profile_dir }}"
-    files: "xos-bootstrap-docker-compose.yaml"
     state: absent
     remove_images: local
   ignore_errors: yes
diff --git a/roles/xos-config/tasks/main.yml b/roles/xos-config/tasks/main.yml
index 2e5f9cc..14b3d45 100644
--- a/roles/xos-config/tasks/main.yml
+++ b/roles/xos-config/tasks/main.yml
@@ -1,6 +1,14 @@
 ---
 # xos-config/tasks/main.yml
 
+- name: Bootstrap XOS database - create site, deployment, admin user
+  command: "python /opt/xos/tosca/run.py none /opt/cord_profile/{{ item }}"
+  with_items:
+    - "fixtures.yaml"
+    - "deployment.yaml"
+  tags:
+    - skip_ansible_lint # TOSCA loading should be idempotent
+
 - name: Configure XOS with profile specific TOSCA
   command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} /opt/cord_profile/{{ item }}"
   with_items: "{{ xos_tosca_config_templates }}"
diff --git a/roles/xos-core-build/defaults/main.yml b/roles/xos-core-build/defaults/main.yml
index 6805c14..e4776dd 100644
--- a/roles/xos-core-build/defaults/main.yml
+++ b/roles/xos-core-build/defaults/main.yml
@@ -8,3 +8,5 @@
 
 xos_libraries:
   - "ng-xos-lib"
+
+xos_services: []
diff --git a/roles/xos-core-build/tasks/main.yml b/roles/xos-core-build/tasks/main.yml
index 09ea5b9..1f7e046 100644
--- a/roles/xos-core-build/tasks/main.yml
+++ b/roles/xos-core-build/tasks/main.yml
@@ -49,6 +49,6 @@
     tag: "{{ build_docker_tag }}"
     dockerfile: "containers/xos/Dockerfile.UI"
     pull: False
-
+    force: yes
 
 
diff --git a/roles/xos-onboard-hosts/tasks/main.yml b/roles/xos-onboard-hosts/tasks/main.yml
index 5adf7d6..2b60f5a 100644
--- a/roles/xos-onboard-hosts/tasks/main.yml
+++ b/roles/xos-onboard-hosts/tasks/main.yml
@@ -4,7 +4,7 @@
 - name: Get the Docker container names for onboarded containers
   docker_service:
     project_name: "{{ cord_profile | regex_replace('\\W','') }}"
-    project_src: "{{ cord_profile_dir }}/onboarding-docker-compose/"
+    project_src: "{{ cord_profile_dir }}"
     recreate: never
   register: xos_onboard_out
 
diff --git a/roles/xos-ready/tasks/main.yml b/roles/xos-ready/tasks/main.yml
index eaf8c85..ba83ed5 100644
--- a/roles/xos-ready/tasks/main.yml
+++ b/roles/xos-ready/tasks/main.yml
@@ -5,5 +5,5 @@
   wait_for:
     host: localhost
     port: "{{ xos_ui_port }}"
-    timeout: 120
+    timeout: 180
 
diff --git a/roles/xos-up/defaults/main.yml b/roles/xos-up/defaults/main.yml
new file mode 100644
index 0000000..7804fa3
--- /dev/null
+++ b/roles/xos-up/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+# xos-service-onboard/defaults/main.yml
+
+cord_dir: "{{ ansible_user_dir + '/cord' }}"
+cord_profile_dir: "{{ ansible_user_dir + '/cord_profile' }}"
+
+xos_docker_networks:
+  - "xos"
diff --git a/roles/xos-up/tasks/main.yml b/roles/xos-up/tasks/main.yml
new file mode 100644
index 0000000..8e442b9
--- /dev/null
+++ b/roles/xos-up/tasks/main.yml
@@ -0,0 +1,12 @@
+---
+# xos-up/tasks/main.yml
+
+- name: Create docker networks
+  docker_network:
+    name: "{{ item }}"
+  with_items: "{{ xos_docker_networks }}"
+
+- name: Bring up XOS services
+  docker_service:
+    project_name: "{{ cord_profile | regex_replace('\\W','') }}"
+    project_src: "{{ cord_profile_dir }}"