Class: RightScaleCLI::SecurityGroups
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::SecurityGroups
- Defined in:
- lib/rightscale_cli/network/security_groups.rb
Overview
Represents Network Manager Security Groups
Class Method Summary collapse
Instance Method Summary collapse
- #create(name, description = false) ⇒ Object
- #create_rs_mgmt(network_id) ⇒ Object
-
#initialize(*args) ⇒ SecurityGroups
constructor
A new instance of SecurityGroups.
- #list ⇒ Object
- #show(secgroup_id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ SecurityGroups
Returns a new instance of SecurityGroups.
26 27 28 29 30 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 26 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new end |
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
151 152 153 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 151 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#create(name, description = false) ⇒ Object
66 67 68 69 70 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 66 def create(name, description=false) @client.create('security_group', cloud: [:cloud], security_group: { name: name, description: description }) end |
#create_rs_mgmt(network_id) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 78 def create_rs_mgmt(network_id) sg_href = @client.create('security_group', cloud: [:cloud], security_group: { name: 'mgmt-rightscale-egress', description: 'Enables all RightScale ' \ 'use cases (end-user access to UI and ' \ 'API, RightLink system management, ' \ 'monitoring, alerting).', network_href: "/api/networks/#{network_id}" }) sg_rules = [ { cidr_ips: '54.187.254.128/26', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '54.225.248.128/27', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '54.244.88.96/27', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '54.246.247.16/28', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '54.255.255.208/28', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '54.86.63.128/26', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'all', direction: 'egress' }, { cidr_ips: '0.0.0.0/0', security_group_href: sg_href, source_type: 'cidr_ips', protocol: 'udp', protocol_details: { start_port: '3011', end_port: '3011' }, direction: 'egress' } ] sg_rules.each do |rule| @logger.info rule @client.create('security_group_rule', security_group_rule: rule) end @logger.info 'Please remember to delete the outbound ' \ '0.0.0.0/0 rule now (TODO: automatically delete).' end |
#list ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 42 def list filter = [] @logger.debug "filter: #{filter}" if [:debug] security_groups = [] @client.client.clouds(id: [:cloud])\ .show.security_groups(filter: filter).index.each do |sec_group| security_groups.push(sec_group) end @client.render(security_groups, 'security_groups') end |
#show(secgroup_id) ⇒ Object
56 57 58 59 |
# File 'lib/rightscale_cli/network/security_groups.rb', line 56 def show(secgroup_id) filter = [] @client.render(@client.client.clouds(id: [:cloud]).show.instances.index(id: instance_id).show.raw, 'instance') end |