Skip to content

Commit

Permalink
Support base snapshot for EBS cloud volume provisioning
Browse files Browse the repository at this point in the history
Add option to create new cloud volume from snapshot for AWS EBS Storage Maneger.
  • Loading branch information
sasoc committed May 22, 2017
1 parent 436648e commit 48f5015
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);

Expand All @@ -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();
};
Expand Down
1 change: 1 addition & 0 deletions app/controllers/cloud_volume_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions app/views/cloud_volume/_common_new_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 48f5015

Please sign in to comment.