Browse Source

Merge "Validate minimum RAM for snapshot source" into stable/mitaka

Jenkins 2 years ago
parent
commit
9a460aad76

+ 10
- 8
horizon/static/horizon/js/horizon.instances.js View File

@@ -212,16 +212,18 @@ horizon.addInitFunction(horizon.instances.init = function () {
212 212
    Update the device size value to reflect minimum allowed
213 213
    for selected image and flavor
214 214
    */
215
-  function update_device_size() {
215
+  function update_device_size(source_type) {
216 216
     var volume_size = horizon.Quota.getSelectedFlavor().disk;
217
-    var image = horizon.Quota.getSelectedImage();
218 217
     var size_field = $("#id_volume_size");
219 218
 
220
-    if (image !== undefined && image.min_disk > volume_size) {
221
-      volume_size = image.min_disk;
222
-    }
223
-    if (image !== undefined && image.size > volume_size) {
224
-      volume_size = image.size;
219
+    if (source_type === 'image') {
220
+      var image = horizon.Quota.getSelectedImageOrSnapshot(source_type);
221
+      if (image !== undefined && image.min_disk > volume_size) {
222
+        volume_size = image.min_disk;
223
+      }
224
+      if (image !== undefined && image.size > volume_size) {
225
+        volume_size = image.size;
226
+      }
225 227
     }
226 228
 
227 229
     // If the user has manually changed the volume size, do not override
@@ -246,7 +248,7 @@ horizon.addInitFunction(horizon.instances.init = function () {
246 248
   });
247 249
 
248 250
   $document.on('change', '.workflow #id_image_id', function () {
249
-    update_device_size();
251
+    update_device_size('image');
250 252
   });
251 253
 
252 254
   $document.on('input', '.workflow #id_volume_size', function () {

+ 14
- 9
horizon/static/horizon/js/horizon.quota.js View File

@@ -134,25 +134,25 @@ horizon.Quota = {
134 134
   },
135 135
 
136 136
   /*
137
-   Return an image Object based on which image ID is selected
137
+   Return an image/snapshot Object based on which image/snapshot ID is selected
138 138
    */
139
-  getSelectedImage: function() {
140
-    var selected = $('#id_image_id option:selected').val();
139
+  getSelectedImageOrSnapshot: function(source_type) {
140
+    var selected = $('#id_' + source_type + '_id option:selected').val();
141 141
     return horizon.Quota.findImageById(selected);
142 142
   },
143 143
 
144 144
   /*
145
-   Disable any flavors for a given image that do not meet
145
+   Disable any flavors for a given image/snapshot that do not meet
146 146
    its minimum RAM or disk requirements.
147 147
    */
148
-  disableFlavorsForImage: function(image) {
149
-    image = horizon.Quota.getSelectedImage();
148
+  disableFlavorsForImage: function(source_type) {
149
+    var source = horizon.Quota.getSelectedImageOrSnapshot(source_type);
150 150
     var to_disable = []; // an array of flavor names to disable
151 151
 
152 152
     horizon.Quota.resetFlavors(); // clear any previous messages
153 153
 
154 154
     $.each(horizon.Quota.flavors, function(i, flavor) {
155
-      if (!horizon.Quota.imageFitsFlavor(image, flavor)) {
155
+      if (!horizon.Quota.imageFitsFlavor(source, flavor)) {
156 156
         to_disable.push(flavor.name);
157 157
       }
158 158
     });
@@ -192,7 +192,7 @@ horizon.Quota = {
192 192
     this.disabledFlavorMessage = disabledMessage;
193 193
     this.allFlavorsDisabledMessage = allDisabledMessage;
194 194
     // Check if the image is pre-selected
195
-    horizon.Quota.disableFlavorsForImage();
195
+    horizon.Quota.disableFlavorsForImage('image');
196 196
   },
197 197
 
198 198
   /*
@@ -397,12 +397,17 @@ horizon.Quota = {
397 397
       };
398 398
 
399 399
       var imageChangeCallback = function() {
400
-        scope.disableFlavorsForImage();
400
+        scope.disableFlavorsForImage('image');
401
+      };
402
+
403
+      var snapshotChangeCallback = function() {
404
+        scope.disableFlavorsForImage('instance_snapshot');
401 405
       };
402 406
 
403 407
       $('#id_flavor').on('keyup change', eventCallback);
404 408
       $('#id_count').on('input', eventCallback);
405 409
       $('#id_image_id').on('change', imageChangeCallback);
410
+      $('#id_instance_snapshot_id').on('change', snapshotChangeCallback);
406 411
     }
407 412
 
408 413
     $(this.user_value_form_inputs).each(function(index, element) {

+ 2
- 2
openstack_dashboard/dashboards/project/instances/templates/instances/_flavors_and_quotas.html View File

@@ -75,8 +75,8 @@
75 75
 
76 76
 
77 77
 <script type="text/javascript" charset="utf-8">
78
-  some_disabled_msg = '{{_("Some flavors not meeting minimum image requirements have been disabled.")|escapejs }}';
79
-  all_disabled_msg = '{{_("No flavors meet minimum criteria for selected image.")|escapejs }}';
78
+  some_disabled_msg = '{{_("Some flavors not meeting minimum boot source requirements have been disabled.")|escapejs }}';
79
+  all_disabled_msg = '{{_("No flavors meet minimum criteria for selected boot source.")|escapejs }}';
80 80
 
81 81
   if(typeof horizon.Quota !== 'undefined') {
82 82
     horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }});

Loading…
Cancel
Save