class VPC::Vpn
Attributes
customer_gateways[R]
route_tables[R]
stub[R]
vpc[R]
vpn_connections[R]
vpn_gateway[R]
Public Class Methods
new(vpc)
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 10 def initialize(vpc) @vpc = vpc @config = vpc.config @gateway = vpc.gateway @route_tables = [] @vpc_tags = @config.get_yaml_vpc_tags @stub = false setup_customer_gateways setup_vpn_gateway setup_vpn_connections end
Public Instance Methods
attach_vpn_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 43 def attach_vpn_gateway @vpn_gateway.attach(@vpc.vpc_id) end
create_customer_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 27 def create_customer_gateway customer_gateways_info = @config.get_vpn_customer_gateways customer_gateways_info.each do |customer_gateway_config| customer_gateway_info = customer_gateway_config['CONFIG']['CUSTOMER_GATEWAY'] customer_gateway = CustomerGateway.new(@config,@gateway) customer_gateway.create(customer_gateway_info) @customer_gateways << customer_gateway end end
create_route()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 61 def create_route @vpn_connections.each do |vpn_connection| vpn_connection_id = vpn_connection.vpn_connection_id @gateway.wait_for_vpn_connection_available(vpn_connection_id) @config.private_route_tables.each do |v| name = v['CONFIG']['ROUTE_TABLE_TAGS'].first['NAME']['VALUE'] destination_cidr_blocks = @config.get_vpn_gateway['DESTINATION_CIDR_BLOCKS'] destination_cidr_blocks.each do |cidr_block| route_tables = @gateway.select_route_tables_by_name(name) route_tables.each do |route_table| @gateway.create_route_vpn(cidr_block['CIDR'],@vpn_gateway.vpn_gateway_id,route_table.route_table_id) @route_tables << route_table end end end end end
create_vpn_connection()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 47 def create_vpn_connection n = 0 vpn_connections_info = @config.get_vpn_connections vpn_connections_info.each do |vpn_connection_config| vpn_connection_info = vpn_connection_config['CONFIG']['VPN_CONNECTION'] customer_gateway_id = @customer_gateways[n].customer_gateway_id vpn_gateway_id = @vpn_gateway.vpn_gateway_id vpn_connection = VpnConnection.new(@config,@gateway) vpn_connection.creat(customer_gateway_id, vpn_gateway_id, vpn_connection_info) @vpn_connections << vpn_connection n += 1 end end
create_vpn_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 37 def create_vpn_gateway vpn_gateway_info = @config.get_vpn_gateway @vpn_gateway = VpnGateway.new(@config,@gateway) @vpn_gateway.create(vpn_gateway_info) end
delete_customer_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 80 def delete_customer_gateway resp = [] @customer_gateways.each do |customer_gateway| resp << customer_gateway.delete end @customer_gateways = [] @customer_gateways = resp end
delete_route()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 106 def delete_route @route_tables.each do |route_table| route_table_id = route_table.route_table_id @associate_route_table_ids = @gateway.select_associate_route_table_ids_by_route_table_id(route_table_id) @associate_route_table_ids.each do |id| @gateway.disassociate_route_table(id) end @gateway.delete_route_table(route_table_id) end end
delete_vpn_connection()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 97 def delete_vpn_connection resp = [] @vpn_connections.each do |vpn_connection| resp << vpn_connection.delete end @vpn_connections = [] @vpn_connections = resp end
delete_vpn_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 89 def delete_vpn_gateway @vpn_gateway = @vpn_gateway.delete end
detach_vpn_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 93 def detach_vpn_gateway @vpn_gateway.detach(@vpc.vpc_id) end
stub?()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 23 def stub? @stub end
Private Instance Methods
setup_customer_gateways()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 118 def setup_customer_gateways @customer_gateways = [] customer_gateways_info = @config.get_vpn_customer_gateways customer_gateways_info.each do |customer_gateway_config| tags = customer_gateway_config['CONFIG']['CUSTOMER_GATEWAY']['TAGS'] value = tags['NAME']['VALUE'] customer_gateways = @gateway.select_customer_gateways_by_name(value) unless customer_gateways.empty? customer_gateway_id = customer_gateways[0].customer_gateway_id @customer_gateways << CustomerGateway.new(@config, @gateway, customer_gateway_id) end end end
setup_vpn_connections()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 141 def setup_vpn_connections @vpn_connections = [] vpn_connections_info = @config.get_vpn_connections vpn_connections_info.each do |vpn_connection_config| tags = vpn_connection_config['CONFIG']['VPN_CONNECTION']['TAGS'] value = tags['NAME']['VALUE'] vpn_connections = @gateway.select_vpn_connections_by_name(value) unless vpn_connections.empty? vpn_connection_id = vpn_connections[0].vpn_connection_id vpn_connection = VpnConnection.new(@config, @gateway, vpn_connection_id) @vpn_connections << vpn_connection end end end
setup_vpn_gateway()
click to toggle source
# File lib/etude_for_aws/vpc/vpn.rb, line 132 def setup_vpn_gateway value = @config.get_vpn_gateway['TAGS']['NAME']['VALUE'] vpn_gateways = @gateway.select_vpc_gateways_by_name(value) unless vpn_gateways.empty? vpn_gateway_id = vpn_gateways[0].vpn_gateway_id @vpn_gateway = VpnGateway.new(@config,@gateway,vpn_gateway_id) end end