From 4d55b7592d69196fa892dd354ef881828ed77155 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Thu, 17 Aug 2017 09:59:38 -0500 Subject: [PATCH] Add boot-from-volume support In some clouds ephemeral storage is much slower than volume storage, so we want to be able to use volume storage for the performance- sensitive instances. This change adds new environments to enable that and updates build-nodes-json to handle the case where there is no image associated with an instance. --- doc/source/deploy/environment-index.rst | 9 +++ environments/boot-from-volume.yaml | 22 ++++++ .../build_nodes_json.py | 21 +++--- sample-env-generator/environments.yaml | 16 ++++ templates/undercloud-volume.yaml | 75 +++++++++++++++++++ .../virtual-baremetal-servers-volume.yaml | 70 +++++++++++++++++ 6 files changed, 204 insertions(+), 9 deletions(-) create mode 100644 environments/boot-from-volume.yaml create mode 100644 templates/undercloud-volume.yaml create mode 100644 templates/virtual-baremetal-servers-volume.yaml diff --git a/doc/source/deploy/environment-index.rst b/doc/source/deploy/environment-index.rst index a990994..de50abb 100644 --- a/doc/source/deploy/environment-index.rst +++ b/doc/source/deploy/environment-index.rst @@ -61,6 +61,15 @@ Base Configuration Options **Description:** Basic configuration options needed for all OVB environments +Boot Undercloud and Baremetal Instances from Volume +--------------------------------------------------- + +**File:** environments/boot-from-volume.yaml + +**Description:** Boot the undercloud and baremetal instances from Cinder volumes instead of +ephemeral storage. + + Create a Private Network ------------------------ diff --git a/environments/boot-from-volume.yaml b/environments/boot-from-volume.yaml new file mode 100644 index 0000000..6d65bb3 --- /dev/null +++ b/environments/boot-from-volume.yaml @@ -0,0 +1,22 @@ +# ******************************************************************* +# This file was created automatically by the sample environment +# generator. Developers should use `tox -e genconfig` to update it. +# Users are recommended to make changes to a copy of the file instead +# of the original, if any customizations are needed. +# ******************************************************************* +# title: Boot Undercloud and Baremetal Instances from Volume +# description: | +# Boot the undercloud and baremetal instances from Cinder volumes instead of +# ephemeral storage. +parameter_defaults: + # The size of the baremetal instance volumes + # Type: number + baremetal_volume_size: 41 + + # The size of the volume for the undercloud instance + # Type: number + undercloud_volume_size: 50 + +resource_registry: + OS::OVB::ServerPair: ../templates/virtual-baremetal-servers-volume.yaml + OS::OVB::UndercloudEnvironment: ../templates/undercloud-volume.yaml diff --git a/openstack_virtual_baremetal/build_nodes_json.py b/openstack_virtual_baremetal/build_nodes_json.py index ba8b9a7..6c3e8da 100755 --- a/openstack_virtual_baremetal/build_nodes_json.py +++ b/openstack_virtual_baremetal/build_nodes_json.py @@ -148,16 +148,19 @@ def _build_nodes(nova, glance, bmc_ports, bm_ports, provision_net, # If a node has uefi firmware ironic needs to be aware of this, in nova # this is set using a image property called "hw_firmware_type" - if not cache.get(baremetal.image['id']): - cache[baremetal.image['id']] = glance.images.get(baremetal.image['id']) - image = cache.get(baremetal.image['id']) - if image.get('hw_firmware_type') == 'uefi': - node['capabilities'] += ",boot_mode:uefi" + # NOTE(bnemec): Boot from volume does not have an image associated with + # the instance so we can't do this. + if baremetal.image: + if not cache.get(baremetal.image['id']): + cache[baremetal.image['id']] = glance.images.get(baremetal.image['id']) + image = cache.get(baremetal.image['id']) + if image.get('hw_firmware_type') == 'uefi': + node['capabilities'] += ",boot_mode:uefi" - bm_name_end = baremetal.name[len(baremetal_base):] - if '-' in bm_name_end: - profile = bm_name_end[1:].split('_')[0] - node['capabilities'] += ',profile:%s' % profile + bm_name_end = baremetal.name[len(baremetal_base):] + if '-' in bm_name_end: + profile = bm_name_end[1:].split('_')[0] + node['capabilities'] += ',profile:%s' % profile nodes.append(node) diff --git a/sample-env-generator/environments.yaml b/sample-env-generator/environments.yaml index 8851ce0..3b662c8 100644 --- a/sample-env-generator/environments.yaml +++ b/sample-env-generator/environments.yaml @@ -143,3 +143,19 @@ environments: - undercloud_floating_ip_id resource_registry: OS::OVB::UndercloudFloating: ../templates/undercloud-floating-existing.yaml + - + name: boot-from-volume + title: Boot Undercloud and Baremetal Instances from Volume + description: | + Boot the undercloud and baremetal instances from Cinder volumes instead of + ephemeral storage. + files: + templates/undercloud-volume.yaml: + parameters: + - undercloud_volume_size + templates/virtual-baremetal-servers-volume.yaml: + parameters: + - baremetal_volume_size + resource_registry: + OS::OVB::UndercloudEnvironment: ../templates/undercloud-volume.yaml + OS::OVB::ServerPair: ../templates/virtual-baremetal-servers-volume.yaml diff --git a/templates/undercloud-volume.yaml b/templates/undercloud-volume.yaml new file mode 100644 index 0000000..32e11e1 --- /dev/null +++ b/templates/undercloud-volume.yaml @@ -0,0 +1,75 @@ +heat_template_version: 2015-04-30 + +parameters: + undercloud_flavor: + type: string + undercloud_image: + type: string + key_name: + type: string + undercloud_name: + type: string + undercloud_user_data_format: + type: string + undercloud_user_data: + type: string + undercloud_volume_size: + type: number + default: 50 + description: The size of the volume for the undercloud instance + private_net: + type: string + provision_net: + type: string + public_net: + type: string + external_net: + type: string + +resources: + undercloud_ports: + type: OS::OVB::UndercloudPorts + properties: + undercloud_name: {get_param: undercloud_name} + private_net: {get_param: private_net} + provision_net: {get_param: provision_net} + public_net: {get_param: public_net} + + undercloud_volume: + type: OS::Cinder::Volume + properties: + name: {get_param: undercloud_name} + image: {get_param: undercloud_image} + size: {get_param: undercloud_volume_size} + + undercloud_server: + type: OS::Nova::Server + depends_on: undercloud_volume + properties: + flavor: {get_param: undercloud_flavor} + key_name: {get_param: key_name} + networks: {get_attr: [undercloud_ports, ports]} + name: {get_param: undercloud_name} + user_data_format: {get_param: undercloud_user_data_format} + user_data: {get_param: undercloud_user_data} + block_device_mapping: + - device_name: vda + volume_id: {get_resource: undercloud_volume} + + undercloud_floating_ip: + type: OS::OVB::UndercloudFloating + properties: + external_net: {get_param: external_net} + undercloud_port: + get_attr: + - undercloud_server + - addresses + - {get_param: private_net} + - 0 + - port + +outputs: + undercloud_host_floating_ip: + description: "floating ip of the undercloud instance" + value: + get_attr: [undercloud_floating_ip, undercloud_host] diff --git a/templates/virtual-baremetal-servers-volume.yaml b/templates/virtual-baremetal-servers-volume.yaml new file mode 100644 index 0000000..7ce29d0 --- /dev/null +++ b/templates/virtual-baremetal-servers-volume.yaml @@ -0,0 +1,70 @@ +heat_template_version: 2014-10-16 + +parameters: + + baremetal_flavor: + type: string + + baremetal_image: + type: string + + baremetal_volume_size: + type: number + default: 41 + description: The size of the baremetal instance volumes + + key_name: + type: string + + baremetal_prefix: + type: string + + provision_net: + type: string + + public_net: + type: string + + suffix: + type: string + +resources: + + baremetal_ports: + type: OS::OVB::BaremetalPorts + properties: + suffix: {get_param: suffix} + baremetal_prefix: {get_param: baremetal_prefix} + provision_net: {get_param: provision_net} + public_net: {get_param: public_net} + + baremetal_volume: + type: OS::Cinder::Volume + properties: + name: + list_join: + - '' + - - {get_param: baremetal_prefix} + - {get_param: suffix} + image: {get_param: baremetal_image} + size: {get_param: baremetal_volume_size} + + baremetal_server: + type: OS::Nova::Server + properties: + flavor: {get_param: baremetal_flavor} + config_drive: false + key_name: {get_param: key_name} + networks: {get_attr: [baremetal_ports, ports]} + block_device_mapping: + - device_name: vda + volume_id: {get_resource: baremetal_volume} + name: + list_join: + - '' + - - {get_param: baremetal_prefix} + - {get_param: suffix} + +outputs: + bmc_nic: + value: {port: {get_resource: bmc_port}}