class RightScaleCLI::SecurityGroups
Represents Network Manager Security Groups
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/rightscale_cli/network/security_groups.rb, line 26 def initialize(*args) super @client = RightScaleCLI::Client.new(options) @logger = RightScaleCLI::Logger.new end
Public Instance Methods
create(name, description=false)
click to toggle source
# File lib/rightscale_cli/network/security_groups.rb, line 66 def create(name, description=false) @client.create('security_group', cloud: options[:cloud], security_group: { name: name, description: description }) end
create_rs_mgmt(network_id)
click to toggle source
# File lib/rightscale_cli/network/security_groups.rb, line 78 def create_rs_mgmt(network_id) sg_href = @client.create('security_group', cloud: options[: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()
click to toggle source
# File lib/rightscale_cli/network/security_groups.rb, line 42 def list filter = [] @logger.debug "filter: #{filter}" if options[:debug] security_groups = [] @client.client.clouds(id: options[: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)
click to toggle source
# File lib/rightscale_cli/network/security_groups.rb, line 56 def show(secgroup_id) filter = [] @client.render(@client.client.clouds(id: options[:cloud]).show.instances.index(id: instance_id).show.raw, 'instance') end