Class: Fog::AWS::Compute::Subnet

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/compute/subnet.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

Removes an existing subnet

subnet.destroy

Returns

True or false depending on the result



33
34
35
36
37
38
# File 'lib/fog/aws/models/compute/subnet.rb', line 33

def destroy
  requires :subnet_id

  service.delete_subnet(subnet_id)
  true
end

#network_interfacesObject



20
21
22
# File 'lib/fog/aws/models/compute/subnet.rb', line 20

def network_interfaces
  service.network_interfaces.all('subnet-id' => [self.identity])
end

#ready?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/fog/aws/models/compute/subnet.rb', line 15

def ready?
  requires :state
  state == 'available'
end

#saveObject

Create a subnet

>> g = AWS.subnets.new(:vpc_id => "vpc-someId", :cidr_block => "10.0.0.0/24")
>> g.save

Returns:

requestId and a subnet object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/aws/models/compute/subnet.rb', line 50

def save
  requires :vpc_id, :cidr_block
  options = {}
  options['AvailabilityZone'] = availability_zone if availability_zone
  data = service.create_subnet(vpc_id, cidr_block, options).body['subnet']
  new_attributes = data.reject {|key,value| key == 'requestId'}
  merge_attributes(new_attributes)
  true

  true
end