Class: CfnVpn::Actions::Subnets
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- CfnVpn::Actions::Subnets
- Includes:
- Thor::Actions
- Defined in:
- lib/cfnvpn/actions/subnets.rb
Instance Method Summary collapse
- #associate ⇒ Object
- #associated? ⇒ Boolean
- #associations ⇒ Object
- #disassociate ⇒ Object
- #set_loglevel ⇒ Object
- #stack_exist ⇒ Object
Instance Method Details
#associate ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cfnvpn/actions/subnets.rb', line 34 def associate if @options[:associate] if !@associated CfnVpn::Log.logger.info "Associating subnets ..." change_set, change_set_type = @deployer.create_change_set(parameters: {"AssociateSubnets" => 'true'}) @deployer.wait_for_changeset(change_set.id) @deployer.execute_change_set(change_set.id) @deployer.wait_for_execute(change_set_type) CfnVpn::Log.logger.info "Association complete" else CfnVpn::Log.logger.warn "Client-VPN #{name} subnets are already associated" end end end |
#associated? ⇒ Boolean
30 31 32 |
# File 'lib/cfnvpn/actions/subnets.rb', line 30 def associated? @associated = @deployer.get_parameter_value('AssociateSubnets') == 'true' end |
#associations ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/cfnvpn/actions/subnets.rb', line 64 def associations vpn = CfnVpn::ClientVpn.new(@name,@options['region']) associations = vpn.get_associations() table = Terminal::Table.new( :headings => ['ID', 'Subnet', 'Status', 'CIDR', 'AZ', 'Groups'], :rows => associations.map {|ass| ass.values}) puts table end |
#disassociate ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cfnvpn/actions/subnets.rb', line 49 def disassociate if @options[:disassociate] if @associated CfnVpn::Log.logger.info "Disassociating subnets ..." change_set, change_set_type = @deployer.create_change_set(parameters: {"AssociateSubnets" => 'false'}) @deployer.wait_for_changeset(change_set.id) @deployer.execute_change_set(change_set.id) @deployer.wait_for_execute(change_set_type) CfnVpn::Log.logger.info "Disassociation complete" else CfnVpn::Log.logger.warn "Client-VPN #{name} subnets are already disassociated" end end end |
#set_loglevel ⇒ Object
18 19 20 |
# File 'lib/cfnvpn/actions/subnets.rb', line 18 def set_loglevel CfnVpn::Log.logger.level = Logger::DEBUG if @options['verbose'] end |
#stack_exist ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/cfnvpn/actions/subnets.rb', line 22 def stack_exist @deployer = CfnVpn::Deployer.new(@options['region'],@name) if !@deployer.does_cf_stack_exist() CfnVpn::Log.logger.error "#{@name}-cfnvpn stack doesn't exists in this account and region #{@options['region']}" exit 1 end end |