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 :availability_zone, :aliases => 'availabilityZone'
attribute :tag_set, :aliases => 'tagSet' attribute :tag_set, :aliases => 'tagSet'
attribute :map_public_ip_on_launch, :aliases => 'mapPublicIpOnLaunch' attribute :map_public_ip_on_launch, :aliases => 'mapPublicIpOnLaunch'
attribute :default_for_az, :aliases => 'defaultForAz'
def ready? def ready?
requires :state requires :state

View file

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

View file

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

View file

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

View file

@ -24,7 +24,8 @@ module Fog
# * 'tagSet'<~Array>: Tags assigned to the resource. # * 'tagSet'<~Array>: Tags assigned to the resource.
# * 'key'<~String> - Tag's key # * 'key'<~String> - Tag's key
# * 'value'<~String> - Tag's value # * 'value'<~String> - Tag's value
# * 'instanceTenancy'<~String> - The allowed tenancy of instances launched into the Subnet. # * '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] # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/2011-07-15/APIReference/index.html?ApiReference-query-DescribeSubnets.html]
def describe_subnets(filters = {}) def describe_subnets(filters = {})

View file

@ -8,6 +8,8 @@ Shindo.tests('Fog::Compute[:aws] | subnet requests', ['aws']) do
'availableIpAddressCount' => String, 'availableIpAddressCount' => String,
'availabilityZone' => String, 'availabilityZone' => String,
'tagSet' => Hash, 'tagSet' => Hash,
'mapPublicIpOnLaunch' => Fog::Boolean,
'defaultForAz' => Fog::Boolean,
} }
@single_subnet_format = { @single_subnet_format = {