Skip to content

Commit

Permalink
Add vm security group operations
Browse files Browse the repository at this point in the history
  • Loading branch information
tzumainn committed Aug 16, 2017
1 parent aad4439 commit d3a4f51
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions app/models/manageiq/providers/cloud_manager/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,54 @@ def disassociate_floating_ip(ip_address)
raw_disassociate_floating_ip(ip_address)
end

def raw_add_security_group(_security_group)
raise NotImplementedError, _("raw_add_security_group must be implemented in a subclass")
end

def add_security_group_queue(userid, security_group)
task_opts = {
:action => "associating Security Group with Instance for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'add_security_group',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [security_group]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def add_security_group(security_group)
raw_add_security_group(security_group)
end

def raw_remove_security_group(_security_group)
raise NotImplementedError, _("raw_remove_security_group must be implemented in a subclass")
end

def remove_security_group_queue(userid, security_group)
task_opts = {
:action => "associating Security Group with Instance for user #{userid}",
:userid => userid
}
queue_opts = {
:class_name => self.class.name,
:method_name => 'remove_security_group',
:instance_id => id,
:role => 'ems_operations',
:zone => my_zone,
:args => [security_group]
}
MiqTask.generic_action_with_callback(task_opts, queue_opts)
end

def remove_security_group(security_group)
raw_remove_security_group(security_group)
end

def service
super || orchestration_stack.try(:service)
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module SupportsFeatureMixin
QUERYABLE_FEATURES = {
:add_host => 'Add Host',
:add_interface => 'Add Interface',
:add_security_group => 'Add Security Group',
:associate_floating_ip => 'Associate a Floating IP',
:clone => 'Clone',
# FIXME: this is just a internal helper and should be refactored
Expand Down Expand Up @@ -100,6 +101,7 @@ module SupportsFeatureMixin
:remove_all_snapshots => 'Remove all snapshots',
:remove_host => 'Remove Host',
:remove_interface => 'Remove Interface',
:remove_security_group => 'Remove Security Group',
:remove_snapshot => 'Remove Snapshot',
:remove_snapshot_by_description => 'Remove snapshot having a description',
:reset => 'Reset',
Expand Down

0 comments on commit d3a4f51

Please sign in to comment.