From 68d3d8ba29242decfc7506e9e83eb25b4a7c943a Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Wed, 28 Dec 2016 22:34:28 +0800 Subject: [PATCH] Run nova-manage simple_cell_setup during deploying and upgrading Change-Id: I64dd52d909a884b2b9aea6f016d789d99caa3f17 Closes-Bug: #1652580 --- ansible/roles/nova/tasks/bootstrap.yml | 8 ++++- ansible/roles/nova/tasks/deploy.yml | 2 ++ .../roles/nova/tasks/simple_cell_setup.yml | 30 +++++++++++++++++++ ansible/roles/nova/tasks/upgrade.yml | 4 +++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/nova/tasks/simple_cell_setup.yml diff --git a/ansible/roles/nova/tasks/bootstrap.yml b/ansible/roles/nova/tasks/bootstrap.yml index adfd64a454..504aebc677 100644 --- a/ansible/roles/nova/tasks/bootstrap.yml +++ b/ansible/roles/nova/tasks/bootstrap.yml @@ -13,6 +13,7 @@ delegate_to: "{{ groups['nova-api'][0] }}" with_items: - "{{ nova_database_name }}" + - "{{ nova_database_name }}_cell0" - "{{ nova_api_database_name }}" - name: Creating Nova databases user and setting permissions @@ -23,7 +24,7 @@ login_port: "{{ database_port }}" login_user: "{{ database_user }}" login_password: "{{ database_password }}" - name: "{{ item.database_name }}" + name: "{{ item.database_username }}" password: "{{ item.database_password }}" host: "%" priv: "{{ item.database_name }}.*:ALL" @@ -31,8 +32,13 @@ register: database_user_create with_items: - database_name: "{{ nova_database_name }}" + database_username: "{{ nova_database_name }}" + database_password: "{{ nova_database_password }}" + - database_name: "{{ nova_database_name }}_cell0" + database_username: "{{ nova_database_name }}" database_password: "{{ nova_database_password }}" - database_name: "{{ nova_api_database_name }}" + database_username: "{{ nova_api_database_name }}" database_password: "{{ nova_api_database_password }}" run_once: True delegate_to: "{{ groups['nova-api'][0] }}" diff --git a/ansible/roles/nova/tasks/deploy.yml b/ansible/roles/nova/tasks/deploy.yml index 14bf9ac8c8..35e32efc51 100644 --- a/ansible/roles/nova/tasks/deploy.yml +++ b/ansible/roles/nova/tasks/deploy.yml @@ -31,3 +31,5 @@ - name: Flush handlers meta: flush_handlers + +- include: simple_cell_setup.yml diff --git a/ansible/roles/nova/tasks/simple_cell_setup.yml b/ansible/roles/nova/tasks/simple_cell_setup.yml new file mode 100644 index 0000000000..14d0112bde --- /dev/null +++ b/ansible/roles/nova/tasks/simple_cell_setup.yml @@ -0,0 +1,30 @@ +--- +- name: Waiting for nova-compute service up + command: > + docker exec kolla_toolbox openstack + --os-auth-url {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}/v3 + --os-identity-api-version 3 + --os-project-domain-name default + --os-tenant-name admin + --os-username admin + --os-password {{ keystone_admin_password }} + --os-user-domain-name default + compute service list -f json --service nova-compute + register: nova_compute_services + changed_when: false + run_once: True + delegate_to: "{{ groups['nova-api'][0] }}" + retries: 20 + delay: 10 + until: + - nova_compute_services | success + - nova_compute_services.stdout | from_json | length != 0 + +- name: Running nova simple cell setup + command: docker exec nova_api nova-manage cell_v2 simple_cell_setup + register: cell_setup + changed_when: + - cell_setup | success + - '"Cell0 is already setup" not in cell_setup.stdout' + run_once: True + delegate_to: "{{ groups['nova-api'][0] }}" diff --git a/ansible/roles/nova/tasks/upgrade.yml b/ansible/roles/nova/tasks/upgrade.yml index 1ee7056c8d..002fd8d194 100644 --- a/ansible/roles/nova/tasks/upgrade.yml +++ b/ansible/roles/nova/tasks/upgrade.yml @@ -6,6 +6,10 @@ # It should be removed later - include: bootstrap.yml +# TODO(Jeffrey4l): Since nova need setup nova cell in N->O, we need to call it. +# This should be removed later +- include: simple_cell_setup.yml + - include: bootstrap_service.yml - include: register.yml