Class: Fog::AWS::Compute::VPC
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::Compute::VPC
- Defined in:
- lib/fog/aws/models/compute/vpc.rb
Instance Method Summary collapse
- #classic_link_dns_enabled? ⇒ Boolean
- #classic_link_enabled? ⇒ Boolean
-
#destroy ⇒ Object
Removes an existing vpc.
- #disable_classic_link ⇒ Object
- #disable_classic_link_dns ⇒ Object
- #enable_classic_link ⇒ Object
- #enable_classic_link_dns ⇒ Object
-
#initialize(attributes = {}) ⇒ VPC
constructor
A new instance of VPC.
- #is_default? ⇒ Boolean
- #ready? ⇒ Boolean
-
#save ⇒ Object
Create a vpc.
- #subnets ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ VPC
Returns a new instance of VPC.
29 30 31 32 33 34 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 29 def initialize(attributes={}) self. ||= "default" self.tenancy ||= "default" self.amazon_provided_ipv_6_cidr_block ||=false super end |
Instance Method Details
#classic_link_dns_enabled? ⇒ Boolean
79 80 81 82 83 84 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 79 def classic_link_dns_enabled? requires :identity service.describe_vpc_classic_link_dns_support(:vpc_ids => [self.identity]).body['vpcs'].first['classicLinkDnsSupported'] rescue nil end |
#classic_link_enabled? ⇒ Boolean
62 63 64 65 66 67 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 62 def classic_link_enabled? requires :identity service.describe_vpc_classic_link(:vpc_ids => [self.identity]).body['vpcSet'].first['classicLinkEnabled'] rescue nil end |
#destroy ⇒ Object
Removes an existing vpc
vpc.destroy
Returns
True or false depending on the result
55 56 57 58 59 60 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 55 def destroy requires :id service.delete_vpc(id) true end |
#disable_classic_link ⇒ Object
74 75 76 77 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 74 def disable_classic_link requires :identity service.disable_vpc_classic_link(self.identity).body['return'] end |
#disable_classic_link_dns ⇒ Object
91 92 93 94 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 91 def disable_classic_link_dns requires :identity service.disable_vpc_classic_link_dns_support(self.identity).body['return'] end |
#enable_classic_link ⇒ Object
69 70 71 72 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 69 def enable_classic_link requires :identity service.enable_vpc_classic_link(self.identity).body['return'] end |
#enable_classic_link_dns ⇒ Object
86 87 88 89 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 86 def enable_classic_link_dns requires :identity service.enable_vpc_classic_link_dns_support(self.identity).body['return'] end |
#is_default? ⇒ Boolean
41 42 43 44 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 41 def is_default? requires :is_default is_default end |
#ready? ⇒ Boolean
36 37 38 39 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 36 def ready? requires :state state == 'available' end |
#save ⇒ Object
Create a vpc
>> g = AWS.vpcs.new(:cidr_block => “10.1.2.0/24”) >> g.save
Returns:
True or an exception depending on the result. Keep in mind that this creates a new vpc. As such, it yields an InvalidGroup.Duplicate exception if you attempt to save an existing vpc.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 107 def save requires :cidr_block = { 'AmazonProvidedIpv6CidrBlock' => amazon_provided_ipv_6_cidr_block, 'InstanceTenancy' => tenancy } data = service.create_vpc(cidr_block, ).body['vpcSet'].first new_attributes = data.reject {|key,value| key == 'requestId'} new_attributes = data.reject {|key,value| key == 'requestId' || key == 'tagSet' } merge_attributes(new_attributes) if = self. # expect eventual consistency Fog.wait_for { self.reload rescue nil } service.( self.identity, ) end true end |
#subnets ⇒ Object
25 26 27 |
# File 'lib/fog/aws/models/compute/vpc.rb', line 25 def subnets service.subnets(:filters => {'vpcId' => self.identity}).all end |