Skip to content

Commit

Permalink
Add hide_create_volume to LAUNCH_INSTANCE_DEFAULTS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tobias-urdin committed Sep 28, 2018
1 parent 6c2225b commit 1322431
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
16 changes: 16 additions & 0 deletions doc/source/configuration/settings.rst
Expand Up @@ -1965,13 +1965,18 @@ LAUNCH_INSTANCE_DEFAULTS

Added the ``create_volume`` option.

.. versionchanged:: 15.0.0(Stein)

Added the ``hide_create_volume`` option.

Default:

.. code-block:: python
{
"config_drive": False,
"create_volume": True,
"hide_create_volume": False,
"disable_image": False,
"disable_instance_snapshot": False,
"disable_volume": False,
Expand Down Expand Up @@ -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
#############

Expand Down
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -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/>
Expand Down
@@ -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.

0 comments on commit 1322431

Please sign in to comment.