Class: AWS::EC2::DHCPOptions
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::EC2::DHCPOptions
- Includes:
- TaggedItem
- Defined in:
- lib/aws/ec2/dhcp_options.rb
Instance Attribute Summary collapse
- #dhcp_options_id ⇒ String (also: #id) readonly
Attributes included from Core::Model
Instance Method Summary collapse
-
#associate(vpc) ⇒ nil
Associates this set of options to the given VPC.
- #configuration ⇒ Hash
-
#delete ⇒ nil
Deletes these DHCP options.
-
#exists? ⇒ Boolean
Returns true if the dhcp options exists.
-
#initialize(dhcp_options_id, options = {}) ⇒ DHCPOptions
constructor
A new instance of DHCPOptions.
-
#vpcs ⇒ VPCCollection
Returns a collection that represents all VPCs currently using this dhcp options.
Methods included from TaggedItem
#add_tag, #cached_tags, #clear_tags, #tagging_resource_type, #tags
Methods inherited from Core::Resource
attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #inspect, new_from
Methods included from Core::Cacheable
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(dhcp_options_id, options = {}) ⇒ DHCPOptions
Returns a new instance of DHCPOptions.
22 23 24 25 |
# File 'lib/aws/ec2/dhcp_options.rb', line 22 def initialize , = {} @dhcp_options_id = super end |
Instance Attribute Details
#dhcp_options_id ⇒ String (readonly) Also known as: id
28 29 30 |
# File 'lib/aws/ec2/dhcp_options.rb', line 28 def @dhcp_options_id end |
Instance Method Details
#associate(vpc) ⇒ nil
Associates this set of options to the given VPC.
60 61 62 63 64 65 66 |
# File 'lib/aws/ec2/dhcp_options.rb', line 60 def associate vpc client_opts = {} client_opts[:dhcp_options_id] = client_opts[:vpc_id] = vpc_id_option(vpc) client.(client_opts) nil end |
#configuration ⇒ Hash
47 48 49 50 51 52 53 54 55 |
# File 'lib/aws/ec2/dhcp_options.rb', line 47 def configuration dhcp_configuration_set.to_a.inject({}) do |config,opt| key = opt[:key].gsub(/-/, '_').to_sym values = opt[:value_set].map{|v| v[:value] } values = values.first if key == :domain_name values = values.first.to_i if key == :netbios_node_type config.merge(key => values) end end |
#delete ⇒ nil
Deletes these DHCP options. An error will be raised if these options are currently associated to a VPC. To disassociate this set of options from a VPC, associate a different set of options with the VPC.
75 76 77 78 79 80 |
# File 'lib/aws/ec2/dhcp_options.rb', line 75 def delete client_opts = {} client_opts[:dhcp_options_id] = client.(client_opts) nil end |
#exists? ⇒ Boolean
Returns true if the dhcp options exists.
90 91 92 93 94 95 96 97 |
# File 'lib/aws/ec2/dhcp_options.rb', line 90 def exists? begin get_resource true rescue Errors::InvalidDhcpOptionID::NotFound false end end |
#vpcs ⇒ VPCCollection
Returns a collection that represents all VPCs currently using this dhcp options.
84 85 86 87 |
# File 'lib/aws/ec2/dhcp_options.rb', line 84 def vpcs vpcs = VPCCollection.new(:config => config) vpcs.filter('dhcp-options-id', ) end |