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
This commit is contained in:
Tobias Urdin 2018-09-27 19:05:04 +02:00
parent 6c2225bab8
commit 132243183a
5 changed files with 46 additions and 2 deletions

View File

@ -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
#############

View File

@ -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;
}
}
/**

View File

@ -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() {

View File

@ -24,7 +24,7 @@
<div ng-if="(model.newInstanceSpec.source_type.type === 'image' ||
model.newInstanceSpec.source_type.type === 'snapshot') &&
model.allowCreateVolumeFromImage">
model.allowCreateVolumeFromImage && !model.newInstanceSpec.hide_create_volume">
<div class="col-xs-6">
<div class="form-group">
<label for="vol-create" translate>Create New Volume</label><br/>

View File

@ -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.