[CORD-1556] Generating inital data and mounting on xos-core
Change-Id: Icdd1a596083f385b7af831aef0ce3f23ef732542
diff --git a/onboard-profile-playbook.yml b/onboard-profile-playbook.yml
index 2a8b597..844340b 100644
--- a/onboard-profile-playbook.yml
+++ b/onboard-profile-playbook.yml
@@ -20,10 +20,15 @@
- include: add-onboard-containers-playbook.yml
-- name: Check to see if XOS UI is ready, apply profile config
- hosts: xos_ui
+- name: Check XOS Ready
+ hosts: head
connection: docker
roles:
- xos-ready
+
+- name: Apply profile config
+ hosts: xos_ui
+ connection: docker
+ roles:
- xos-config
diff --git a/profile_manifests/mock-rcord.yml b/profile_manifests/mock-rcord.yml
index 8aba25f..861d16c 100644
--- a/profile_manifests/mock-rcord.yml
+++ b/profile_manifests/mock-rcord.yml
@@ -36,7 +36,6 @@
build_xos_base_image: True
xos_tosca_config_templates:
- - sample.yaml
- management-net.yaml
- mock-onos.yaml
- cord-services.yaml
@@ -103,3 +102,5 @@
subj: "/C=US/ST=California/L=Menlo Park/O=ON.Lab/OU=Test Deployment/CN=xos-core.{{ site_suffix }}"
altnames:
- "DNS:xos-core.{{ site_suffix }}"
+
+xos_images: []
\ No newline at end of file
diff --git a/roles/cord-profile/tasks/main.yml b/roles/cord-profile/tasks/main.yml
index 6c49108..a3c38ab 100644
--- a/roles/cord-profile/tasks/main.yml
+++ b/roles/cord-profile/tasks/main.yml
@@ -103,6 +103,7 @@
with_items:
- xos_config.yaml
- xos_config_synchronizer.yaml
+ - initial_data.yaml
- deployment.yaml
- xos.yaml
- gateway-config.yml
@@ -126,7 +127,6 @@
with_items: "{{ xos_other_templates }}"
- name: Create OpenStack config and TOSCA onboarding
- when: use_openstack
template:
src: "{{ item }}.j2"
dest: "{{ config_cord_profile_dir }}/{{ item }}"
diff --git a/roles/cord-profile/templates/deployment.yaml.j2 b/roles/cord-profile/templates/deployment.yaml.j2
index 1c7a41b..71f1355 100644
--- a/roles/cord-profile/templates/deployment.yaml.j2
+++ b/roles/cord-profile/templates/deployment.yaml.j2
@@ -45,18 +45,6 @@
{% endfor %}
-# Site
- {{ site_name }}:
- type: tosca.nodes.Site
- properties:
- display_name: {{ site_humanname }}
- site_url: http://{{ site_name }}.opencloud.us/
- hosts_nodes: true
- requirements:
- - deployment:
- node: {{ deployment_type }}
- relationship: tosca.relationships.MemberOfDeployment
-
# Attach the Tenant view to the deployment
Tenant:
type: tosca.nodes.DashboardView
@@ -67,40 +55,3 @@
- deployment:
node: {{ deployment_type }}
relationship: tosca.relationships.SupportsDeployment
-
-# XOS Users
-# Default admin user account
- {{ xos_admin_user }}:
- type: tosca.nodes.User
- properties:
- password: {{ xos_admin_pass }}
- firstname: {{ xos_admin_first }}
- lastname: {{ xos_admin_last }}
- is_admin: True
- requirements:
- - site:
- node: {{ site_name }}
- relationship: tosca.relationships.MemberOfSite
- - tenant_dashboard:
- node: Tenant
- relationship: tosca.relationships.UsesDashboard
-
-# All other users
-{% for user in xos_users %}
- {{ user.email }}:
- type: tosca.nodes.User
- properties:
- password: {{ user.password }}
- firstname: {{ user.first | default(user.email) }}
- lastname: {{ user.last | default("unknown") }}
- is_admin: {{ user.admin | default("false") }}
- requirements:
- - site:
- node: {{ site_name }}
- relationship: tosca.relationships.MemberOfSite
- - tenant_dashboard:
- node: Tenant
- relationship: tosca.relationships.UsesDashboard
-
-{% endfor %}
-
diff --git a/roles/cord-profile/templates/docker-compose.yml.j2 b/roles/cord-profile/templates/docker-compose.yml.j2
index 6ff8914..b3faeaf 100644
--- a/roles/cord-profile/templates/docker-compose.yml.j2
+++ b/roles/cord-profile/templates/docker-compose.yml.j2
@@ -231,7 +231,7 @@
{% for network in xos_docker_networks %}
- {{ network }}
{% endfor %}
- command: python /opt/xos/manage.py runserver 0.0.0.0:9000 --insecure --makemigrations
+ command: python /opt/xos/manage.py runserver 0.0.0.0:9000 --insecure
ports:
- "9000:9000"
links:
@@ -288,6 +288,7 @@
- {{ head_cord_profile_dir }}:/opt/cord_profile:ro
- {{ head_cord_dir }}/orchestration/xos_libraries/ng-xos-lib:/opt/xos_libraries/ng-xos-lib:ro
- {{ head_cord_profile_dir }}/im_cert_chain.pem:/usr/local/share/ca-certificates/local_certs.crt:ro
+ - {{ head_cord_profile_dir }}/initial_data.yaml:/opt/xos/core/migrations/initial_data.yaml:ro
- /var/run/docker.sock:/var/run/docker.sock
logging:
driver: "json-file"
diff --git a/roles/cord-profile/templates/initial_data.yaml.j2 b/roles/cord-profile/templates/initial_data.yaml.j2
new file mode 100644
index 0000000..4433c2b
--- /dev/null
+++ b/roles/cord-profile/templates/initial_data.yaml.j2
@@ -0,0 +1,52 @@
+{#
+Copyright 2017-present Open Networking Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+#}
+
+# Site
+- model: core.Site
+ fields:
+ name: {{ site_name }}
+ site_url: http://{{ site_name }}.opencloud.us/
+ hosts_nodes: true
+
+# User
+- model: core.User
+ fields:
+ email: {{ xos_admin_user }}
+ password: {{ xos_admin_pass }}
+ firstname: {{ xos_admin_first }}
+ lastname: {{ xos_admin_last }}
+ is_admin: True
+ relations:
+ site:
+ fields:
+ name: {{ site_name }}
+ model: core.Site
+
+# All other users
+{% for user in xos_users %}
+- model: core.User
+ fields:
+ email: {{ user.email }}
+ password: {{ user.password }}
+ firstname: {{ user.first | default(user.email) }}
+ lastname: {{ user.last | default("unknown") }}
+ is_admin: {{ user.admin | default("false") }}
+ relations:
+ site:
+ fields:
+ name: {{ site_name }}
+ model: core.Site
+{% endfor %}
\ No newline at end of file
diff --git a/roles/xos-config/tasks/main.yml b/roles/xos-config/tasks/main.yml
index 353e199..e75195f 100644
--- a/roles/xos-config/tasks/main.yml
+++ b/roles/xos-config/tasks/main.yml
@@ -17,8 +17,10 @@
---
# xos-config/tasks/main.yml
+# TODO move this to the TOSCA container
+
- name: Bootstrap XOS database - create site, deployment, admin user
- command: "python /opt/xos/tosca/run.py none /opt/cord_profile/{{ item }}"
+ command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} /opt/cord_profile/{{ item }}"
with_items:
- "fixtures.yaml"
- "deployment.yaml"
@@ -26,7 +28,6 @@
- skip_ansible_lint # TOSCA loading should be idempotent
- name: Configure XOS with OpenStack config
- when: use_openstack
command: "python /opt/xos/tosca/run.py {{ xos_admin_user }} /opt/cord_profile/{{ item }}"
with_items:
- openstack.yaml
diff --git a/roles/xos-ready/defaults/main.yml b/roles/xos-ready/defaults/main.yml
index edaecab..4c35845 100644
--- a/roles/xos-ready/defaults/main.yml
+++ b/roles/xos-ready/defaults/main.yml
@@ -18,3 +18,6 @@
# xos-ready/defaults/main.yml
xos_ui_port: 9000
+xos_grpc_insecure_port: 50055
+xos_grpc_secure_port: 50051
+xos_chameleon_port: 9101
diff --git a/roles/xos-ready/tasks/main.yml b/roles/xos-ready/tasks/main.yml
index 18fad1c..6ffc41e 100644
--- a/roles/xos-ready/tasks/main.yml
+++ b/roles/xos-ready/tasks/main.yml
@@ -17,9 +17,11 @@
---
# xos-ready/tasks/main.yml
-- name: Wait for XOS to be ready after service onboarding
- wait_for:
- host: localhost
- port: "{{ xos_ui_port }}"
- timeout: 300
-
+- name: Wait for XOS Chameleon to be ready after service onboarding #this means core is ready
+ shell: curl localhost:{{ xos_chameleon_port }}/xosapi/v1/modeldefs
+ register: result
+ until: result.stdout.find("items") != -1
+ retries: 10
+ delay: 20
+ tags:
+ - skip_ansible_lint # running a sub job