From f583d96659bb8f9b0258fdb90b0b291ed1c43a4b Mon Sep 17 00:00:00 2001 From: "Matthew J. Black" Date: Fri, 6 Oct 2017 08:40:46 -0400 Subject: [PATCH] Add parameter to configure instance defaults New parameter accepts a hash value to configure the LAUNCH_INSTANCE_DEFAULTS options in horizon configuration. Closes-Bug: #1721774 Change-Id: I778b3dc076d611d40205edbe0982141a815e1830 --- manifests/init.pp | 39 +++++++++++++++++++ ...fault_config_options-123cc41099d5e098.yaml | 3 ++ spec/classes/horizon_init_spec.rb | 8 ++++ templates/local_settings.py.erb | 8 ++++ 4 files changed, 58 insertions(+) create mode 100644 releasenotes/notes/added_instance_default_config_options-123cc41099d5e098.yaml diff --git a/manifests/init.pp b/manifests/init.pp index f47b30b5..f9afb534 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -141,6 +141,30 @@ # profiles to enable. Defaults to 'None', other options include # 'cisco'. # +# [*instance_options*] +# (optional) A hash of parameters to enable or disable instance options +# when using the launch instance options under Compute Instances tab. +# These options include: +# 'config_drive': Boolean to set default value of config drive options. +# A value of 'True' to have a check in the checkbox or 'False' to have it +# unchecked. +# Defaults to True. +# 'create_volume': Boolean to set 'Create Volume' to 'Yes' or 'No' on source +# options. Values are True (Yes) or False (No). +# Defaults to True. +# 'disable_image': Boolean to not show 'Image' as a boot source option. +# Defaults to False. +# 'disable_instance_snapshot': Boolean to not show 'Instance Snapshot' as a +# boot source option. +# Defaults to False. +# 'disable_volume': Boolean to not show 'Volume' as a boot source option. +# Defaults to False. +# 'disable_volume_snapshot': Boolean to not show 'Volume Snapshot' as a +# boot source option. +# Defaults to False. +# 'enable_scheduler_hints': Boolean to allow scheduler hints to be provided. +# Defaults to True. +# # [*configure_apache*] # (optional) Configure Apache for Horizon. (Defaults to true) # @@ -440,6 +464,7 @@ class horizon( $cinder_options = {}, $keystone_options = {}, $neutron_options = {}, + $instance_options = {}, $file_upload_temp_dir = '/tmp', $policy_files_path = undef, $policy_files = undef, @@ -540,12 +565,26 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive 'profile_support' => 'None', } + # Default options for the LAUNCH_INSTANCE_DEFAULTS section. These will + # be merged with user-provided options when the local_settings.py.erb + # template is interpolated. + $instance_defaults = { + 'config_drive' => false, + 'create_volume' => true, + 'disable_image' => false, + 'disable_instance_snapshot' => false, + 'disable_volume' => false, + 'disable_volume_snapshot' => false, + 'enable_scheduler_hints' => true, + } + Service <| title == 'memcached' |> -> Class['horizon'] $hypervisor_options_real = merge($hypervisor_defaults,$hypervisor_options) $cinder_options_real = merge($cinder_defaults,$cinder_options) $keystone_options_real = merge($keystone_defaults, $keystone_options) $neutron_options_real = merge($neutron_defaults,$neutron_options) + $instance_options_real = merge($instance_defaults,$instance_options) validate_hash($api_versions) validate_re($password_autocomplete, ['^on$', '^off$']) validate_re($images_panel, ['^legacy$', '^angular$']) diff --git a/releasenotes/notes/added_instance_default_config_options-123cc41099d5e098.yaml b/releasenotes/notes/added_instance_default_config_options-123cc41099d5e098.yaml new file mode 100644 index 00000000..cc737373 --- /dev/null +++ b/releasenotes/notes/added_instance_default_config_options-123cc41099d5e098.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added parameter to horizon class to allow configuring LAUNCH_INSTANCE_DEFAULTS. diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 59b49e08..e5d117b2 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -115,6 +115,7 @@ describe 'horizon' do :neutron_options => {'enable_lb' => true, 'enable_firewall' => true, 'enable_quotas' => false, 'enable_security_group' => false, 'enable_vpn' => true, 'enable_distributed_router' => false, 'enable_ha_router' => false, 'profile_support' => 'cisco', 'supported_provider_types' => ['flat', 'vxlan'], 'supported_vnic_types' => ['*'], 'default_ipv4_subnet_pool_label' => 'None', }, + :instance_options => {'disable_image' => true, 'disable_instance_snapshot' => true, 'disable_volume' => true, 'disable_volume_snapshot' => true, 'create_volume' => false }, :file_upload_temp_dir => '/var/spool/horizon', :secure_cookies => true, :api_versions => {'identity' => 2.0}, @@ -181,6 +182,13 @@ describe 'horizon' do 'OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True', 'CREATE_IMAGE_DEFAULTS = {', " 'image_visibility': 'private',", + " 'config_drive': False,", + " 'create_volume': False,", + " 'disable_image': True,", + " 'disable_instance_snapshot': True,", + " 'disable_volume': True,", + " 'disable_volume_snapshot': True,", + " 'enable_scheduler_hints': True,", 'OPENSTACK_ENDPOINT_TYPE = "internalURL"', 'SECONDARY_ENDPOINT_TYPE = "ANY-VALUE"', 'API_RESULT_LIMIT = 4682', diff --git a/templates/local_settings.py.erb b/templates/local_settings.py.erb index 7ec10af8..c025c16f 100644 --- a/templates/local_settings.py.erb +++ b/templates/local_settings.py.erb @@ -388,6 +388,14 @@ OPENSTACK_CINDER_FEATURES = { } <%-end-%> +<%- if ! (@instance_options_real.empty?) -%> +LAUNCH_INSTANCE_DEFAULTS = { +<%- @instance_options_real.sort.each do |opt_name,opt_val| -%> + '<%= opt_name -%>': <%= opt_val.to_s.capitalize -%>, +<%-end-%> +} +<%-end-%> + # The OPENSTACK_NEUTRON_NETWORK settings can be used to enable optional # services provided by neutron. Options currently available are load # balancer service, security groups, quotas, VPN service.