1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Add default_for_az attribute to subnet

* Add new attribute `default_for_az` to `Subnet` model;
* Update parsers to take into account new attribute;
* Fix comments and tests for `map_public_ip_on_launch` attribute.
This commit is contained in:
Roman Zaharenkov 2017-10-16 22:52:16 +02:00
parent 298a99d91d
commit d689de6c66
No known key found for this signature in database
GPG key ID: 7FE3C7A97D2364C6
6 changed files with 33 additions and 23 deletions

View file

@ -10,6 +10,7 @@ module Fog
attribute :availability_zone, :aliases => 'availabilityZone'
attribute :tag_set, :aliases => 'tagSet'
attribute :map_public_ip_on_launch, :aliases => 'mapPublicIpOnLaunch'
attribute :default_for_az, :aliases => 'defaultForAz'
def ready?
requires :state

View file

@ -32,6 +32,8 @@ module Fog
case name
when 'subnetId', 'state', 'vpcId', 'cidrBlock', 'availableIpAddressCount', 'availabilityZone'
@subnet[name] = value
when 'mapPublicIpOnLaunch', 'defaultForAz'
@subnet[name] = value == 'true' ? true : false
when 'subnet'
@response['subnet'] = @subnet
when 'requestId'

View file

@ -32,7 +32,7 @@ module Fog
case name
when 'subnetId', 'state', 'vpcId', 'cidrBlock', 'availableIpAddressCount', 'availabilityZone'
@subnet[name] = value
when 'mapPublicIpOnLaunch'
when 'mapPublicIpOnLaunch', 'defaultForAz'
@subnet[name] = value == 'true' ? true : false
when 'item'
@response['subnetSet'] << @subnet

View file

@ -18,15 +18,17 @@ module Fog
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'subnet'<~Array>:
# * 'subnetId'<~String> - The Subnet's ID
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
# * 'AvailableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any stopped
# instances are considered unavailable)
# * 'AvailabilityZone'<~String> - The Availability Zone the subnet is in
# * 'tagSet'<~Array>: Tags assigned to the resource.
# * 'key'<~String> - Tag's key
# * 'value'<~String> - Tag's value
# * 'subnetId'<~String> - The Subnet's ID
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
# * 'availableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any stopped
# instances are considered unavailable)
# * 'availabilityZone'<~String> - The Availability Zone the subnet is in
# * 'tagSet'<~Array>: Tags assigned to the resource.
# * 'key'<~String> - Tag's key
# * 'value'<~String> - Tag's value
# * 'mapPublicIpOnLaunch'<~Boolean> - Indicates whether instances launched in this subnet receive a public IPv4 address.
# * 'defaultForAz'<~Boolean> - Indicates whether this is the default subnet for the Availability Zone.
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2011-07-15/APIReference/ApiReference-query-CreateSubnet.html]
def create_subnet(vpcId, cidrBlock, options = {})
@ -65,7 +67,9 @@ module Fog
'cidrBlock' => cidrBlock,
'availableIpAddressCount' => "255",
'availabilityZone' => av_zone,
'tagSet' => {}
'tagSet' => {},
'mapPublicIpOnLaunch' => true,
'defaultForAz' => true
}
# Add this subnet to the default network ACL

View file

@ -14,17 +14,18 @@ module Fog
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'subnetSet'<~Array>:
# * 'subnetId'<~String> - The Subnet's ID
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
# * 'vpcId'<~String> - The ID of the VPC the subnet is in
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
# * 'availableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any
# stopped instances are considered unavailable)
# * 'availabilityZone'<~String> - The Availability Zone the subnet is in.
# * 'tagSet'<~Array>: Tags assigned to the resource.
# * 'key'<~String> - Tag's key
# * 'value'<~String> - Tag's value
# * 'instanceTenancy'<~String> - The allowed tenancy of instances launched into the Subnet.
# * 'subnetId'<~String> - The Subnet's ID
# * 'state'<~String> - The current state of the Subnet. ['pending', 'available']
# * 'vpcId'<~String> - The ID of the VPC the subnet is in
# * 'cidrBlock'<~String> - The CIDR block the Subnet covers.
# * 'availableIpAddressCount'<~Integer> - The number of unused IP addresses in the subnet (the IP addresses for any
# stopped instances are considered unavailable)
# * 'availabilityZone'<~String> - The Availability Zone the subnet is in.
# * 'tagSet'<~Array>: Tags assigned to the resource.
# * 'key'<~String> - Tag's key
# * 'value'<~String> - Tag's value
# * 'mapPublicIpOnLaunch'<~Boolean> - Indicates whether instances launched in this subnet receive a public IPv4 address.
# * 'defaultForAz'<~Boolean> - Indicates whether this is the default subnet for the Availability Zone.
#
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2011-07-15/APIReference/index.html?ApiReference-query-DescribeSubnets.html]
def describe_subnets(filters = {})

View file

@ -8,6 +8,8 @@ Shindo.tests('Fog::Compute[:aws] | subnet requests', ['aws']) do
'availableIpAddressCount' => String,
'availabilityZone' => String,
'tagSet' => Hash,
'mapPublicIpOnLaunch' => Fog::Boolean,
'defaultForAz' => Fog::Boolean,
}
@single_subnet_format = {
@ -24,7 +26,7 @@ Shindo.tests('Fog::Compute[:aws] | subnet requests', ['aws']) do
'requestId' => String,
'return' => Fog::Boolean
}
@vpc_network = '10.0.10.0/24'
@vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => @vpc_network)
@vpc_id = @vpc.id