diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index afc537e004..bf3a215399 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -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 ~~~~~~~~~~~~~~~~~~~ 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 4bf8dd70df..337558427a 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 @@ -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; }); 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 f922c46258..b165413afd 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 @@ -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); diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js index 186a2c2136..3975190b87 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js @@ -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; } } ); diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js index 6bdfb98af3..5344428edb 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js @@ -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(); diff --git a/openstack_dashboard/defaults.py b/openstack_dashboard/defaults.py index 51ef91ce1e..c81c3ab802 100644 --- a/openstack_dashboard/defaults.py +++ b/openstack_dashboard/defaults.py @@ -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', diff --git a/releasenotes/notes/default-instance-boot-source-0cd60b3090ef4b38.yaml b/releasenotes/notes/default-instance-boot-source-0cd60b3090ef4b38.yaml new file mode 100644 index 0000000000..45b4251d93 --- /dev/null +++ b/releasenotes/notes/default-instance-boot-source-0cd60b3090ef4b38.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Introduced a new ``DEFAULT_BOOT_SOURCE`` config option to allow + operators to configure a default instance boot source.