diff --git a/lib/fog/aws/models/compute/subnet.rb b/lib/fog/aws/models/compute/subnet.rb index 1be361e33..cb0a9a935 100644 --- a/lib/fog/aws/models/compute/subnet.rb +++ b/lib/fog/aws/models/compute/subnet.rb @@ -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 diff --git a/lib/fog/aws/parsers/compute/create_subnet.rb b/lib/fog/aws/parsers/compute/create_subnet.rb index 226ba0612..d1f831e55 100644 --- a/lib/fog/aws/parsers/compute/create_subnet.rb +++ b/lib/fog/aws/parsers/compute/create_subnet.rb @@ -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' diff --git a/lib/fog/aws/parsers/compute/describe_subnets.rb b/lib/fog/aws/parsers/compute/describe_subnets.rb index 4447aa63b..ed347df74 100644 --- a/lib/fog/aws/parsers/compute/describe_subnets.rb +++ b/lib/fog/aws/parsers/compute/describe_subnets.rb @@ -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 diff --git a/lib/fog/aws/requests/compute/create_subnet.rb b/lib/fog/aws/requests/compute/create_subnet.rb index c061fcccf..8af7ac7e0 100644 --- a/lib/fog/aws/requests/compute/create_subnet.rb +++ b/lib/fog/aws/requests/compute/create_subnet.rb @@ -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 diff --git a/lib/fog/aws/requests/compute/describe_subnets.rb b/lib/fog/aws/requests/compute/describe_subnets.rb index f48967f9e..ff7554d94 100644 --- a/lib/fog/aws/requests/compute/describe_subnets.rb +++ b/lib/fog/aws/requests/compute/describe_subnets.rb @@ -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 = {}) diff --git a/tests/requests/compute/subnet_tests.rb b/tests/requests/compute/subnet_tests.rb index 201658eda..1b7d59c6d 100644 --- a/tests/requests/compute/subnet_tests.rb +++ b/tests/requests/compute/subnet_tests.rb @@ -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