Add config for default create volume option
This patch adds the ability to configure the default "create volume" value when launching an instance with Cinder enabled. Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com> Closes-Bug: 1678109 Change-Id: I272f7f1b20cc1276976c464a82d1776de92d17e7
This commit is contained in:
parent
3afb8f650b
commit
d734f482ec
@ -670,6 +670,7 @@ Default::
|
||||
"disable_instance_snapshot": False,
|
||||
"disable_volume": False,
|
||||
"disable_volume_snapshot": False,
|
||||
"create_volume": True,
|
||||
}
|
||||
|
||||
A dictionary of settings which can be used to provide the default values for
|
||||
@ -681,6 +682,10 @@ Drive property.
|
||||
The ``enable_scheduler_hints`` setting specifies whether or not Scheduler Hints
|
||||
can be provided when launching an instance.
|
||||
|
||||
The ``create_volume`` 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.
|
||||
|
||||
The ``disable_image`` setting disables Images as a valid boot source for launching
|
||||
instances. Image sources won't show up in the Launch Instance modal.
|
||||
|
||||
|
@ -200,6 +200,7 @@
|
||||
// REQUIRED for JS logic (image | snapshot | volume | volume_snapshot)
|
||||
source_type: null,
|
||||
source: [],
|
||||
create_volume_default: true,
|
||||
// REQUIRED for JS logic
|
||||
vol_create: false,
|
||||
// May be null
|
||||
@ -288,6 +289,10 @@
|
||||
if ('config_drive' in defaults) {
|
||||
model.newInstanceSpec.config_drive = defaults.config_drive;
|
||||
}
|
||||
if ('create_volume' in defaults) {
|
||||
// Append "_default" to distinguish from the 'vol_create' item
|
||||
model.newInstanceSpec.create_volume_default = defaults.create_volume;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,6 +158,7 @@
|
||||
beforeEach(function () {
|
||||
settings = {
|
||||
LAUNCH_INSTANCE_DEFAULTS: {
|
||||
create_volume: true,
|
||||
config_drive: false,
|
||||
disable_image: false,
|
||||
disable_instance_snapshot: false,
|
||||
@ -479,6 +480,22 @@
|
||||
expect(model.newInstanceSpec.config_drive).toBe(true);
|
||||
});
|
||||
|
||||
it('should default create_volume to true if setting not provided', function() {
|
||||
delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
|
||||
model.initialize(true);
|
||||
scope.$apply();
|
||||
|
||||
expect(model.newInstanceSpec.create_volume_default).toBe(true);
|
||||
});
|
||||
|
||||
it('should default create_volume to false based on setting', function() {
|
||||
settings.LAUNCH_INSTANCE_DEFAULTS.create_volume = false;
|
||||
model.initialize(true);
|
||||
scope.$apply();
|
||||
|
||||
expect(model.newInstanceSpec.create_volume_default).toBe(false);
|
||||
});
|
||||
|
||||
it('should not set availability zone if the zone list is empty', function () {
|
||||
spyOn(novaApi, 'getAvailabilityZones').and.callFake(function () {
|
||||
var deferred = $q.defer();
|
||||
@ -577,6 +594,7 @@
|
||||
});
|
||||
|
||||
it('should have proper allowedBootSources if specific settings missing', function() {
|
||||
delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
|
||||
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_image;
|
||||
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_instance_snapshot;
|
||||
delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_volume;
|
||||
@ -589,6 +607,7 @@
|
||||
expect(model.allowedBootSources).toContain(INSTANCE_SNAPSHOT);
|
||||
expect(model.allowedBootSources).toContain(VOLUME);
|
||||
expect(model.allowedBootSources).toContain(VOLUME_SNAPSHOT);
|
||||
expect(model.newInstanceSpec.create_volume_default).toBe(true);
|
||||
});
|
||||
|
||||
it('should have no images if disable_image is set to true', function() {
|
||||
@ -744,7 +763,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(20);
|
||||
expect(Object.keys(model.newInstanceSpec).length).toBe(21);
|
||||
});
|
||||
|
||||
it('sets availability zone to null', function() {
|
||||
@ -759,6 +778,10 @@
|
||||
expect(model.newInstanceSpec.config_drive).toBe(false);
|
||||
});
|
||||
|
||||
it('sets create volume to true', function() {
|
||||
expect(model.newInstanceSpec.create_volume_default).toBe(true);
|
||||
});
|
||||
|
||||
it('sets user data to an empty string', function() {
|
||||
expect(model.newInstanceSpec.user_data).toBe('');
|
||||
});
|
||||
|
@ -431,7 +431,8 @@
|
||||
ctrl.currentBootSource = selectedSource;
|
||||
if ((selectedSource === bootSourceTypes.IMAGE ||
|
||||
selectedSource === bootSourceTypes.INSTANCE_SNAPSHOT) && $scope.model.volumeBootable) {
|
||||
$scope.model.newInstanceSpec.vol_create = true;
|
||||
$scope.model.newInstanceSpec.vol_create =
|
||||
$scope.model.newInstanceSpec.create_volume_default;
|
||||
} else {
|
||||
$scope.model.newInstanceSpec.vol_create = false;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
scope.model = {
|
||||
allowedBootSources: [{type: 'image', label: 'Image'}],
|
||||
newInstanceSpec: { source: [], source_type: '' },
|
||||
newInstanceSpec: { source: [], source_type: '', create_volume_default: true },
|
||||
images: [ { id: 'image-1' }, { id: 'image-2' } ],
|
||||
imageSnapshots: [ { id: 'imageSnapshot-1' } ],
|
||||
volumes: [ { id: 'volume-1' }, { id: 'volume-2' } ],
|
||||
|
@ -257,6 +257,7 @@ OPENSTACK_KEYSTONE_BACKEND = {
|
||||
# 'disable_instance_snapshot': False,
|
||||
# 'disable_volume': False,
|
||||
# 'disable_volume_snapshot': False,
|
||||
# 'create_volume': True,
|
||||
#}
|
||||
|
||||
# The Xen Hypervisor has the ability to set the mount point for volumes
|
||||
|
5
releasenotes/notes/bug-1678109-4440ebe90908647d.yaml
Normal file
5
releasenotes/notes/bug-1678109-4440ebe90908647d.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Added a new ``create_volume`` setting under the
|
||||
``LAUNCH_INSTANCE_DEFAULTS`` dict. This allows you to set the default value
|
||||
of "Create Volume", when Cinder is available.
|
Loading…
Reference in New Issue
Block a user