From c9eaf9158beb55e8495865ef978b77291583039d Mon Sep 17 00:00:00 2001 From: guochao Date: Fri, 4 Aug 2017 17:15:57 +0800 Subject: [PATCH] Add vSphere support to nova_compute Implements compute part of the blueprint. Make virt_type of nova_compute configerable. Change-Id: I0f37e49e09c4f14a64797506007bb55a6f534f0f Partially-implements: blueprint kolla-ansible-support-vsphere Co-Authored-By: shaofeng cheng --- ansible/group_vars/all.yml | 12 +++++++----- ansible/roles/nova/defaults/main.yml | 7 ++++++- ansible/roles/nova/handlers/main.yml | 1 + ansible/roles/nova/tasks/config.yml | 15 +++++++++++++++ ansible/roles/nova/tasks/precheck.yml | 1 + .../roles/nova/templates/nova-compute.json.j2 | 6 ++++++ ansible/roles/nova/templates/nova.conf.j2 | 18 +++++++++++++++++- etc/kolla/globals.yml | 3 +++ 8 files changed, 56 insertions(+), 7 deletions(-) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 992eb4b2d9..cbe09abe04 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -551,7 +551,8 @@ computes_need_external_bridge: "{{ enable_neutron_dvr | bool or enable_neutron_p ####################### nova_backend_ceph: "{{ enable_ceph }}" nova_backend: "{{ 'rbd' if nova_backend_ceph | bool else 'default' }}" - +# Valid options are [ kvm, qemu, vmware ] +nova_compute_virt_type: "kvm" ####################### # Murano options @@ -622,10 +623,11 @@ ceph_cache_rule: "cache host firstn" ################################################ # VMware - OpenStack VMware support ################################################ -vmware_vcenter_host_ip: -vmware_vcenter_host_username: -vmware_vcenter_host_password: -vmware_vcenter_cluster_name: +vmware_vcenter_host_ip: "127.0.0.1" +vmware_vcenter_host_username: "username" +vmware_vcenter_host_password: "password" +vmware_vcenter_cluster_name: "cluster-1" +vmware_vcenter_insecure: "True" ###################### # OpenDaylight diff --git a/ansible/roles/nova/defaults/main.yml b/ansible/roles/nova/defaults/main.yml index f5d53aded3..5ddf4e5a35 100644 --- a/ansible/roles/nova/defaults/main.yml +++ b/ansible/roles/nova/defaults/main.yml @@ -5,7 +5,7 @@ nova_services: nova-libvirt: container_name: nova_libvirt group: compute - enabled: True + enabled: "{{ nova_compute_virt_type in ['kvm', 'qemu'] }}" image: "{{ nova_libvirt_image_full }}" pid_mode: "host" privileged: True @@ -249,3 +249,8 @@ nova_notification_topics: enabled: "{{ enable_designate | bool }}" nova_enabled_notification_topics: "{{ nova_notification_topics | selectattr('enabled', 'equalto', true) | list }}" + +#################### +# VMware +#################### +vmware_vcenter_datastore_regex: ".*" diff --git a/ansible/roles/nova/handlers/main.yml b/ansible/roles/nova/handlers/main.yml index a63d82107a..42699947e8 100644 --- a/ansible/roles/nova/handlers/main.yml +++ b/ansible/roles/nova/handlers/main.yml @@ -262,6 +262,7 @@ - config_json.changed | bool or nova_conf.changed | bool or policy_json.changed | bool + or vcenter_ca_file | bool or nova_compute_container.changed | bool - name: Restart nova-compute-ironic container diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml index eda07ccba8..2af2fded29 100644 --- a/ansible/roles/nova/tasks/config.yml +++ b/ansible/roles/nova/tasks/config.yml @@ -112,6 +112,21 @@ notify: - Restart nova-ssh container +- name: Copying VMware vCenter CA file + vars: + service: "{{ nova_services['nova-compute'] }}" + copy: + src: "{{ node_custom_config }}/vmware_ca" + dest: "{{ node_config_directory }}/nova-compute/vmware_ca" + register: vcenter_ca_file + when: + - nova_compute_virt_type == "vmware" + - not vmware_vcenter_insecure | bool + - inventory_hostname in groups[service.group] + - service.enabled | bool + notify: + - Restart nova-compute container + - name: Check if policies shall be overwritten local_action: stat path="{{ node_custom_config }}/nova/policy.json" run_once: True diff --git a/ansible/roles/nova/tasks/precheck.yml b/ansible/roles/nova/tasks/precheck.yml index 22af7ea465..1f98d408d1 100644 --- a/ansible/roles/nova/tasks/precheck.yml +++ b/ansible/roles/nova/tasks/precheck.yml @@ -121,5 +121,6 @@ register: result failed_when: result.stat.exists when: + - nova_compute_virt_type in ['kvm', 'qemu'] - container_facts['nova_libvirt'] is not defined - inventory_hostname in groups[nova_libvirt.group] diff --git a/ansible/roles/nova/templates/nova-compute.json.j2 b/ansible/roles/nova/templates/nova-compute.json.j2 index d37f071573..98a4f5ca99 100644 --- a/ansible/roles/nova/templates/nova-compute.json.j2 +++ b/ansible/roles/nova/templates/nova-compute.json.j2 @@ -19,6 +19,12 @@ "dest": "/etc/ceph/", "owner": "nova", "perm": "0700" + }{% endif %}{% if nova_compute_virt_type == "vmware" and not vmware_vcenter_insecure | bool %}, + { + "source": "{{ container_config_directory }}/vmware_ca", + "dest": "/etc/nova/vmware_ca", + "owner": "nova", + "perm": "0600" }{% endif %} ], "permissions": [ diff --git a/ansible/roles/nova/templates/nova.conf.j2 b/ansible/roles/nova/templates/nova.conf.j2 index 566cc8f4ca..d4b0ff391b 100644 --- a/ansible/roles/nova/templates/nova.conf.j2 +++ b/ansible/roles/nova/templates/nova.conf.j2 @@ -31,6 +31,8 @@ reserved_host_memory_mb = 0 {% elif enable_nova_fake | bool %} host = {{ ansible_hostname }}_{{ service_name }} compute_driver = fake.FakeDriver +{% elif nova_compute_virt_type == 'vmware' %} +compute_driver = vmwareapi.VMwareVCDriver {% else %} compute_driver = libvirt.LibvirtDriver {% endif %} @@ -159,7 +161,7 @@ memcache_security_strategy = ENCRYPT memcache_secret_key = {{ memcache_secret_key }} memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %} - +{% if nova_compute_virt_type in ['kvm', 'qemu'] %} [libvirt] connection_uri = "qemu+tcp://{{ api_interface_address }}/system" {% if enable_ceph | bool and nova_backend == "rbd" %} @@ -175,7 +177,21 @@ hw_disk_discard = {{ nova_hw_disk_discard }} {% if nova_backend == "rbd" and external_ceph_cephx_enabled | bool %} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif %} +virt_type = {{ nova_compute_virt_type }} +{% endif %} +{% if nova_compute_virt_type == "vmware" %} +[vmware] +host_ip = {{ vmware_vcenter_host_ip }} +host_username = {{ vmware_vcenter_host_username }} +host_password = {{ vmware_vcenter_host_password }} +cluster_name = {{ vmware_vcenter_cluster_name }} +datastore_regex = {{ vmware_vcenter_datastore_regex }} +insecure = {{ vmware_vcenter_insecure }} +{% if not vmware_vcenter_insecure | bool %} +ca_file = /etc/nova/vmware_ca +{% endif %} +{% endif %} [upgrade_levels] compute = auto diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index f0a4b65963..c84b598d52 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -306,6 +306,9 @@ kolla_internal_vip_address: "10.10.10.254" ######################### #nova_backend_ceph: "{{ enable_ceph }}" +# Valid options are [ qemu, kvm, vmware ] +#nova_compute_virt_type: "kvm" + ################### # Hyper-V options ###################