Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume backup restore, delete. #15891

Merged
merged 2 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about cloud_volume_backup_restore?

Copy link
Author

@alexander-demicev alexander-demicev Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agrare identifiers should be unique and cloud_volume_backup_restore is already there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm is that feature used anywhere? It sounds like exactly what this does just defined on CloudVolume but I don't see any restore methods on CloudVolume

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agrare if you mean cloud_volume_backup_restore_to_volume, then it`s used here ManageIQ/manageiq-ui-classic#2037

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, I need a better name for this feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-demichev actually I was wondering if cloud_volume_backup_restore could be removed from CloudVolume and moved here?

Copy link
Author

@alexander-demicev alexander-demicev Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agrare It`s used here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright maybe we can refactor this later to use this instead?

- :name: Delete Backup
:description: Delete Backup
:feature_type: control
:identifier: cloud_volume_backup_delete

# Flavor
- :name: Flavors
Expand Down