mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
clean up conflict
This commit is contained in:
commit
a7a51ac961
28 changed files with 1481 additions and 9 deletions
|
@ -15,6 +15,8 @@ module Fog
|
|||
collection :flavors
|
||||
model :image
|
||||
collection :images
|
||||
model :internet_gateway
|
||||
collection :internet_gateways
|
||||
model :key_pair
|
||||
collection :key_pairs
|
||||
model :network_interface
|
||||
|
@ -40,9 +42,11 @@ module Fog
|
|||
request :allocate_address
|
||||
request :associate_address
|
||||
request :attach_network_interface
|
||||
request :attach_internet_gateway
|
||||
request :attach_volume
|
||||
request :authorize_security_group_ingress
|
||||
request :cancel_spot_instance_requests
|
||||
request :create_internet_gateway
|
||||
request :create_image
|
||||
request :create_key_pair
|
||||
request :create_network_interface
|
||||
|
@ -54,6 +58,7 @@ module Fog
|
|||
request :create_tags
|
||||
request :create_volume
|
||||
request :create_vpc
|
||||
request :delete_internet_gateway
|
||||
request :delete_key_pair
|
||||
request :delete_network_interface
|
||||
request :delete_security_group
|
||||
|
@ -69,6 +74,7 @@ module Fog
|
|||
request :describe_availability_zones
|
||||
request :describe_images
|
||||
request :describe_instances
|
||||
request :describe_internet_gateways
|
||||
request :describe_reserved_instances
|
||||
request :describe_instance_status
|
||||
request :describe_key_pairs
|
||||
|
@ -88,6 +94,7 @@ module Fog
|
|||
request :describe_volume_status
|
||||
request :describe_vpcs
|
||||
request :detach_network_interface
|
||||
request :detach_internet_gateway
|
||||
request :detach_volume
|
||||
request :disassociate_address
|
||||
request :get_console_output
|
||||
|
@ -177,6 +184,7 @@ module Fog
|
|||
:network_interfaces => {},
|
||||
:snapshots => {},
|
||||
:volumes => {},
|
||||
:internet_gateways => {},
|
||||
:tags => {},
|
||||
:tag_sets => Hash.new do |tag_set_hash, resource_id|
|
||||
tag_set_hash[resource_id] = {}
|
||||
|
|
|
@ -37,6 +37,9 @@ module Fog
|
|||
request :register_instances_with_load_balancer
|
||||
request :set_load_balancer_listener_ssl_certificate
|
||||
request :set_load_balancer_policies_of_listener
|
||||
request :attach_load_balancer_to_subnets
|
||||
request :detach_load_balancer_from_subnets
|
||||
request :apply_security_groups_to_load_balancer
|
||||
|
||||
model_path 'fog/aws/models/elb'
|
||||
model :load_balancer
|
||||
|
|
|
@ -31,5 +31,436 @@ class Fog::AWS::ELB::Mock
|
|||
"Description"=>""
|
||||
}],
|
||||
"PolicyTypeName"=>"PublicKeyPolicyType"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"Description" => "Listener policy that defines the ciphers and protocols that will be accepted by the load balancer. This policy can be associated only with HTTPS/SSL listeners.",
|
||||
"PolicyAttributeTypeDescriptions" => [{
|
||||
"AttributeName"=>"Protocol-SSLv2",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EDH-DSS-DES-CBC3-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-RSA-CAMELLIA128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DES-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-RC4-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-CAMELLIA128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"PSK-RC4-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"PSK-AES128-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-EDH-RSA-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"CAMELLIA128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-DSS-AES128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EDH-RSA-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-RSA-SEED-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-DES-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-RSA-CAMELLIA256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-DES-CBC3-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DES-CBC3-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-RC2-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EDH-DSS-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"PSK-AES256-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-AES256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-DES-CBC3-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"AES128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-DSS-SEED-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-CAMELLIA256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-RC4-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EDH-RSA-DES-CBC3-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-DES-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"Protocol-TLSv1",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"PSK-3DES-EDE-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"SEED-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-DSS-CAMELLIA256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"IDEA-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"RC2-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-AES128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"RC4-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"AES256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"Protocol-SSLv3",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DES-CBC3-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-RSA-AES128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-EDH-DSS-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-RC2-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-RSA-AES256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"KRB5-DES-CBC3-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"TRUE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-RC2-CBC-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-ADH-RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-RC4-MD5",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"CAMELLIA256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-DSS-CAMELLIA128-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-KRB5-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"EXP-ADH-DES-CBC-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"DHE-DSS-AES256-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
},
|
||||
{
|
||||
"AttributeName"=>"ADH-SEED-SHA",
|
||||
"AttributeType"=>"Boolean",
|
||||
"Cardinality"=>"ONE",
|
||||
"DefaultValue"=>"FALSE",
|
||||
"Description"=>""
|
||||
}],
|
||||
"PolicyTypeName"=>"SSLNegotiationPolicyType"
|
||||
}]
|
||||
end
|
||||
|
|
85
lib/fog/aws/models/compute/internet_gateway.rb
Normal file
85
lib/fog/aws/models/compute/internet_gateway.rb
Normal file
|
@ -0,0 +1,85 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
class InternetGateway < Fog::Model
|
||||
|
||||
identity :id, :aliases => 'internetGatewayId'
|
||||
attribute :attachment_set, :aliases => 'attachmentSet'
|
||||
attribute :tag_set, :aliases => 'tagSet'
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
# Attaches an existing internet gateway
|
||||
#
|
||||
# internet_gateway.attach(igw-id, vpc-id)
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# True or false depending on the result
|
||||
#
|
||||
def attach(vpc_id)
|
||||
requires :id
|
||||
connection.attach_internet_gateway(id, vpc_id)
|
||||
#reload
|
||||
end
|
||||
|
||||
# Detaches an existing internet gateway
|
||||
#
|
||||
# internet_gateway.detach(igw-id, vpc-id)
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# True or false depending on the result
|
||||
#
|
||||
|
||||
def detach(vpc_id)
|
||||
requires :id
|
||||
connection.detach_internet_gateway(id, vpc_id)
|
||||
reload
|
||||
end
|
||||
|
||||
|
||||
# Removes an existing internet gateway
|
||||
#
|
||||
# internet_gateway.destroy
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# True or false depending on the result
|
||||
#
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.delete_internet_gateway(id)
|
||||
true
|
||||
end
|
||||
|
||||
# Create an internet gateway
|
||||
#
|
||||
# >> g = AWS.internet_gateways.new()
|
||||
# >> g.save
|
||||
#
|
||||
# == Returns:
|
||||
#
|
||||
# requestId and a internetGateway object
|
||||
#
|
||||
|
||||
def save
|
||||
data = connection.create_internet_gateway.body['internetGatewaySet'].first
|
||||
puts data.inspect
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
true
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
91
lib/fog/aws/models/compute/internet_gateways.rb
Normal file
91
lib/fog/aws/models/compute/internet_gateways.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/aws/models/compute/internet_gateway'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
class InternetGateways < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Compute::AWS::InternetGateway
|
||||
|
||||
# Creates a new internet gateway
|
||||
#
|
||||
# AWS.internet_gateways.new
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new Subnet
|
||||
#
|
||||
#>> AWS.internet_gateways.new
|
||||
#=> <Fog::Compute::AWS::InternetGateway
|
||||
#id=nil,
|
||||
#attachment_set=nil,
|
||||
#tag_set=nil
|
||||
#>
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
# Returns an array of all InternetGateways that have been created
|
||||
#
|
||||
# AWS.internet_gateways.all
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns an array of all InternetGateways
|
||||
#
|
||||
#>> AWS.internet_gateways.all
|
||||
#<Fog::Compute::AWS::InternetGateways
|
||||
#filters={}
|
||||
#[
|
||||
#<Fog::Compute::AWS::InternetGateway
|
||||
#id="igw-some-id",
|
||||
#attachment_set={"vpcId"=>"vpc-some-id", "state"=>"available"},
|
||||
#tag_set={}
|
||||
#>
|
||||
#]
|
||||
#>
|
||||
#
|
||||
|
||||
def all(filters = filters)
|
||||
unless filters.is_a?(Hash)
|
||||
Fog::Logger.warning("all with #{filters.class} param is deprecated, use all('internet-gateway-id' => []) instead [light_black](#{caller.first})[/]")
|
||||
filters = {'subnet-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_internet_gateways(filters).body
|
||||
load(data['internetGatewaySet'])
|
||||
end
|
||||
|
||||
# Used to retrieve an InternetGateway
|
||||
#
|
||||
# You can run the following command to get the details:
|
||||
# AWS.internet_gateways.get("igw-12345678")
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>> AWS.internet_gateways.get("igw-12345678")
|
||||
#=> <Fog::Compute::AWS::InternetGateway
|
||||
#id="igw-12345678",
|
||||
#attachment_set={"vpcId"=>"vpc-12345678", "state"=>"available"},
|
||||
#tag_set={}
|
||||
#>
|
||||
#
|
||||
|
||||
def get(internet_gateway_id)
|
||||
if internet_gateway_id
|
||||
self.class.new(:connection => connection).all('internet-gateway-id' => internet_gateway_id).first
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,9 +14,16 @@ module Fog
|
|||
attribute :source_group, :aliases => 'SourceSecurityGroup'
|
||||
attribute :hosted_zone_name, :aliases => 'CanonicalHostedZoneName'
|
||||
attribute :hosted_zone_name_id, :aliases => 'CanonicalHostedZoneNameID'
|
||||
attribute :subnet_ids, :aliases => 'Subnets'
|
||||
attribute :security_groups, :aliases => 'SecurityGroups'
|
||||
attribute :vpc_id, :aliases => 'VPCId'
|
||||
|
||||
def initialize(attributes={})
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones'] || %w(us-east-1a us-east-1b us-east-1c us-east-1d)
|
||||
if attributes[:subnet_ids] ||= attributes['Subnets']
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones']
|
||||
else
|
||||
attributes[:availability_zones] ||= attributes['AvailabilityZones'] || %w(us-east-1a us-east-1b us-east-1c us-east-1d)
|
||||
end
|
||||
unless attributes['ListenerDescriptions']
|
||||
new_listener = Fog::AWS::ELB::Listener.new
|
||||
attributes['ListenerDescriptions'] = [{
|
||||
|
@ -53,6 +60,24 @@ module Fog
|
|||
data = connection.disable_availability_zones_for_load_balancer(zones, id).body['DisableAvailabilityZonesForLoadBalancerResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def attach_subnets(subnet_ids)
|
||||
requires :id
|
||||
data = connection.attach_load_balancer_to_subnets(subnet_ids, id).body['AttachLoadBalancerToSubnetsResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def detach_subnets(subnet_ids)
|
||||
requires :id
|
||||
data = connection.detach_load_balancer_from_subnets(subnet_ids, id).body['DetachLoadBalancerFromSubnetsResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def apply_security_groups(security_groups)
|
||||
requires :id
|
||||
data = connection.apply_security_groups_to_load_balancer(security_groups, id).body['ApplySecurityGroupsToLoadBalancerResult']
|
||||
merge_attributes(data)
|
||||
end
|
||||
|
||||
def instance_health
|
||||
requires :id
|
||||
|
@ -114,9 +139,15 @@ module Fog
|
|||
def save
|
||||
requires :id
|
||||
requires :listeners
|
||||
requires :availability_zones
|
||||
|
||||
connection.create_load_balancer(availability_zones, id, listeners.map{|l| l.to_params})
|
||||
# with the VPC release, the ELB can have either availability zones or subnets
|
||||
# if both are specified, the availability zones have preference
|
||||
#requires :availability_zones
|
||||
if (availability_zones || subnet_ids)
|
||||
connection.create_load_balancer(availability_zones, id, listeners.map{|l| l.to_params}) if availability_zones
|
||||
connection.create_load_balancer(nil, id, listeners.map{|l| l.to_params}, {:subnet_ids => subnet_ids, :security_groups => security_groups}) if subnet_ids && !availability_zones
|
||||
else
|
||||
throw Fog::Errors::Error.new("No availability zones or subnet ids specified")
|
||||
end
|
||||
|
||||
# reload instead of merge attributes b/c some attrs (like HealthCheck)
|
||||
# may be set, but only the DNS name is returned in the create_load_balance
|
||||
|
|
24
lib/fog/aws/parsers/compute/attach_internet_gateway.rb
Normal file
24
lib/fog/aws/parsers/compute/attach_internet_gateway.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class AttachInternetGateway < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
when 'return'
|
||||
if value == 'true'
|
||||
@response[name] = true
|
||||
else
|
||||
@response[name] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
65
lib/fog/aws/parsers/compute/create_internet_gateway.rb
Normal file
65
lib/fog/aws/parsers/compute/create_internet_gateway.rb
Normal file
|
@ -0,0 +1,65 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class CreateInternetGateway < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@internet_gateway = { 'attachmentSet' => {}, 'tagSet' => {} }
|
||||
@response = { 'internetGatewaySet' => [] }
|
||||
@tag = {}
|
||||
@attachment = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'tagSet'
|
||||
@in_tag_set = true
|
||||
when 'attachmentSet'
|
||||
@in_attachment_set = true
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if @in_tag_set
|
||||
case name
|
||||
when 'item'
|
||||
@vpc['tagSet'][@tag['key']] = @tag['value']
|
||||
@tag = {}
|
||||
when 'key', 'value'
|
||||
@tag[name] = value
|
||||
when 'tagSet'
|
||||
@in_tag_set = false
|
||||
end
|
||||
elsif @in_attachment_set
|
||||
case name
|
||||
when 'item'
|
||||
@internet_gateway['attachmentSet'][@attachment['key']] = @attachment['value']
|
||||
@attachment = {}
|
||||
when 'key', 'value'
|
||||
@attachment[name] = value
|
||||
when 'attachmentSet'
|
||||
@in_attachment_set = false
|
||||
end
|
||||
else
|
||||
case name
|
||||
when 'internetGatewayId'
|
||||
@internet_gateway[name] = value
|
||||
when 'internetGateway'
|
||||
@response['internetGatewaySet'] << @internet_gateway
|
||||
@internet_gateway = { 'tagSet' => {} }
|
||||
@internet_gateway = { 'attachmentSet' => {} }
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
24
lib/fog/aws/parsers/compute/delete_internet_gateway.rb
Normal file
24
lib/fog/aws/parsers/compute/delete_internet_gateway.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class DeleteInternetGateway < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
when 'return'
|
||||
if value == 'true'
|
||||
@response[name] = true
|
||||
else
|
||||
@response[name] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
65
lib/fog/aws/parsers/compute/describe_internet_gateways.rb
Normal file
65
lib/fog/aws/parsers/compute/describe_internet_gateways.rb
Normal file
|
@ -0,0 +1,65 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class DescribeInternetGateways < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@internet_gateway = { 'attachmentSet' => {}, 'tagSet' => {} }
|
||||
@response = { 'internetGatewaySet' => [] }
|
||||
@tag = {}
|
||||
@attachment = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'tagSet'
|
||||
@in_tag_set = true
|
||||
when 'attachmentSet'
|
||||
@in_attachment_set = true
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if @in_tag_set
|
||||
case name
|
||||
when 'item'
|
||||
@vpc['tagSet'][@tag['key']] = @tag['value']
|
||||
@tag = {}
|
||||
when 'key', 'value'
|
||||
@tag[name] = value
|
||||
when 'tagSet'
|
||||
@in_tag_set = false
|
||||
end
|
||||
elsif @in_attachment_set
|
||||
case name
|
||||
when 'item'
|
||||
@internet_gateway['attachmentSet']=@attachment
|
||||
@attachment = {}
|
||||
when 'vpcId', 'state'
|
||||
@attachment[name] = value
|
||||
when 'attachmentSet'
|
||||
@in_attachment_set = false
|
||||
end
|
||||
else
|
||||
case name
|
||||
when 'internetGatewayId'
|
||||
@internet_gateway[name] = value
|
||||
when 'item'
|
||||
@response['internetGatewaySet'] << @internet_gateway
|
||||
@internet_gateway = { 'tagSet' => {} }
|
||||
@internet_gateway = { 'attachmentSet' => {} }
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
24
lib/fog/aws/parsers/compute/detach_internet_gateway.rb
Normal file
24
lib/fog/aws/parsers/compute/detach_internet_gateway.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class DetachInternetGateway < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
when 'return'
|
||||
if value == 'true'
|
||||
@response[name] = true
|
||||
else
|
||||
@response[name] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module ELB
|
||||
|
||||
class ApplySecurityGroupsToLoadBalancer < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'ApplySecurityGroupsToLoadBalancerResult' => { 'SecurityGroups' => [] }, 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'member'
|
||||
@response['ApplySecurityGroupsToLoadBalancerResult']['SecurityGroups'] << value
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/aws/parsers/elb/attach_load_balancer_to_subnets.rb
Normal file
26
lib/fog/aws/parsers/elb/attach_load_balancer_to_subnets.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module ELB
|
||||
|
||||
class AttachLoadBalancerToSubnets < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'AttachLoadBalancerToSubnetsResult' => { 'Subnets' => [] }, 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'member'
|
||||
@response['AttachLoadBalancerToSubnetsResult']['Subnets'] << value
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
end
|
||||
|
||||
def reset_load_balancer
|
||||
@load_balancer = { 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {}, 'SourceSecurityGroup' => {} }
|
||||
@load_balancer = { 'Subnets' => [], 'SecurityGroups' => [], 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {}, 'SourceSecurityGroup' => {} }
|
||||
end
|
||||
|
||||
def reset_listener_description
|
||||
|
@ -34,6 +34,10 @@ module Fog
|
|||
@in_instances = true
|
||||
when 'AvailabilityZones'
|
||||
@in_availability_zones = true
|
||||
when 'SecurityGroups'
|
||||
@in_security_groups = true
|
||||
when 'Subnets'
|
||||
@in_subnets = true
|
||||
when 'PolicyNames'
|
||||
@in_policy_names = true
|
||||
when 'Policies'
|
||||
|
@ -52,6 +56,10 @@ module Fog
|
|||
@listener_description['PolicyNames'] << value
|
||||
elsif @in_availability_zones
|
||||
@load_balancer['AvailabilityZones'] << value
|
||||
elsif @in_security_groups
|
||||
@load_balancer['SecurityGroups'] << value
|
||||
elsif @in_subnets
|
||||
@load_balancer['Subnets'] << value
|
||||
elsif @in_listeners
|
||||
@load_balancer['ListenerDescriptions'] << @listener_description
|
||||
reset_listener_description
|
||||
|
@ -84,9 +92,15 @@ module Fog
|
|||
@in_instances = false
|
||||
when 'InstanceId'
|
||||
@load_balancer['Instances'] << value
|
||||
when 'VPCId'
|
||||
@load_balancer[name] = value
|
||||
|
||||
when 'AvailabilityZones'
|
||||
@in_availability_zones = false
|
||||
when 'SecurityGroups'
|
||||
@in_security_groups = false
|
||||
when 'Subnets'
|
||||
@in_subnets = false
|
||||
|
||||
when 'Policies'
|
||||
@in_policies = false
|
||||
|
|
26
lib/fog/aws/parsers/elb/detach_load_balancer_from_subnets.rb
Normal file
26
lib/fog/aws/parsers/elb/detach_load_balancer_from_subnets.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module ELB
|
||||
|
||||
class DetachLoadBalancerFromSubnets < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'DetachLoadBalancerFromSubnetsResult' => { 'Subnets' => [] }, 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'member'
|
||||
@response['DetachLoadBalancerFromSubnetsResult']['Subnets'] << value
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
56
lib/fog/aws/requests/compute/attach_internet_gateway.rb
Normal file
56
lib/fog/aws/requests/compute/attach_internet_gateway.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/attach_internet_gateway'
|
||||
# Attaches an Internet gateway to a VPC, enabling connectivity between the Internet and the VPC
|
||||
#
|
||||
# ==== Parameters
|
||||
# * internet_gateway_id<~String> - The ID of the Internet gateway to attach
|
||||
# * vpc_id<~String> - The ID of the VPC
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'return'<~Boolean> - Returns true if the request succeeds.
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachInternetGateway.html]
|
||||
def attach_internet_gateway(internet_gateway_id, vpc_id)
|
||||
request(
|
||||
'Action' => 'AttachInternetGateway',
|
||||
'InternetGatewayId' => internet_gateway_id,
|
||||
'VpcId' => vpc_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::AttachInternetGateway.new
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def attach_internet_gateway(internet_gateway_id, vpc_id)
|
||||
response = Excon::Response.new
|
||||
if internet_gateway_id && vpc_id
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
}
|
||||
response
|
||||
else
|
||||
if !internet_gateway_id
|
||||
message << 'The request must contain the parameter internet_gateway_id'
|
||||
elsif !vpc_id
|
||||
message << 'The request must contain the parameter vpc_id'
|
||||
end
|
||||
raise Fog::Compute::AWS::Error.new(message)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
51
lib/fog/aws/requests/compute/create_internet_gateway.rb
Normal file
51
lib/fog/aws/requests/compute/create_internet_gateway.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/create_internet_gateway'
|
||||
|
||||
# Creates an InternetGateway
|
||||
#
|
||||
# ==== Parameters
|
||||
# (none)
|
||||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'internetGateway'<~Array>:
|
||||
# * 'attachmentSet'<~Array>: A list of VPCs attached to the Internet gateway
|
||||
# * 'vpcId'<~String> - The ID of the VPC the Internet gateway is attached to.
|
||||
# * 'state'<~String> - The current state of the attachment.
|
||||
# * 'tagSet'<~Array>: Tags assigned to the resource.
|
||||
# * 'key'<~String> - Tag's key
|
||||
# * 'value'<~String> - Tag's value
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-InternetGatewayAttachmentType.html]
|
||||
def create_internet_gateway()
|
||||
request({
|
||||
'Action' => 'CreateInternetGateway',
|
||||
:parser => Fog::Parsers::Compute::AWS::CreateInternetGateway.new
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_internet_gateway()
|
||||
Excon::Response.new.tap do |response|
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'internetGatewaySet' => [
|
||||
'internetGatewayId' => Fog::AWS::Mock.request_id,
|
||||
'attachmentSet' => {},
|
||||
'tagSet' => {}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
48
lib/fog/aws/requests/compute/delete_internet_gateway.rb
Normal file
48
lib/fog/aws/requests/compute/delete_internet_gateway.rb
Normal file
|
@ -0,0 +1,48 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/delete_internet_gateway'
|
||||
#Deletes an Internet gateway from your AWS account. The gateway must not be attached to a VPC
|
||||
#
|
||||
# ==== Parameters
|
||||
# * internet_gateway_id<~String> - The ID of the InternetGateway you want to delete.
|
||||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'return'<~Boolean> - Returns true if the request succeeds.
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteInternetGateway.html]
|
||||
def delete_internet_gateway(internet_gateway_id)
|
||||
request(
|
||||
'Action' => 'DeleteInternetGateway',
|
||||
'InternetGatewayId' => internet_gateway_id,
|
||||
:parser => Fog::Parsers::Compute::AWS::DeleteInternetGateway.new
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_internet_gateway(internet_gateway_id)
|
||||
Excon::Response.new.tap do |response|
|
||||
if internet_gateway_id
|
||||
response.status = 200
|
||||
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
}
|
||||
else
|
||||
message = 'MissingParameter => '
|
||||
message << 'The request must contain the parameter internet_gateway_id'
|
||||
raise Fog::Compute::AWS::Error.new(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
61
lib/fog/aws/requests/compute/describe_internet_gateways.rb
Normal file
61
lib/fog/aws/requests/compute/describe_internet_gateways.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/describe_internet_gateways'
|
||||
|
||||
# Describe all or specified internet_gateways
|
||||
#
|
||||
# ==== Parameters
|
||||
# * filters<~Hash> - List of filters to limit results with
|
||||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'InternetGatewaySet'<~Array>:
|
||||
# * 'internetGatewayId'<~String> - The ID of the Internet gateway.
|
||||
# * 'attachmentSet'<~Array>: - A list of VPCs attached to the Internet gateway
|
||||
# * 'vpcId'<~String> - The ID of the VPC the Internet gateway is attached to
|
||||
# * 'state'<~String> - The current state of the attachment
|
||||
# * 'tagSet'<~Array>: Tags assigned to the resource.
|
||||
# * 'key'<~String> - Tag's key
|
||||
# * 'value'<~String> - Tag's value
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-InternetGatewayType.html]
|
||||
def describe_internet_gateways(filters = {})
|
||||
unless filters.is_a?(Hash)
|
||||
Fog::Logger.warning("describe_internet_gateways with #{filters.class} param is deprecated, use internet_gateways('internet-gateway-id' => []) instead [light_black](#{caller.first})[/]")
|
||||
filters = {'internet-gateway-id' => [*filters]}
|
||||
end
|
||||
params = Fog::AWS.indexed_filters(filters)
|
||||
request({
|
||||
'Action' => 'DescribeInternetGateways',
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::DescribeInternetGateways.new
|
||||
}.merge!(params))
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def describe_internet_gateways(filters = {})
|
||||
Excon::Response.new.tap do |response|
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'internetGatewaySet' => [
|
||||
'internetGatewayId' => Fog::AWS::Mock.request_id,
|
||||
'attachmentSet' => {
|
||||
'vpcId' => Fog::AWS::Mock.request_id,
|
||||
'state' => 'pending',
|
||||
},
|
||||
'tagSet' => {}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
56
lib/fog/aws/requests/compute/detach_internet_gateway.rb
Normal file
56
lib/fog/aws/requests/compute/detach_internet_gateway.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/detach_internet_gateway'
|
||||
# Detaches an Internet gateway to a VPC, enabling connectivity between the Internet and the VPC
|
||||
#
|
||||
# ==== Parameters
|
||||
# * internet_gateway_id<~String> - The ID of the Internet gateway to detach
|
||||
# * vpc_id<~String> - The ID of the VPC
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'return'<~Boolean> - Returns true if the request succeeds.
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DetachInternetGateway.html]
|
||||
def detach_internet_gateway(internet_gateway_id, vpc_id)
|
||||
request(
|
||||
'Action' => 'DetachInternetGateway',
|
||||
'InternetGatewayId' => internet_gateway_id,
|
||||
'VpcId' => vpc_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::DetachInternetGateway.new
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def detach_internet_gateway(internet_gateway_id, vpc_id)
|
||||
response = Excon::Response.new
|
||||
if internet_gateway_id && vpc_id
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
}
|
||||
response
|
||||
else
|
||||
if !internet_gateway_id
|
||||
message << 'The request must contain the parameter internet_gateway_id'
|
||||
elsif !vpc_id
|
||||
message << 'The request must contain the parameter vpc_id'
|
||||
end
|
||||
raise Fog::Compute::AWS::Error.new(message)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/apply_security_groups_to_load_balancer'
|
||||
|
||||
# Sets the security groups for an ELB in VPC
|
||||
#
|
||||
# ==== Parameters
|
||||
# * security_group_ids<~Array> - List of security group ids to enable on ELB
|
||||
# * lb_name<~String> - Load balancer to disable availability zones on
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'ResponseMetadata'<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of request
|
||||
# * 'ApplySecurityGroupsToLoadBalancer'<~Hash>:
|
||||
# * 'SecurityGroups'<~Array> - array of strings describing the security group ids currently enabled
|
||||
def apply_security_groups_to_load_balancer(security_group_ids, lb_name)
|
||||
params = Fog::AWS.indexed_param('SecurityGroups.member', [*security_group_ids])
|
||||
request({
|
||||
'Action' => 'ApplySecurityGroupsToLoadBalancer',
|
||||
'LoadBalancerName' => lb_name,
|
||||
:parser => Fog::Parsers::AWS::ELB::ApplySecurityGroupsToLoadBalancer.new
|
||||
}.merge!(params))
|
||||
end
|
||||
|
||||
alias :apply_security_groups :apply_security_groups_to_load_balancer
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def apply_security_groups_to_load_balancer(security_group_ids, lb_name)
|
||||
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
load_balancer['SecurityGroups'] << security_group_ids
|
||||
load_balancer['SecurityGroups'].flatten!.uniq!
|
||||
|
||||
response.body = {
|
||||
'ResponseMetadata' => {
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
},
|
||||
'DetachLoadBalancerFromSubnetsResult' => {
|
||||
'SecurityGroups' => load_balancer['SecurityGroups']
|
||||
}
|
||||
}
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
alias :apply_security_groups :apply_security_groups_to_load_balancer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
61
lib/fog/aws/requests/elb/attach_load_balancer_to_subnets.rb
Normal file
61
lib/fog/aws/requests/elb/attach_load_balancer_to_subnets.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/attach_load_balancer_to_subnets'
|
||||
|
||||
# Enable a subnet for an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
# * subnet_ids<~Array> - List of subnet ids to enable on ELB
|
||||
# * lb_name<~String> - Load balancer to enable availability zones on
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'ResponseMetadata'<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of request
|
||||
# * 'AttachLoadBalancerToSubnetsResult'<~Hash>:
|
||||
# * 'Subnets'<~Array> - array of strings describing the subnet ids currently enabled
|
||||
def attach_load_balancer_to_subnets(subnet_ids, lb_name)
|
||||
params = Fog::AWS.indexed_param('Subnets.member', [*subnet_ids])
|
||||
request({
|
||||
'Action' => 'AttachLoadBalancerToSubnets',
|
||||
'LoadBalancerName' => lb_name,
|
||||
:parser => Fog::Parsers::AWS::ELB::AttachLoadBalancerToSubnets.new
|
||||
}.merge!(params))
|
||||
end
|
||||
|
||||
alias :enable_subnets :attach_load_balancer_to_subnets
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def attach_load_balancer_to_subnets(subnet_ids, lb_name)
|
||||
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
load_balancer['Subnets'] << subnet_ids
|
||||
load_balancer['Subnets'].flatten!.uniq!
|
||||
|
||||
response.body = {
|
||||
'ResponseMetadata' => {
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
},
|
||||
'AttachLoadBalancerToSubnetsResult' => {
|
||||
'Subnets' => load_balancer['Subnets']
|
||||
}
|
||||
}
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
alias :enable_subnets :attach_load_balancer_to_subnets
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -23,8 +23,10 @@ module Fog
|
|||
# * 'RequestId'<~String> - Id of request
|
||||
# * 'CreateLoadBalancerResult'<~Hash>:
|
||||
# * 'DNSName'<~String> - DNS name for the newly created ELB
|
||||
def create_load_balancer(availability_zones, lb_name, listeners)
|
||||
def create_load_balancer(availability_zones, lb_name, listeners, options = {})
|
||||
params = Fog::AWS.indexed_param('AvailabilityZones.member', [*availability_zones])
|
||||
params.merge!(Fog::AWS.indexed_param('Subnets.member.%d', options[:subnet_ids]))
|
||||
params.merge!(Fog::AWS.indexed_param('SecurityGroups.member.%d', options[:security_groups]))
|
||||
|
||||
listener_protocol = []
|
||||
listener_lb_port = []
|
||||
|
@ -54,7 +56,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
def create_load_balancer(availability_zones, lb_name, listeners = [])
|
||||
def create_load_balancer(availability_zones, lb_name, listeners = [], options = {})
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
|
@ -72,6 +74,8 @@ module Fog
|
|||
dns_name = Fog::AWS::ELB::Mock.dns_name(lb_name, @region)
|
||||
self.data[:load_balancers][lb_name] = {
|
||||
'AvailabilityZones' => availability_zones,
|
||||
'Subnets' => options[:subnet_ids],
|
||||
'SecurityGroups' => options[:security_groups],
|
||||
'CanonicalHostedZoneName' => '',
|
||||
'CanonicalHostedZoneNameID' => '',
|
||||
'CreatedTime' => Time.now,
|
||||
|
@ -96,7 +100,6 @@ module Fog
|
|||
'OwnerAlias' => ''
|
||||
}
|
||||
}
|
||||
|
||||
response.body = {
|
||||
'ResponseMetadata' => {
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class ELB
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elb/detach_load_balancer_from_subnets'
|
||||
|
||||
# Disable a subnet for an existing ELB
|
||||
#
|
||||
# ==== Parameters
|
||||
# * subnet_ids<~Array> - List of subnet ids to enable on ELB
|
||||
# * lb_name<~String> - Load balancer to disable availability zones on
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'ResponseMetadata'<~Hash>:
|
||||
# * 'RequestId'<~String> - Id of request
|
||||
# * 'DetachLoadBalancerFromSubnetsResult'<~Hash>:
|
||||
# * 'Subnets'<~Array> - array of strings describing the subnet ids currently enabled
|
||||
def detach_load_balancer_from_subnets(subnet_ids, lb_name)
|
||||
params = Fog::AWS.indexed_param('Subnets.member', [*subnet_ids])
|
||||
request({
|
||||
'Action' => 'DetachLoadBalancerFromSubnets',
|
||||
'LoadBalancerName' => lb_name,
|
||||
:parser => Fog::Parsers::AWS::ELB::DetachLoadBalancerFromSubnets.new
|
||||
}.merge!(params))
|
||||
end
|
||||
|
||||
alias :disable_subnets :detach_load_balancer_from_subnets
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def detach_load_balancer_from_subnets(subnet_ids, lb_name)
|
||||
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
load_balancer['Subnets'] << subnet_ids
|
||||
load_balancer['Subnets'].flatten!.uniq!
|
||||
|
||||
response.body = {
|
||||
'ResponseMetadata' => {
|
||||
'RequestId' => Fog::AWS::Mock.request_id
|
||||
},
|
||||
'DetachLoadBalancerFromSubnetsResult' => {
|
||||
'Subnets' => load_balancer['Subnets']
|
||||
}
|
||||
}
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
alias :disable_subnets :detach_load_balancer_from_subnets
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
tests/aws/models/compute/internet_gateway_tests.rb
Normal file
3
tests/aws/models/compute/internet_gateway_tests.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
Shindo.tests("Fog::Compute[:aws] | internet_gateway", ['aws']) do
|
||||
model_tests(Fog::Compute[:aws].internet_gateways , {}, true)
|
||||
end
|
4
tests/aws/models/compute/internet_gateways_tests.rb
Normal file
4
tests/aws/models/compute/internet_gateways_tests.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
Shindo.tests("Fog::Compute[:aws] | internet_gateways", ['aws']) do
|
||||
collection_tests(Fog::Compute[:aws].internet_gateways, {}, true)
|
||||
end
|
||||
|
|
@ -2,6 +2,14 @@ Shindo.tests('AWS::ELB | models', ['aws', 'elb']) do
|
|||
require 'fog'
|
||||
@availability_zones = Fog::Compute[:aws].describe_availability_zones('state' => 'available').body['availabilityZoneInfo'].collect{ |az| az['zoneName'] }
|
||||
@key_name = 'fog-test-model'
|
||||
@vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
|
||||
@vpc_id = @vpc.id
|
||||
@subnet = Fog::Compute[:aws].subnets.create({:vpc_id => @vpc_id, :cidr_block => '10.0.10.0/24'})
|
||||
@subnet_id = @subnet.subnet_id
|
||||
@igw=Fog::Compute[:aws].internet_gateways.create
|
||||
@igw_id = @igw.id
|
||||
@igw.attach(@vpc_id)
|
||||
|
||||
|
||||
tests('success') do
|
||||
tests('load_balancers') do
|
||||
|
@ -46,6 +54,18 @@ Shindo.tests('AWS::ELB | models', ['aws', 'elb']) do
|
|||
tests("params").returns(Fog::AWS[:elb].listeners.new.to_params) { elb.listeners.first.to_params }
|
||||
end
|
||||
end
|
||||
tests('with vpc') do
|
||||
elb2 = Fog::AWS[:elb].load_balancers.create(:id => "#{elb_id}-2", :subnet_ids => [@subnet_id])
|
||||
tests("subnet ids are correct").returns(@subnet_id) { elb2.subnet_ids.first }
|
||||
elb2.destroy
|
||||
end
|
||||
if !Fog.mocking?
|
||||
@igw.detach(@vpc_id)
|
||||
@igw.destroy
|
||||
@subnet.destroy
|
||||
sleep 5
|
||||
@vpc.destroy
|
||||
end
|
||||
|
||||
tests('with availability zones') do
|
||||
azs = @availability_zones[1..-1]
|
||||
|
|
44
tests/aws/requests/compute/internet_gateway_tests.rb
Normal file
44
tests/aws/requests/compute/internet_gateway_tests.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
Shindo.tests('Fog::Compute[:aws] | internet_gateway requests', ['aws']) do
|
||||
|
||||
@internet_gateways_format = {
|
||||
'internetGatewaySet' => [{
|
||||
'internetGatewayId' => String,
|
||||
'attachmentSet' => Hash,
|
||||
'tagSet' => Fog::Nullable::Hash,
|
||||
}],
|
||||
'requestId' => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
@vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
|
||||
@vpc_id = @vpc.id
|
||||
@subnet=Fog::Compute[:aws].subnets.create('vpc_id' => @vpc_id, 'cidr_block' => '10.0.10.0/24')
|
||||
@subnet_id = @subnet.subnet_id
|
||||
@igw_id = nil
|
||||
|
||||
|
||||
tests('#create_internet_gateway').formats(@internet_gateways_format) do
|
||||
data = Fog::Compute[:aws].create_internet_gateway().body
|
||||
@igw_id = data['internetGatewaySet'].first['internetGatewayId']
|
||||
data
|
||||
end
|
||||
|
||||
tests('#describe_internet_gateways').formats(@internet_gateways_format) do
|
||||
Fog::Compute[:aws].describe_internet_gateways.body
|
||||
end
|
||||
|
||||
tests("#attach_internet_gateway('#{@igw_id}, #{@vpc_id}')").formats(AWS::Compute::Formats::BASIC) do
|
||||
Fog::Compute[:aws].attach_internet_gateway(@igw_id, @vpc_id).body
|
||||
end
|
||||
|
||||
tests("#detach_internet_gateway('#{@igw_id}, #{@vpc_id}')").formats(AWS::Compute::Formats::BASIC) do
|
||||
Fog::Compute[:aws].detach_internet_gateway(@igw_id, @vpc_id).body
|
||||
end
|
||||
|
||||
tests("#delete_internet_gateway('#{@igw_id}')").formats(AWS::Compute::Formats::BASIC) do
|
||||
Fog::Compute[:aws].delete_internet_gateway(@igw_id).body
|
||||
end
|
||||
@subnet.destroy
|
||||
@vpc.destroy
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue