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

Use task queue for VM actions #13782

Merged
merged 1 commit into from
Feb 16, 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
53 changes: 52 additions & 1 deletion app/models/manageiq/providers/cloud_manager/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,26 @@ def cpu_percent_available?
true
end

def resize(new_flavor)
def resize_queue(userid, new_flavor)
task_opts = {
:action => "resizing Instance for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'resize',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [new_flavor.id]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def resize(new_flavor_id)
raise ArgumentError, _("new_flavor_id cannot be nil") if new_flavor_id.nil?
new_flavor = Flavor.find(new_flavor_id)
raise ArgumentError, _("flavor cannot be found") if new_flavor.nil?
raw_resize(new_flavor)
end

Expand All @@ -128,6 +147,22 @@ def raw_associate_floating_ip(_ip_address)
raise NotImplementedError, _("raw_associate_floating_ip must be implemented in a subclass")
end

def associate_floating_ip_queue(userid, ip_address)
task_opts = {
:action => "associating floating IP with Instance for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'associate_floating_ip',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [ip_address]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def associate_floating_ip(ip_address)
raw_associate_floating_ip(ip_address)
end
Expand All @@ -136,6 +171,22 @@ def raw_disassociate_floating_ip(_ip_address)
raise NotImplementedError, _("raw_disassociate_floating_ip must be implemented in a subclass")
end

def disassociate_floating_ip_queue(userid, ip_address)
task_opts = {
:action => "disassociating floating IP with Instance for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'disassociate_floating_ip',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [ip_address]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def disassociate_floating_ip(ip_address)
raw_disassociate_floating_ip(ip_address)
end
Expand Down
16 changes: 16 additions & 0 deletions app/models/vm_or_template/operations/relocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ def raw_evacuate(_options = nil)
raise NotImplementedError, _("raw_evacuate must be implemented in a subclass")
end

def evacuate_queue(userid, options)
task_opts = {
:action => "evacuating VM for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'evacuate',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [options]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def evacuate(options = {})
raw_evacuate(options)
end
Expand Down