mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
this adds the dhcp_options object and associated operations
This commit is contained in:
parent
8d95d5bff2
commit
efa20d8a37
15 changed files with 627 additions and 4 deletions
|
@ -237,6 +237,18 @@ module Fog
|
|||
def self.network_interface_id
|
||||
"eni-#{Fog::Mock.random_hex(8)}"
|
||||
end
|
||||
def self.internet_gateway_id
|
||||
"igw-#{Fog::Mock.random_hex(8)}"
|
||||
end
|
||||
def self.dhcp_options_id
|
||||
"dopt-#{Fog::Mock.random_hex(8)}"
|
||||
end
|
||||
def self.vpc_id
|
||||
"vpc-#{Fog::Mock.random_hex(8)}"
|
||||
end
|
||||
def self.subnet_id
|
||||
"subnet-#{Fog::Mock.random_hex(8)}"
|
||||
end
|
||||
|
||||
def self.key_id(length=21)
|
||||
#Probably close enough
|
||||
|
|
|
@ -11,6 +11,8 @@ module Fog
|
|||
model_path 'fog/aws/models/compute'
|
||||
model :address
|
||||
collection :addresses
|
||||
model :dhcp_options
|
||||
collection :dhcp_options
|
||||
model :flavor
|
||||
collection :flavors
|
||||
model :image
|
||||
|
@ -41,11 +43,13 @@ module Fog
|
|||
request_path 'fog/aws/requests/compute'
|
||||
request :allocate_address
|
||||
request :associate_address
|
||||
request :associate_dhcp_options
|
||||
request :attach_network_interface
|
||||
request :attach_internet_gateway
|
||||
request :attach_volume
|
||||
request :authorize_security_group_ingress
|
||||
request :cancel_spot_instance_requests
|
||||
request :create_dhcp_options
|
||||
request :create_internet_gateway
|
||||
request :create_image
|
||||
request :create_key_pair
|
||||
|
@ -58,6 +62,7 @@ module Fog
|
|||
request :create_tags
|
||||
request :create_volume
|
||||
request :create_vpc
|
||||
request :delete_dhcp_options
|
||||
request :delete_internet_gateway
|
||||
request :delete_key_pair
|
||||
request :delete_network_interface
|
||||
|
@ -72,6 +77,7 @@ module Fog
|
|||
request :deregister_image
|
||||
request :describe_addresses
|
||||
request :describe_availability_zones
|
||||
request :describe_dhcp_options
|
||||
request :describe_images
|
||||
request :describe_instances
|
||||
request :describe_internet_gateways
|
||||
|
|
68
lib/fog/aws/models/compute/dhcp_option.rb
Normal file
68
lib/fog/aws/models/compute/dhcp_option.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
class DhcpOption < Fog::Model
|
||||
|
||||
identity :id, :aliases => 'dhcpOptionsId'
|
||||
attribute :dhcp_configuration_set, :aliases => 'dhcpConfigurationSet'
|
||||
attribute :tag_set, :aliases => 'tagSet'
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
# Associates an existing dhcp configration set with a VPC
|
||||
#
|
||||
# dhcp_option.attach(dopt-id, vpc-id)
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# True or false depending on the result
|
||||
#
|
||||
def associate(vpc_id)
|
||||
requires :id
|
||||
connection.attach_dhcp_option(id, vpc_id)
|
||||
#reload
|
||||
end
|
||||
|
||||
# Removes an existing dhcp configuration set
|
||||
#
|
||||
# dhcp_option.destroy
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# True or false depending on the result
|
||||
#
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_dhcp_options(id)
|
||||
true
|
||||
end
|
||||
|
||||
# Create a dhcp configuration set
|
||||
#
|
||||
# >> g = AWS.dhcp_options.new()
|
||||
# >> g.save
|
||||
#
|
||||
# == Returns:
|
||||
#
|
||||
# requestId and a dhcpOptions object
|
||||
#
|
||||
|
||||
def save
|
||||
requires :dhcp_configuration_set
|
||||
data = connection.create_dhcp_options(dhcp_configuration_set).body['dhcpOptionsSet'].first
|
||||
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/dhcp_options.rb
Normal file
91
lib/fog/aws/models/compute/dhcp_options.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/aws/models/compute/dhcp_option'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
|
||||
class DhcpOptions < Fog::Collection
|
||||
|
||||
attribute :filters
|
||||
|
||||
model Fog::Compute::AWS::DhcpOption
|
||||
|
||||
# Creates a new dhcp option
|
||||
#
|
||||
# AWS.dhcp_options.new
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new DHCP options
|
||||
#
|
||||
#>> AWS.dhcp_options.new
|
||||
#=> <Fog::Compute::AWS::DhcpOption
|
||||
#id=nil,
|
||||
#dhcp_configuration_set=nil,
|
||||
#tag_set=nil
|
||||
#>
|
||||
#
|
||||
|
||||
def initialize(attributes)
|
||||
self.filters ||= {}
|
||||
super
|
||||
end
|
||||
|
||||
# Returns an array of all DhcpOptions that have been created
|
||||
#
|
||||
# AWS.dhcp_options.all
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns an array of all DhcpOptions
|
||||
#
|
||||
#>> AWS.dhcp_options.all
|
||||
#<Fog::Compute::AWS::DhcpOptions
|
||||
#filters={}
|
||||
#[
|
||||
#<Fog::Compute::AWS::DhcpOption
|
||||
#id="dopt-some-id",
|
||||
#dhcp_configuration_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 = {'dhcp-options-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_dhcp_options(filters).body
|
||||
load(data['dhcpOptionsSet'])
|
||||
end
|
||||
|
||||
# Used to retrieve an DhcpOption
|
||||
#
|
||||
# You can run the following command to get the details:
|
||||
# AWS.dhcp_options.get("dopt-12345678")
|
||||
#
|
||||
# ==== Returns
|
||||
#
|
||||
#>> AWS.dhcp_options.get("dopt-12345678")
|
||||
#=> <Fog::Compute::AWS::DhcpOption
|
||||
#id="dopt-12345678",
|
||||
#dhcp_configuration_set={"vpcId"=>"vpc-12345678", "state"=>"available"},
|
||||
#tag_set={}
|
||||
#>
|
||||
#
|
||||
|
||||
def get(dhcp_options_id)
|
||||
if dhcp_options_id
|
||||
self.class.new(:connection => connection).all('dhcp-options-id' => dhcp_options_id).first
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -72,7 +72,6 @@ module Fog
|
|||
|
||||
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
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
#
|
||||
# ==== Returns
|
||||
#
|
||||
# Returns the details of the new Subnet
|
||||
# Returns the details of the new InternetGateway
|
||||
#
|
||||
#>> AWS.internet_gateways.new
|
||||
#=> <Fog::Compute::AWS::InternetGateway
|
||||
|
@ -56,7 +56,7 @@ module Fog
|
|||
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]}
|
||||
filters = {'internet-gateway-id' => [*filters]}
|
||||
end
|
||||
self.filters = filters
|
||||
data = connection.describe_internet_gateways(filters).body
|
||||
|
|
24
lib/fog/aws/parsers/compute/associate_dhcp_options.rb
Normal file
24
lib/fog/aws/parsers/compute/associate_dhcp_options.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class AssociateDhcpOptions < 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
|
75
lib/fog/aws/parsers/compute/create_dhcp_options.rb
Normal file
75
lib/fog/aws/parsers/compute/create_dhcp_options.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class CreateDhcpOptions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@dhcp_options = { 'dhcpConfigurationSet' => {}, 'tagSet' => {} }
|
||||
@response = { 'dhcpOptionsSet' => [] }
|
||||
@tag = {}
|
||||
@value_set = []
|
||||
@dhcp_configuration = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'tagSet'
|
||||
@in_tag_set = true
|
||||
when 'dhcpConfigurationSet'
|
||||
@in_dhcp_configuration_set = true
|
||||
when 'valueSet'
|
||||
@in_value_set = true
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if @in_tag_set
|
||||
case name
|
||||
when 'item'
|
||||
@dhcp_options['tagSet'][@tag['key']] = @tag['value']
|
||||
@tag = {}
|
||||
when 'key', 'value'
|
||||
@tag[name] = value
|
||||
when 'tagSet'
|
||||
@in_tag_set = false
|
||||
end
|
||||
elsif @in_dhcp_configuration_set
|
||||
case name
|
||||
when 'item'
|
||||
unless @in_value_set
|
||||
@dhcp_options['dhcpConfigurationSet'][@dhcp_configuration['key']] = @value_set
|
||||
@value_set=[]
|
||||
@dhcp_configuration = {}
|
||||
end
|
||||
when 'key', 'value'
|
||||
if !@in_value_set
|
||||
@dhcp_configuration[name] = value
|
||||
else
|
||||
@value_set << value
|
||||
end
|
||||
when 'valueSet'
|
||||
@in_value_set = false
|
||||
when 'dhcpConfigurationSet'
|
||||
@in_dhcp_configuration_set = false
|
||||
end
|
||||
else
|
||||
case name
|
||||
when 'dhcpOptionsId'
|
||||
@dhcp_options[name] = value
|
||||
when 'dhcpOptions'
|
||||
@response['dhcpOptionsSet'] << @dhcp_options
|
||||
@dhcp_options = { 'tagSet' => {} }
|
||||
@dhcp_options = { 'dhcpOptionsSet' => {} }
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/fog/aws/parsers/compute/delete_dhcp_options.rb
Normal file
24
lib/fog/aws/parsers/compute/delete_dhcp_options.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class DeleteDhcpOptions < 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
|
75
lib/fog/aws/parsers/compute/describe_dhcp_options.rb
Normal file
75
lib/fog/aws/parsers/compute/describe_dhcp_options.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Compute
|
||||
module AWS
|
||||
|
||||
class DescribeDhcpOptions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@dhcp_options = { 'dhcpConfigurationSet' => {}, 'tagSet' => {} }
|
||||
@response = { 'dhcpOptionsSet' => [] }
|
||||
@tag = {}
|
||||
@value_set = []
|
||||
@dhcp_configuration = {}
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
case name
|
||||
when 'tagSet'
|
||||
@in_tag_set = true
|
||||
when 'dhcpConfigurationSet'
|
||||
@in_dhcp_configuration_set = true
|
||||
when 'valueSet'
|
||||
@in_value_set = true
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if @in_tag_set
|
||||
case name
|
||||
when 'item'
|
||||
@dhcp_options['tagSet'][@tag['key']] = @tag['value']
|
||||
@tag = {}
|
||||
when 'key', 'value'
|
||||
@tag[name] = value
|
||||
when 'tagSet'
|
||||
@in_tag_set = false
|
||||
end
|
||||
elsif @in_dhcp_configuration_set
|
||||
case name
|
||||
when 'item'
|
||||
unless @in_value_set
|
||||
@dhcp_options['dhcpConfigurationSet'][@dhcp_configuration['key']] = @value_set
|
||||
@value_set=[]
|
||||
@dhcp_configuration = {}
|
||||
end
|
||||
when 'key', 'value'
|
||||
if !@in_value_set
|
||||
@dhcp_configuration[name] = value
|
||||
else
|
||||
@value_set << value
|
||||
end
|
||||
when 'valueSet'
|
||||
@in_value_set = false
|
||||
when 'dhcpConfigurationSet'
|
||||
@in_dhcp_configuration_set = false
|
||||
end
|
||||
else
|
||||
case name
|
||||
when 'dhcpOptionsId'
|
||||
@dhcp_options[name] = value
|
||||
when 'item'
|
||||
@response['dhcpOptionsSet'] << @dhcp_options
|
||||
@dhcp_options = { 'tagSet' => {} }
|
||||
@dhcp_options = { 'dhcpConfigurationSet' => {} }
|
||||
when 'requestId'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
57
lib/fog/aws/requests/compute/associate_dhcp_options.rb
Normal file
57
lib/fog/aws/requests/compute/associate_dhcp_options.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/associate_dhcp_options'
|
||||
#
|
||||
#
|
||||
# ==== Parameters
|
||||
# * dhcp_options_id<~String> - The ID of the DHCP options you want to associate with the VPC, or "default" if you want the VPC
|
||||
# to use no DHCP options.
|
||||
# * 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-AssociateDhcpOptions.html]
|
||||
def associate_dhcp_options(dhcp_options_id, vpc_id)
|
||||
request(
|
||||
'Action' => 'AssociateDhcpOptions',
|
||||
'DhcpOptionsId' => dhcp_options_id,
|
||||
'VpcId' => vpc_id,
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::AttachInternetGateway.new
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def associate_dhcp_options(dhcp_options_id, vpc_id)
|
||||
response = Excon::Response.new
|
||||
if dhcp_options_id && vpc_id
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
}
|
||||
response
|
||||
else
|
||||
if !dhcp_options_id
|
||||
message << 'The request must contain the parameter dhcp_options_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
|
75
lib/fog/aws/requests/compute/create_dhcp_options.rb
Normal file
75
lib/fog/aws/requests/compute/create_dhcp_options.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/create_dhcp_options'
|
||||
|
||||
# Creates a set of DHCP options for your VPC
|
||||
#
|
||||
# ==== Parameters
|
||||
# * DhcpConfigurationOptions<~Hash> - hash of key value dhcp options to assign
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
#
|
||||
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateDhcpOptions.html]
|
||||
def create_dhcp_options(dhcp_configurations = {})
|
||||
params = {}
|
||||
params.merge!(indexed_multidimensional_params(dhcp_configurations))
|
||||
request({
|
||||
'Action' => 'CreateDhcpOptions',
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::CreateDhcpOptions.new
|
||||
}.merge!(params))
|
||||
end
|
||||
private
|
||||
def indexed_multidimensional_params(multi_params)
|
||||
params = {}
|
||||
multi_params.keys.each_with_index do |key, key_index|
|
||||
key_index += 1
|
||||
params[format('DhcpConfiguration.%d.Key', key_index)] = key
|
||||
[*multi_params[key]].each_with_index do |value, value_index|
|
||||
value_index += 1
|
||||
params[format('DhcpConfiguration.%d.Value.%d', key_index, value_index)] = value
|
||||
end
|
||||
end
|
||||
params
|
||||
end
|
||||
end
|
||||
class Mock
|
||||
def create_dhcp_options(dhcp_configurations = {})
|
||||
params = {}
|
||||
params.merge!(indexed_multidimensional_params(dhcp_configurations))
|
||||
Excon::Response.new.tap do |response|
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'dhcpOptionsSet' => [
|
||||
'dhcpOptionsId' => Fog::AWS::Mock.dhcp_options_id,
|
||||
'dhcpConfigurationSet' => {},
|
||||
'tagSet' => {}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
private
|
||||
def indexed_multidimensional_params(multi_params)
|
||||
params = {}
|
||||
multi_params.keys.each_with_index do |key, key_index|
|
||||
key_index += 1
|
||||
params[format('DhcpConfiguration.%d.Key', key_index)] = key
|
||||
[*multi_params[key]].each_with_index do |value, value_index|
|
||||
value_index += 1
|
||||
params[format('DhcpConfiguration.%d.Value.%d', key_index, value_index)] = value
|
||||
end
|
||||
end
|
||||
params
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
50
lib/fog/aws/requests/compute/delete_dhcp_options.rb
Normal file
50
lib/fog/aws/requests/compute/delete_dhcp_options.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/delete_dhcp_options'
|
||||
#Deletes a set of DHCP options that you specify. Amazon VPC returns an error if the set of options you specify is currently
|
||||
#associated with a VPC. You can disassociate the set of options by associating either a new set of options or the default
|
||||
#options with the VPC.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * dhcp_options_id<~String> - The ID of the DHCP options set 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-DeleteDhcpOptions.html]
|
||||
def delete_dhcp_options(dhcp_options_id)
|
||||
request(
|
||||
'Action' => 'DeleteDhcpOptions',
|
||||
'DhcpOptionsId' => dhcp_options_id,
|
||||
:parser => Fog::Parsers::Compute::AWS::DeleteDhcpOptions.new
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_dhcp_options(dhcp_options_id)
|
||||
Excon::Response.new.tap do |response|
|
||||
if dhcp_options_id
|
||||
response.status = 200
|
||||
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
}
|
||||
else
|
||||
message = 'MissingParameter => '
|
||||
message << 'The request must contain the parameter dhcp_options_id'
|
||||
raise Fog::Compute::AWS::Error.new(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
62
lib/fog/aws/requests/compute/describe_dhcp_options.rb
Normal file
62
lib/fog/aws/requests/compute/describe_dhcp_options.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class AWS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/compute/describe_dhcp_options'
|
||||
|
||||
# Describe all or specified dhcp_options
|
||||
#
|
||||
# ==== Parameters
|
||||
# * filters<~Hash> - List of filters to limit results with
|
||||
#
|
||||
# === Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'requestId'<~String> - Id of request
|
||||
# * 'DhcpOptionsSet'<~Array>:
|
||||
# * 'dhcpOptionsId'<~String> - The ID of the Dhcp Options
|
||||
# * 'dhcpConfigurationSet'<~Array>: - The list of options in the set.
|
||||
# * 'key'<~String> - The name of a DHCP option.
|
||||
# * 'valueSet'<~Array>: A set of values for a DHCP option.
|
||||
# * 'value'<~String> - The value of a DHCP option.
|
||||
# * '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-DhcpOptionsType.html]
|
||||
def describe_dhcp_options(filters = {})
|
||||
unless filters.is_a?(Hash)
|
||||
Fog::Logger.warning("describe_dhcp_options with #{filters.class} param is deprecated, use dhcp_options('dhcp-options-id' => []) instead [light_black](#{caller.first})[/]")
|
||||
filters = {'dhcp-options-id' => [*filters]}
|
||||
end
|
||||
params = Fog::AWS.indexed_filters(filters)
|
||||
request({
|
||||
'Action' => 'DescribeDhcpOptions',
|
||||
:idempotent => true,
|
||||
:parser => Fog::Parsers::Compute::AWS::DescribeDhcpOptions.new
|
||||
}.merge!(params))
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def describe_dhcp_options(filters = {})
|
||||
Excon::Response.new.tap do |response|
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'dhcpOptionsSet' => [
|
||||
'dhcpOptionsId' => Fog::AWS::Mock.dhcp_options_id,
|
||||
'dhcpConfigurationSet' => {
|
||||
'key' => 'domain-name',
|
||||
'valueSet' => ["example.com"],
|
||||
},
|
||||
'tagSet' => {}
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,9 @@
|
|||
require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
|
||||
begin
|
||||
require(File.expand_path(File.join(File.dirname(__FILE__), 'core')))
|
||||
rescue LoadError => e
|
||||
retry if require('rubygems')
|
||||
raise e.message
|
||||
end
|
||||
|
||||
module Fog
|
||||
module Libvirt
|
||||
|
|
Loading…
Reference in a new issue