Skip to content

Commit

Permalink
Merge pull request #4623 from mansam/allow-restoring-backups-to-new-v…
Browse files Browse the repository at this point in the history
…olumes

Allow restoring backups to new volumes
  • Loading branch information
himdel authored Apr 15, 2019
2 parents 2126217 + e250f6e commit 0a1cd9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function cloudVolumeBackupFormController(miqService, $http) {

vm.cloudVolumeBackupModel = {
volume: '',
name: '',
};

vm.model = 'cloudVolumeBackupModel';
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/cloud_volume_backup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def backup_restore
cancel_action(_("Restore to Cloud Volume \"%{name}\" was cancelled by the user") % {:name => @backup.name})

when "restore"
task_id = @backup.restore_queue(session[:userid], params[:volume][:ems_ref])
# volume_id to restore to is optional
volume_id = params[:volume].try(:fetch, :ems_ref, nil)
new_volume_name = params[:name]
task_id = @backup.restore_queue(session[:userid], volume_id, new_volume_name)

if task_id.kind_of?(Integer)
initiate_wait_for_task(:task_id => task_id, :action => "backup_restore_finished")
Expand Down
20 changes: 14 additions & 6 deletions app/views/static/cloud_volume_backup/volume_select.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
%label.col-md-2.control-label
= _('Volume')
.col-md-8
= select_tag('volume_id',
'',
'ng-model' => 'vm.cloudVolumeBackupModel.volume',
'ng-options' => 'volume.name for volume in vm.volume_choices track by volume.id',
:required => '',
'miq-select' => true)
%select{"name" => "volume_id",
"ng-model" => "vm.cloudVolumeBackupModel.volume",
"ng-options" => "volume.name for volume in vm.volume_choices track by volume.id",
"miq-select" => true}
%option{"value" => ""}
= "<#{_('New Volume')}>"
.form-group{"ng-if" => "vm.cloudVolumeBackupModel.volume == null"}
%label.col-md-2.control-label
= _('New Volume Name')
.col-md-8
%input.form-control{:type => "text",
:name => "name",
'ng-model' => "vm.cloudVolumeBackupModel.name",
'ng-maxlength' => 128}

= render :partial => 'layouts/angular/generic_form_buttons'
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('cloud-volume-backup-form', function() {
describe('#init', function() {
var expectedValue = {
volume: { name: "original value" },
name: ''
};

it('sets model correctly', function() {
Expand Down

0 comments on commit 0a1cd9b

Please sign in to comment.