Class: BuildCloud::DHCPOptionsSet
- Inherits:
-
Object
- Object
- BuildCloud::DHCPOptionsSet
- Includes:
- Component
- Defined in:
- lib/build-cloud/dhcpoptionsset.rb
Constant Summary collapse
- @@objects =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(fog_interfaces, log, options = {}) ⇒ DHCPOptionsSet
constructor
A new instance of DHCPOptionsSet.
- #read ⇒ Object (also: #fog_object)
Methods included from Component
Constructor Details
#initialize(fog_interfaces, log, options = {}) ⇒ DHCPOptionsSet
Returns a new instance of DHCPOptionsSet.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 25 def initialize ( fog_interfaces, log, = {} ) @compute = fog_interfaces[:compute] @log = log @options = @log.debug( .inspect ) (:dhcp_configuration_set) end |
Class Method Details
.get_id_by_name(name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 7 def self.get_id_by_name( name ) dhcp_option = self.search( :name => name ).first unless dhcp_option raise "Couldn't get a DHCP Options Set object for #{name} - is it defined?" end dhcp_option_fog = dhcp_option.read unless dhcp_option_fog raise "Couldn't get a DHCP Options Set fog object for #{name} - is it created?" end dhcp_option_fog.id end |
Instance Method Details
#[](key) ⇒ Object
72 73 74 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 72 def [](key) @options[key] end |
#create ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 37 def create return if exists? @log.info( "Creating new DHCP Options Set for #{@options[:name]}" ) = @options.dup [:tags] = { 'Name' => .delete(:name) } dhcp_option = @compute..new( ) dhcp_option.save @compute.( dhcp_option.id, [:tags] ) @log.debug( dhcp_option.inspect ) end |
#delete ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 62 def delete return unless exists? @log.info( "Deleting DHCP Options Set for #{@options[:name]}" ) fog_object.destroy end |
#read ⇒ Object Also known as: fog_object
56 57 58 |
# File 'lib/build-cloud/dhcpoptionsset.rb', line 56 def read @compute..select { |d| d.tag_set['Name'] == @options[:name] }.first end |