diff --git a/app/assets/javascripts/controllers/cloud_volume/cloud_volume_form_controller.js b/app/assets/javascripts/controllers/cloud_volume/cloud_volume_form_controller.js index 5c61bb679c88..943f3bb1395d 100644 --- a/app/assets/javascripts/controllers/cloud_volume/cloud_volume_form_controller.js +++ b/app/assets/javascripts/controllers/cloud_volume/cloud_volume_form_controller.js @@ -26,7 +26,7 @@ ManageIQ.angular.app.controller('cloudVolumeFormController', ['miqService', 'API if (cloudVolumeFormId !== 'new') { // Fetch cloud volume data before showing the form. - API.get('/api/cloud_volumes/' + cloudVolumeFormId + '?attributes=ext_management_system.type,availability_zone.ems_ref') + API.get('/api/cloud_volumes/' + cloudVolumeFormId + '?attributes=ext_management_system.type,availability_zone.ems_ref,base_snapshot.ems_ref') .then(getCloudVolumeFormData) .catch(miqService.handleFailure); } else { @@ -113,7 +113,7 @@ ManageIQ.angular.app.controller('cloudVolumeFormController', ['miqService', 'API vm.storageManagerChanged = function(id) { miqService.sparkleOn(); - API.get('/api/providers/' + id + '?attributes=type,parent_manager.availability_zones,parent_manager.cloud_tenants') + API.get('/api/providers/' + id + '?attributes=type,parent_manager.availability_zones,parent_manager.cloud_tenants,parent_manager.cloud_volume_snapshots') .then(getStorageManagerFormData) .catch(miqService.handleFailure); }; @@ -214,6 +214,11 @@ ManageIQ.angular.app.controller('cloudVolumeFormController', ['miqService', 'API vm.cloudVolumeModel.aws_volume_type = data.volume_type; vm.cloudVolumeModel.aws_availability_zone_id = data.availability_zone.ems_ref; + // If volume was created from snapshot and this snapshot still exists + if (data.base_snapshot) { + vm.cloudVolumeModel.aws_base_snapshot_id = data.base_snapshot.ems_ref; + } + // Update the IOPS based on the current volume size. vm.sizeChanged(vm.cloudVolumeModel.size); @@ -224,6 +229,7 @@ ManageIQ.angular.app.controller('cloudVolumeFormController', ['miqService', 'API vm.cloudVolumeModel.emstype = data.type; vm.cloudTenantChoices = data.parent_manager.cloud_tenants; vm.availabilityZoneChoices = data.parent_manager.availability_zones; + vm.baseSnapshotChoices = data.parent_manager.cloud_volume_snapshots; miqService.sparkleOff(); }; diff --git a/app/controllers/cloud_volume_controller.rb b/app/controllers/cloud_volume_controller.rb index b448ca139e08..44291a543696 100644 --- a/app/controllers/cloud_volume_controller.rb +++ b/app/controllers/cloud_volume_controller.rb @@ -693,6 +693,7 @@ def form_params_create # Only set IOPS if io1 (provisioned IOPS) and IOPS available options[:iops] = params[:aws_iops] if options[:volume_type] == 'io1' && params[:aws_iops] options[:availability_zone] = params[:aws_availability_zone_id] if params[:aws_availability_zone_id] + options[:snapshot_id] = params[:aws_base_snapshot_id] if params[:aws_base_snapshot_id] options[:encrypted] = params[:aws_encryption] # Get the storage manager. diff --git a/app/views/cloud_volume/_common_new_edit.html.haml b/app/views/cloud_volume/_common_new_edit.html.haml index 9316863ec4fc..4c42aeac4aec 100644 --- a/app/views/cloud_volume/_common_new_edit.html.haml +++ b/app/views/cloud_volume/_common_new_edit.html.haml @@ -110,6 +110,20 @@ %span.help-block{"ng-show" => "vm.cloudVolumeModel.aws_volume_type == 'io1' && angularForm.aws_iops.$error.required"} = _("Required") +.form-group{"ng-if" => "vm.cloudVolumeModel.emstype == 'ManageIQ::Providers::Amazon::StorageManager::Ebs'"} + %label.col-md-2.control-label + = _('Base Snapshot') + .col-md-8 + %select{"name" => "aws_base_snapshot_id", + "ng-model" => "vm.cloudVolumeModel.aws_base_snapshot_id", + "ng-options" => "vs.ems_ref as vs.name for vs in vm.baseSnapshotChoices", + "ng-disabled" => "!vm.newRecord", + :checkchange => true, + "data-live-search" => "true", + "pf-select" => true} + %option{"value" => "", "enabled" => ""} + = _('No snapshot') + .form-group{"ng-if" => "vm.cloudVolumeModel.emstype == 'ManageIQ::Providers::Amazon::StorageManager::Ebs'"} %label.col-md-2.control-label = _('Encryption')