Skip to content

Commit

Permalink
Add notifications around security_group_create using the mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Aug 15, 2018
1 parent 6581a32 commit 9618637
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/models/manageiq/providers/amazon/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ManageIQ::Providers::Amazon::NetworkManager < ManageIQ::Providers::Network
require_nested :SecurityGroup

include ManageIQ::Providers::Amazon::ManagerMixin
include NotificationMixin

# Auth and endpoints delegations, editing of this type of manager must be disabled
delegate :authentication_check,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@ def self.display_name(number = 1)
end

def self.raw_create_security_group(ext_management_system, options, user_id)
Ansible::Runner.run(ext_management_system.parent_manager.ansible_env_vars,
{
:vpc_id => options["vpc_id"],
:security_group_name => options["security_group_name"],
:security_group_description => options["security_group_description"],
:security_group_rules => options["security_group_rules"],
:security_group_rules_egress => options["security_group_rules_egress"],
},
ext_management_system.parent_manager.ansible_root.join("create_security_group.yml"))
rescue => e
_log.error("security_group=[#{options[:name]}], error: #{e}")
raise MiqException::MiqSecurityGroupCreateError, e.message, e.backtrace
ext_management_system.notify_task_start(_('My awesome task is starting.'), user_id)
begin
task = Ansible::Runner.run(ext_management_system.parent_manager.ansible_env_vars,
{
:vpc_id => options["vpc_id"],
:security_group_name => options["security_group_name"],
:security_group_description => options["security_group_description"],
:security_group_rules => options["security_group_rules"],
:security_group_rules_egress => options["security_group_rules_egress"],
},
ext_management_system.parent_manager.ansible_root.join("create_security_group.yml"))
rescue => e
_log.error("security_group=[#{options[:name]}], error: #{e}")
ext_management_system.notify_task_fail(_('My awesome task failed.'), user_id)
raise MiqException::MiqSecurityGroupCreateError, e.message, e.backtrace
else
ext_management_system.notify_task_finish(_('My awesome task finished.'), user_id)
end

task
end
end

0 comments on commit 9618637

Please sign in to comment.