2013-04-10 21:44:13 -04:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class AWS
|
|
|
|
class Real
|
|
|
|
|
|
|
|
require 'fog/aws/parsers/compute/create_route_table'
|
|
|
|
|
2013-08-06 10:47:47 -04:00
|
|
|
# Creates a route table for the specified VPC.
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
|
|
|
# ==== Parameters
|
2013-08-06 10:47:47 -04:00
|
|
|
# * VpcId<~String> - The ID of the VPC.
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
|
|
|
# === Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
2013-08-06 10:47:47 -04:00
|
|
|
# * 'requestId'<~String> - Id of the request
|
|
|
|
# * 'routeTableSet'<~Array> - Information about the newly created route table
|
|
|
|
# * 'routeTableId'<~String>
|
|
|
|
# * 'vpcId'<~String>
|
|
|
|
# * 'routeSet'<~Array>
|
|
|
|
# * 'item'<~Array>
|
|
|
|
# * 'destinationCidrBlock'<~String> - The CIDR address block used for the destination match.
|
|
|
|
# * 'gatewayId'<~String> - The ID of an Internet gateway attached to your VPC.
|
|
|
|
# * 'state'<~String> - The current state of the route table. ['pending', 'available']
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
2013-08-06 10:47:47 -04:00
|
|
|
# {Amazon API Reference}[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-CreateRouteTable.html]
|
|
|
|
def create_route_table(vpc_id)
|
2013-04-10 21:44:13 -04:00
|
|
|
request({
|
|
|
|
'Action' => 'CreateRouteTable',
|
|
|
|
'VpcId' => vpc_id,
|
|
|
|
:parser => Fog::Parsers::Compute::AWS::CreateRouteTable.new
|
2013-08-06 10:47:47 -04:00
|
|
|
})
|
2013-04-10 21:44:13 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
2013-08-06 10:47:47 -04:00
|
|
|
def create_route_table(vpc_id)
|
|
|
|
response = Excon::Response.new
|
|
|
|
vpc = self.data[:vpcs].find { |vpc| vpc["vpcId"].eql? vpc_id }
|
|
|
|
unless vpc.nil?
|
|
|
|
response.status = 200
|
|
|
|
self.data[:route_tables].push({
|
|
|
|
'routeTableId' => "rtb-#{Fog::Mock.random_hex(8)}",
|
|
|
|
'vpcId' => vpc["vpcId"],
|
|
|
|
'routeSet' => {
|
|
|
|
'item' => {
|
|
|
|
"destinationCidrBlock" => vpc["cidrBlock"],
|
|
|
|
"gatewayId" => "local",
|
|
|
|
"state" => "pending"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'associationSet' => {},
|
2013-08-16 10:15:06 -04:00
|
|
|
'tagSet' => {}
|
2013-08-06 10:47:47 -04:00
|
|
|
})
|
|
|
|
response.body = {
|
2013-08-16 10:15:06 -04:00
|
|
|
'requestId'=> Fog::AWS::Mock.request_id,
|
|
|
|
'routeTableSet' => self.data[:route_tables]
|
|
|
|
}
|
2013-08-06 10:47:47 -04:00
|
|
|
response
|
|
|
|
else
|
|
|
|
raise Fog::Compute::AWS::NotFound.new("The vpc ID '#{vpc_id }' does not exist")
|
|
|
|
end
|
2013-08-16 10:15:06 -04:00
|
|
|
end
|
2013-04-10 21:44:13 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|