Browse Source

Merge "Add config for default create volume option" into stable/ocata

Jenkins 1 year ago
parent
commit
f87d87a2fa

+ 5
- 0
doc/source/topics/settings.rst View File

@@ -670,6 +670,7 @@ Default::
670 670
         "disable_instance_snapshot": False,
671 671
         "disable_volume": False,
672 672
         "disable_volume_snapshot": False,
673
+        "create_volume": True,
673 674
     }
674 675
 
675 676
 A dictionary of settings which can be used to provide the default values for
@@ -681,6 +682,10 @@ Drive property.
681 682
 The ``enable_scheduler_hints`` setting specifies whether or not Scheduler Hints
682 683
 can be provided when launching an instance.
683 684
 
685
+The ``create_volume`` setting allows you to specify the default value for the
686
+option of creating a new volume in the workflow for image and instance snapshot
687
+sources.
688
+
684 689
 The ``disable_image`` setting disables Images as a valid boot source for launching
685 690
 instances. Image sources won't show up in the Launch Instance modal.
686 691
 

+ 5
- 0
openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js View File

@@ -195,6 +195,7 @@
195 195
         // REQUIRED for JS logic (image | snapshot | volume | volume_snapshot)
196 196
         source_type: null,
197 197
         source: [],
198
+        create_volume_default: true,
198 199
         // REQUIRED for JS logic
199 200
         vol_create: false,
200 201
         // May be null
@@ -278,6 +279,10 @@
278 279
       if ('config_drive' in defaults) {
279 280
         model.newInstanceSpec.config_drive = defaults.config_drive;
280 281
       }
282
+      if ('create_volume' in defaults) {
283
+        // Append "_default" to distinguish from the 'vol_create' item
284
+        model.newInstanceSpec.create_volume_default = defaults.create_volume;
285
+      }
281 286
     }
282 287
 
283 288
     /**

+ 24
- 1
openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js View File

@@ -158,6 +158,7 @@
158 158
         beforeEach(function () {
159 159
           settings = {
160 160
             LAUNCH_INSTANCE_DEFAULTS: {
161
+              create_volume: true,
161 162
               config_drive: false,
162 163
               disable_image: false,
163 164
               disable_instance_snapshot: false,
@@ -485,6 +486,22 @@
485 486
           expect(model.newInstanceSpec.config_drive).toBe(true);
486 487
         });
487 488
 
489
+        it('should default create_volume to true if setting not provided', function() {
490
+          delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
491
+          model.initialize(true);
492
+          scope.$apply();
493
+
494
+          expect(model.newInstanceSpec.create_volume_default).toBe(true);
495
+        });
496
+
497
+        it('should default create_volume to false based on setting', function() {
498
+          settings.LAUNCH_INSTANCE_DEFAULTS.create_volume = false;
499
+          model.initialize(true);
500
+          scope.$apply();
501
+
502
+          expect(model.newInstanceSpec.create_volume_default).toBe(false);
503
+        });
504
+
488 505
         it('should not set availability zone if the zone list is empty', function () {
489 506
           spyOn(novaApi, 'getAvailabilityZones').and.callFake(function () {
490 507
             var deferred = $q.defer();
@@ -583,6 +600,7 @@
583 600
         });
584 601
 
585 602
         it('should have proper allowedBootSources if specific settings missing', function() {
603
+          delete settings.LAUNCH_INSTANCE_DEFAULTS.create_volume;
586 604
           delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_image;
587 605
           delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_instance_snapshot;
588 606
           delete settings.LAUNCH_INSTANCE_DEFAULTS.disable_volume;
@@ -595,6 +613,7 @@
595 613
           expect(model.allowedBootSources).toContain(INSTANCE_SNAPSHOT);
596 614
           expect(model.allowedBootSources).toContain(VOLUME);
597 615
           expect(model.allowedBootSources).toContain(VOLUME_SNAPSHOT);
616
+          expect(model.newInstanceSpec.create_volume_default).toBe(true);
598 617
         });
599 618
 
600 619
         it('should have no images if disable_image is set to true', function() {
@@ -750,7 +769,7 @@
750 769
         // This is here to ensure that as people add/change items, they
751 770
         // don't forget to implement tests for them.
752 771
         it('has the right number of properties', function() {
753
-          expect(Object.keys(model.newInstanceSpec).length).toBe(21);
772
+          expect(Object.keys(model.newInstanceSpec).length).toBe(22);
754 773
         });
755 774
 
756 775
         it('sets availability zone to null', function() {
@@ -765,6 +784,10 @@
765 784
           expect(model.newInstanceSpec.config_drive).toBe(false);
766 785
         });
767 786
 
787
+        it('sets create volume to true', function() {
788
+          expect(model.newInstanceSpec.create_volume_default).toBe(true);
789
+        });
790
+
768 791
         it('sets user data to an empty string', function() {
769 792
           expect(model.newInstanceSpec.user_data).toBe('');
770 793
         });

+ 2
- 1
openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.js View File

@@ -418,7 +418,8 @@
418 418
       ctrl.currentBootSource = selectedSource;
419 419
       if ((selectedSource === bootSourceTypes.IMAGE ||
420 420
            selectedSource === bootSourceTypes.INSTANCE_SNAPSHOT) && $scope.model.volumeBootable) {
421
-        $scope.model.newInstanceSpec.vol_create = true;
421
+        $scope.model.newInstanceSpec.vol_create =
422
+          $scope.model.newInstanceSpec.create_volume_default;
422 423
       } else {
423 424
         $scope.model.newInstanceSpec.vol_create = false;
424 425
       }

+ 1
- 1
openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/source/source.controller.spec.js View File

@@ -50,7 +50,7 @@
50 50
 
51 51
         scope.model = {
52 52
           allowedBootSources: [{type: 'image', label: 'Image'}],
53
-          newInstanceSpec: { source: [], source_type: '' },
53
+          newInstanceSpec: { source: [], source_type: '', create_volume_default: true },
54 54
           images: [ { id: 'image-1' }, { id: 'image-2' } ],
55 55
           imageSnapshots: [ { id: 'imageSnapshot-1' } ],
56 56
           volumes: [ { id: 'volume-1' }, { id: 'volume-2' } ],

+ 1
- 0
openstack_dashboard/local/local_settings.py.example View File

@@ -257,6 +257,7 @@ OPENSTACK_KEYSTONE_BACKEND = {
257 257
 #    'disable_instance_snapshot': False,
258 258
 #    'disable_volume': False,
259 259
 #    'disable_volume_snapshot': False,
260
+#    'create_volume': True,
260 261
 #}
261 262
 
262 263
 # The Xen Hypervisor has the ability to set the mount point for volumes

+ 5
- 0
releasenotes/notes/bug-1678109-4440ebe90908647d.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+features:
3
+  - Added a new ``create_volume`` setting under the
4
+    ``LAUNCH_INSTANCE_DEFAULTS`` dict. This allows you to set the default value
5
+    of "Create Volume", when Cinder is available.

Loading…
Cancel
Save