From f7dfb9755f5b89276ee9ab64c3d5a28488b625ee Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Wed, 18 Mar 2015 13:34:04 -0400 Subject: [PATCH] allow provision demo image to be user-selected This replaces CONFIG_PROVISION_CIRROS_URL with a set of configuration options that permit a deployer to specify the image url, image name, and username to use when connecting: CONFIG_PROVISION_IMAGE_URL CONFIG_PROVISION_IMAGE_NAME CONFIG_PROVISION_IMAGE_FORMAT CONFIG_PROVISION_IMAGE_SSH_USER Resolves: rhbz#982035 Change-Id: Id6db5ea551465a6dbf94890e2fc895d255c5bd8e --- docs/packstack.rst | 13 +++- packstack/plugins/provision_700.py | 60 ++++++++++++++++--- .../puppet/templates/provision_demo_glance.pp | 9 +-- .../puppet/templates/provision_tempest.pp | 7 ++- .../templates/provision_tempest_glance.pp | 9 +-- 5 files changed, 77 insertions(+), 21 deletions(-) diff --git a/docs/packstack.rst b/docs/packstack.rst index 4a3192bd8..b5b66e0bd 100644 --- a/docs/packstack.rst +++ b/docs/packstack.rst @@ -825,8 +825,17 @@ Provisioning demo config **CONFIG_PROVISION_DEMO_FLOATRANGE** CIDR network address for the floating IP subnet. -**CONFIG_PROVISION_CIRROS_URL** - A URL or local file location for the Cirros demo image (provided as an initial image in the Image service). +**CONFIG_PROVISION_IMAGE_URL** + A URL or local file location for an image to download and provision in Glance (defaults to a URL for a recent "cirros" image). + +**CONFIG_PROVISION_IMAGE_NAME** + The name to be assigned to the demo image in Glance (default "cirros"). + +**CONFIG_PROVISION_IMAGE_FORMAT** + Format for the demo image (default "qcow2"). + +**CONFIG_PROVISION_IMAGE_SSH_USER** + User to use when connecting to instances booted from the demo image. Provisioning tempest config --------------------------- diff --git a/packstack/plugins/provision_700.py b/packstack/plugins/provision_700.py index cd93bb5a5..774f60dae 100644 --- a/packstack/plugins/provision_700.py +++ b/packstack/plugins/provision_700.py @@ -29,9 +29,12 @@ from packstack.modules.ospluginutils import getManifestTemplate PLUGIN_NAME = "OS-Provision" PLUGIN_NAME_COLORED = utils.color_text(PLUGIN_NAME, 'blue') -DEMO_CIRRUS_URL = ( +DEMO_IMAGE_NAME = 'cirros' +DEMO_IMAGE_URL = ( 'http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img' ) +DEMO_IMAGE_SSH_USER = 'cirros' +DEMO_IMAGE_FORMAT = 'qcow2' def initConfig(controller): @@ -87,17 +90,58 @@ def initConfig(controller): "NEED_CONFIRM": False, "CONDITION": False}, - {"CMD_OPTION": "provision-cirros-url", - "USAGE": "A URL or local file location for the Cirros demo image " - "used for Glance", - "PROMPT": "Enter the URL or local file location for the Cirros " - "image", + {"CMD_OPTION": "provision-image-name", + "USAGE": "A named to be used for the demo image in Glance", + "PROMPT": "Enter the name to be assigned to the demo image", "OPTION_LIST": False, "VALIDATORS": [validators.validate_not_empty], - "DEFAULT_VALUE": DEMO_CIRRUS_URL, + "DEFAULT_VALUE": DEMO_IMAGE_NAME, "MASK_INPUT": False, "LOOSE_VALIDATION": True, - "CONF_NAME": "CONFIG_PROVISION_CIRROS_URL", + "CONF_NAME": "CONFIG_PROVISION_IMAGE_NAME", + "USE_DEFAULT": False, + "NEED_CONFIRM": False, + "CONDITION": False}, + + {"CMD_OPTION": "provision-image-url", + "USAGE": ("A URL or local file location for an image " + "to be loaded into Glance"), + "PROMPT": ("Enter the location of an image to be loaded " + "into Glance"), + "OPTION_LIST": False, + "VALIDATORS": [validators.validate_not_empty], + "DEFAULT_VALUE": DEMO_IMAGE_URL, + "MASK_INPUT": False, + "LOOSE_VALIDATION": True, + "CONF_NAME": "CONFIG_PROVISION_IMAGE_URL", + "USE_DEFAULT": False, + "NEED_CONFIRM": False, + "CONDITION": False}, + + {"CMD_OPTION": "provision-image-format", + "USAGE": ("Disk format (qcow2, raw, etc) of demo image"), + "PROMPT": ("Enter the format of the demo image"), + "OPTION_LIST": False, + "VALIDATORS": [validators.validate_not_empty], + "DEFAULT_VALUE": DEMO_IMAGE_FORMAT, + "MASK_INPUT": False, + "LOOSE_VALIDATION": True, + "CONF_NAME": "CONFIG_PROVISION_IMAGE_FORMAT", + "USE_DEFAULT": False, + "NEED_CONFIRM": False, + "CONDITION": False}, + + {"CMD_OPTION": "provision-image-ssh-user", + "USAGE": ("Name of a user to use when connecting via ssh to " + "instances booted from the demo image"), + "PROMPT": ("Enter the name of a user to use when connecting " + "to the demo image via ssh"), + "OPTION_LIST": False, + "VALIDATORS": [validators.validate_not_empty], + "DEFAULT_VALUE": DEMO_IMAGE_SSH_USER, + "MASK_INPUT": False, + "LOOSE_VALIDATION": True, + "CONF_NAME": "CONFIG_PROVISION_IMAGE_SSH_USER", "USE_DEFAULT": False, "NEED_CONFIRM": False, "CONDITION": False}, diff --git a/packstack/puppet/templates/provision_demo_glance.pp b/packstack/puppet/templates/provision_demo_glance.pp index e9f7fe583..0e6222913 100644 --- a/packstack/puppet/templates/provision_demo_glance.pp +++ b/packstack/puppet/templates/provision_demo_glance.pp @@ -1,14 +1,15 @@ ## Images ## Glance - $image_name = 'cirros' - $image_source = hiera('CONFIG_PROVISION_CIRROS_URL') - $image_ssh_user = 'cirros' + $image_name = hiera('CONFIG_PROVISION_IMAGE_NAME') + $image_source = hiera('CONFIG_PROVISION_IMAGE_URL') + $image_ssh_user = hiera('CONFIG_PROVISION_IMAGE_SSH_USER') + $image_format = hiera('CONFIG_PROVISION_IMAGE_FORMAT') glance_image { $image_name: ensure => present, is_public => 'yes', container_format => 'bare', - disk_format => 'qcow2', + disk_format => $image_format, source => $image_source, } diff --git a/packstack/puppet/templates/provision_tempest.pp b/packstack/puppet/templates/provision_tempest.pp index 8bcb3dafb..79adfd438 100644 --- a/packstack/puppet/templates/provision_tempest.pp +++ b/packstack/puppet/templates/provision_tempest.pp @@ -20,9 +20,10 @@ if $provision_tempest_user != '' { $admin_tenant_name = 'admin' ## Glance - $image_name = 'cirros' - $image_source = hiera('CONFIG_PROVISION_CIRROS_URL') - $image_ssh_user = 'cirros' + $image_name = hiera('CONFIG_PROVISION_IMAGE_NAME') + $image_source = hiera('CONFIG_PROVISION_IMAGE_URL') + $image_ssh_user = hiera('CONFIG_PROVISION_IMAGE_SSH_USER') + $image_format = hiera('CONFIG_PROVISION_IMAGE_FORMAT') ## Neutron $public_network_name = 'public' diff --git a/packstack/puppet/templates/provision_tempest_glance.pp b/packstack/puppet/templates/provision_tempest_glance.pp index a4b83aaad..e5ae5981b 100644 --- a/packstack/puppet/templates/provision_tempest_glance.pp +++ b/packstack/puppet/templates/provision_tempest_glance.pp @@ -1,8 +1,9 @@ ## Glance - $image_name = 'cirros' - $image_source = hiera('CONFIG_PROVISION_CIRROS_URL') - $image_ssh_user = 'cirros' + $image_name = hiera('CONFIG_PROVISION_IMAGE_NAME') + $image_source = hiera('CONFIG_PROVISION_IMAGE_URL') + $image_ssh_user = hiera('CONFIG_PROVISION_IMAGE_SSH_USER') + $image_format = hiera('CONFIG_PROVISION_IMAGE_FORMAT') ## Tempest @@ -15,7 +16,7 @@ ensure => present, is_public => 'yes', container_format => 'bare', - disk_format => 'qcow2', + disk_format => $image_format, source => $image_source, }