Allow to set default instance boot source

This introduces a new config option `DEFAULT_BOOT_SOURCE` to allow
operators to configure a default instance boot source.

Change-Id: Ia9b0d1d24ae69958b6606b9a645bd54f70b3aacc
Implements: blueprint default-instance-boot-source
This commit is contained in:
Ivan Kolodyazhny 2020-02-07 12:55:50 +02:00
parent bb959361b3
commit 3e7bc83c4b
7 changed files with 51 additions and 16 deletions

View File

@ -2052,6 +2052,20 @@ This setting specifies the type of in-browser console used to access the VMs.
Valid values are ``"AUTO"``, ``"VNC"``, ``"SPICE"``, ``"RDP"``,
``"SERIAL"``, ``"MKS"``, and ``None``.
DEFAULT_BOOT_SOURCE
~~~~~~~~~~~~~~~~~~~
.. versionadded:: 18.1.0(Ussuri)
Default: ``image``
A default instance boot source. Allowed values are:
* ``image`` - boot instance from image (default option)
* ``snapshot`` - boot instance from instance snapshot
* ``volume`` - boot instance from volume
* ``volume_snapshot`` - boot instance from volume snapshot
INSTANCE_LOG_LENGTH
~~~~~~~~~~~~~~~~~~~

View File

@ -247,6 +247,10 @@
model.allowedBootSources.length = 0;
var launchInstanceDefaults = settings.getSetting('LAUNCH_INSTANCE_DEFAULTS');
settings.getSetting('DEFAULT_BOOT_SOURCE').then(
function (response) {
model.defaultBootSource = response;
});
promise = $q.all([
novaAPI.getAvailabilityZones().then(onGetAvailabilityZones)
@ -726,10 +730,13 @@
function addAllowedBootSource(rawTypes, type, label) {
if (rawTypes) {
var selected = model.defaultBootSource === type;
model.allowedBootSources.push({
type: type,
label: label
label: label,
selected: selected
});
model.allowedBootSources.sort(function(a, b) {
return a.type > b.type;
});

View File

@ -170,12 +170,13 @@
disable_instance_snapshot: false,
disable_volume: false,
disable_volume_snapshot: false
}
},
DEFAULT_BOOT_SOURCE: 'image'
};
IMAGE = {type: 'image', label: 'Image'};
VOLUME = {type: 'volume', label: 'Volume'};
VOLUME_SNAPSHOT = {type: 'volume_snapshot', label: 'Volume Snapshot'};
INSTANCE_SNAPSHOT = {type: 'snapshot', label: 'Instance Snapshot'};
IMAGE = {type: 'image', label: 'Image', selected: true};
VOLUME = {type: 'volume', label: 'Volume', selected: false};
VOLUME_SNAPSHOT = {type: 'volume_snapshot', label: 'Volume Snapshot', selected: false};
INSTANCE_SNAPSHOT = {type: 'snapshot', label: 'Instance Snapshot', selected: false};
});
$provide.value('horizon.app.core.openstack-service-api.nova', novaApi);

View File

@ -409,8 +409,8 @@
);
// When the allowedboot list changes, change the source_type
// and update the table for the new source selection. Only done
// with the first item for the list
// and update the table for the new source selection. The devault value is
// set by the DEFAULT_BOOT_SOURCE config option.
// The boot source is changed only if the selected value is not included
// in the updated list (newValue)
var allowedBootSourcesWatcher = $scope.$watchCollection(
@ -419,13 +419,14 @@
},
function changeBootSource(newValue) {
if (angular.isArray(newValue) && newValue.length > 0 ) {
if (!$scope.model.newInstanceSpec.source_type ||
newValue.filter(function(value) {
return value.type === $scope.model.newInstanceSpec.source_type.type;
}).length === 0) {
updateBootSourceSelection(newValue[0].type);
$scope.model.newInstanceSpec.source_type = newValue[0];
var opt = newValue[0];
for (var index = 0; index < newValue.length; index++) {
if (newValue[index].selected) {
opt = newValue[index];
}
}
updateBootSourceSelection(opt.type);
$scope.model.newInstanceSpec.source_type = opt;
}
}
);

View File

@ -134,8 +134,10 @@
expect(ctrl.currentBootSource).toBe('snapshot');
// Change the allowed boot sources
scope.model.allowedBootSources = [{type: 'image', label: 'Image'},
{type: 'snapshot', label: 'Snapshot'}];
scope.model.allowedBootSources = [
{type: 'image', label: 'Image', selected: false},
{type: 'snapshot', label: 'Snapshot', selected: true}
];
scope.$apply();

View File

@ -213,6 +213,10 @@ HORIZON_IMAGES_UPLOAD_MODE = 'legacy'
# configuration and policies allow setting locations.
IMAGES_ALLOW_LOCATION = False
# A default instance boot source. Allowed values are: "image", "snapshot",
# "volume" and "volume_snapshot"
DEFAULT_BOOT_SOURCE = "image"
# The IMAGE_CUSTOM_PROPERTY_TITLES settings is used to customize the titles for
# image custom property attributes that appear on image detail pages.
IMAGE_CUSTOM_PROPERTY_TITLES = {
@ -522,6 +526,7 @@ ANGULAR_FEATURES = {
# See: https://wiki.openstack.org/wiki/Horizon/RESTAPI
REST_API_REQUIRED_SETTINGS = [
'CREATE_IMAGE_DEFAULTS',
'DEFAULT_BOOT_SOURCE'
'ENFORCE_PASSWORD_CHECK'
'LAUNCH_INSTANCE_DEFAULTS',
'OPENSTACK_HYPERVISOR_FEATURES',

View File

@ -0,0 +1,5 @@
---
features:
- |
Introduced a new ``DEFAULT_BOOT_SOURCE`` config option to allow
operators to configure a default instance boot source.