diff --git a/doc/source/topics/settings.rst b/doc/source/topics/settings.rst index b2a754d70d..ccf893e2e3 100644 --- a/doc/source/topics/settings.rst +++ b/doc/source/topics/settings.rst @@ -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. 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 deebfdf3d6..f76ea5ba2f 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 @@ -195,6 +195,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 @@ -278,6 +279,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; + } } /** 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 87b07fe4dc..0ed7f929e9 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 @@ -158,6 +158,7 @@ beforeEach(function () { settings = { LAUNCH_INSTANCE_DEFAULTS: { + create_volume: true, config_drive: false, disable_image: false, disable_instance_snapshot: false, @@ -485,6 +486,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(); @@ -583,6 +600,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; @@ -595,6 +613,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() { @@ -750,7 +769,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(21); + expect(Object.keys(model.newInstanceSpec).length).toBe(22); }); it('sets availability zone to null', function() { @@ -765,6 +784,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(''); }); 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 8444d70983..4892c86b2b 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 @@ -418,7 +418,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; } 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 b874c13329..5834a8df28 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 @@ -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' } ], diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index deca94cffb..2eb3d22cda 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -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 diff --git a/releasenotes/notes/bug-1678109-4440ebe90908647d.yaml b/releasenotes/notes/bug-1678109-4440ebe90908647d.yaml new file mode 100644 index 0000000000..e0cde1186d --- /dev/null +++ b/releasenotes/notes/bug-1678109-4440ebe90908647d.yaml @@ -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.