Skip to content

Commit

Permalink
Merge pull request #15891 from alexander-demichev/cloud-volume-backup
Browse files Browse the repository at this point in the history
Volume backup restore, delete.
  • Loading branch information
agrare authored Aug 29, 2017
2 parents bf8f9a8 + f8b8535 commit 68cb56e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
52 changes: 52 additions & 0 deletions app/models/cloud_volume_backup.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,61 @@
class CloudVolumeBackup < ApplicationRecord
include NewWithTypeStiMixin
include ProviderObjectMixin
include SupportsFeatureMixin
include CloudTenancyMixin

acts_as_miq_taggable

belongs_to :ext_management_system, :foreign_key => :ems_id, :class_name => "ExtManagementSystem"
belongs_to :availability_zone
belongs_to :cloud_volume
has_one :cloud_tenant, :through => :cloud_volume

def restore_queue(userid, volumeid)
task_opts = {
:action => "Restoring Cloud Volume Backup for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'restore',
:instance_id => id,
:role => 'ems_operations',
:zone => ext_management_system.my_zone,
:args => [volumeid]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def restore(volume)
raw_restore(volume)
end

def raw_restore(*)
raise NotImplementedError, _("raw_restore must be implemented in a subclass")
end

def delete_queue(userid)
task_opts = {
:action => "deleting Cloud Volume Backup for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'delete',
:instance_id => id,
:role => 'ems_operations',
:zone => ext_management_system.my_zone,
:args => []
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def delete
raw_delete
end

def raw_delete
raise NotImplementedError, _("raw_delete must be implemented in a subclass")
end
end
8 changes: 8 additions & 0 deletions db/fixtures/miq_product_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,14 @@
:description: Edit Tags of Backups
:feature_type: control
:identifier: cloud_volume_backup_tag
- :name: Restore Backup
:description: Restore Backup to Volume
:feature_type: control
:identifier: cloud_volume_backup_restore_to_volume
- :name: Delete Backup
:description: Delete Backup
:feature_type: control
:identifier: cloud_volume_backup_delete

# Flavor
- :name: Flavors
Expand Down

0 comments on commit 68cb56e

Please sign in to comment.