From 6ebb1eec7d48d8591251269b439039bd2721e96e Mon Sep 17 00:00:00 2001 From: Alexander Demichev Date: Mon, 21 Aug 2017 11:24:12 +0200 Subject: [PATCH 1/2] add volume backup restore, delete --- app/models/cloud_volume_backup.rb | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/models/cloud_volume_backup.rb b/app/models/cloud_volume_backup.rb index d009c162f1f..db14dc2a8f7 100644 --- a/app/models/cloud_volume_backup.rb +++ b/app/models/cloud_volume_backup.rb @@ -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 From f8b8535bd17ccc5a2ba93d343ad06a3c6e698b33 Mon Sep 17 00:00:00 2001 From: Alexander Demichev Date: Mon, 21 Aug 2017 11:25:02 +0200 Subject: [PATCH 2/2] add backup delete, restore to features --- db/fixtures/miq_product_features.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/fixtures/miq_product_features.yml b/db/fixtures/miq_product_features.yml index 0fa81685dd9..26042e9d4b7 100644 --- a/db/fixtures/miq_product_features.yml +++ b/db/fixtures/miq_product_features.yml @@ -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