From 132243183a7cffe6f05571ea48342df5ad9ef73e Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Thu, 27 Sep 2018 19:05:04 +0200 Subject: [PATCH] Add hide_create_volume to LAUNCH_INSTANCE_DEFAULTS This adds a new option named hide_create_volume to the LAUNCH_INSTANCE_DEFAULTS dict. With this option you can select if you want to hide the "Create New Volume" option to your users and have it rely on the default value that is provide with the create_volume option. This is currently the only way to make sure the end-users utilizing the web interface is forced to spawn a volume-backed instance until Nova supports Cinder as a images backend. Change-Id: I3a78593ada0d39cc7f1e30fb0a6300887b7b1a00 --- doc/source/configuration/settings.rst | 16 ++++++++++++++++ .../launch-instance-model.service.js | 4 ++++ .../launch-instance-model.service.spec.js | 19 ++++++++++++++++++- .../launch-instance/source/source.html | 2 +- ...s-hide-create-volume-774549bebb6e7c82.yaml | 7 +++++++ 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/instance-defaults-hide-create-volume-774549bebb6e7c82.yaml diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index d12c79143f..1a844f1cb1 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -1965,6 +1965,10 @@ LAUNCH_INSTANCE_DEFAULTS Added the ``create_volume`` option. +.. versionchanged:: 15.0.0(Stein) + + Added the ``hide_create_volume`` option. + Default: .. code-block:: python @@ -1972,6 +1976,7 @@ Default: { "config_drive": False, "create_volume": True, + "hide_create_volume": False, "disable_image": False, "disable_instance_snapshot": False, "disable_volume": False, @@ -2002,6 +2007,17 @@ Default: ``True`` This setting allows you to specify the default value for the option of creating a new volume in the workflow for image and instance snapshot sources. +hide_create_volume +################## + +.. versionadded:: 15.0.0(Stein) + +Default: ``False`` + +This setting allow your to hide the "Create New Volume" option and rely on the +default value you select with ``create_volume`` to be the most suitable for your +users. + disable_image ############# diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js index d4184059ac..8454389939 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js @@ -203,6 +203,7 @@ source: [], create_volume_default: true, // REQUIRED for JS logic + hide_create_volume: false, vol_create: false, // May be null vol_device_name: 'vda', @@ -297,6 +298,9 @@ // Append "_default" to distinguish from the 'vol_create' item model.newInstanceSpec.create_volume_default = defaults.create_volume; } + if ('hide_create_volume' in defaults) { + model.newInstanceSpec.hide_create_volume = defaults.hide_create_volume; + } } /** diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js index e663b107b0..0c7257ba5c 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js @@ -160,6 +160,7 @@ settings = { LAUNCH_INSTANCE_DEFAULTS: { create_volume: true, + hide_create_volume: false, config_drive: false, disable_image: false, disable_instance_snapshot: false, @@ -512,6 +513,22 @@ expect(model.newInstanceSpec.create_volume_default).toBe(false); }); + it('should default hide_create_volume to false if setting not provided', function() { + delete settings.LAUNCH_INSTANCE_DEFAULTS.hide_create_volume; + model.initialize(true); + scope.$apply(); + + expect(model.newInstanceSpec.hide_create_volume).toBe(false); + }); + + it('should default hide_create_volume to true based on setting', function() { + settings.LAUNCH_INSTANCE_DEFAULTS.hide_create_volume = true; + model.initialize(true); + scope.$apply(); + + expect(model.newInstanceSpec.hide_create_volume).toBe(true); + }); + it('should not set availability zone if the zone list is empty', function () { spyOn(novaApi, 'getAvailabilityZones').and.callFake(function () { var deferred = $q.defer(); @@ -825,7 +842,7 @@ // This is here to ensure that as people add/change items, they // don't forget to implement tests for them. it('has the right number of properties', function() { - expect(Object.keys(model.newInstanceSpec).length).toBe(22); + expect(Object.keys(model.newInstanceSpec).length).toBe(23); }); it('sets availability zone to null', function() { diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.html b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.html index 6b817451a3..6aa4c1d3f6 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.html +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.html @@ -24,7 +24,7 @@
+ model.allowCreateVolumeFromImage && !model.newInstanceSpec.hide_create_volume">

diff --git a/releasenotes/notes/instance-defaults-hide-create-volume-774549bebb6e7c82.yaml b/releasenotes/notes/instance-defaults-hide-create-volume-774549bebb6e7c82.yaml new file mode 100644 index 0000000000..9f31abd653 --- /dev/null +++ b/releasenotes/notes/instance-defaults-hide-create-volume-774549bebb6e7c82.yaml @@ -0,0 +1,7 @@ +--- +features: + - Added a new ``hide_create_volume`` setting under the + ``LAUNCH_INSTANCE_DEFAULTS`` dict. This allows you to hide the + "Create New Volume" option in the "Launch Instance" form and instead rely + on the default value you select with ``create_volume`` is the best suitable + option for your users.