class BuildCloud::DHCPOptionsSet

Public Class Methods

get_id_by_name( name ) click to toggle source
# 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
new( fog_interfaces, log, options = {} ) click to toggle source
# File lib/build-cloud/dhcpoptionsset.rb, line 25
def initialize ( fog_interfaces, log, options = {} )

    @compute = fog_interfaces[:compute]
    @log     = log
    @options = options

    @log.debug( options.inspect )

    required_options(:dhcp_configuration_set)

end

Public Instance Methods

[](key) click to toggle source
# File lib/build-cloud/dhcpoptionsset.rb, line 72
def [](key)
    @options[key]
end
create() click to toggle source
# File lib/build-cloud/dhcpoptionsset.rb, line 37
def create
    
    return if exists?

    @log.info( "Creating new DHCP Options Set for #{@options[:name]}" )

    options = @options.dup

    options[:tags] = { 'Name' => options.delete(:name) }

    dhcp_option = @compute.dhcp_options.new( options )
    dhcp_option.save

    @compute.create_tags( dhcp_option.id, options[:tags] )

    @log.debug( dhcp_option.inspect )

end
delete() click to toggle source
# 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
fog_object()
Alias for: read
read() click to toggle source
# File lib/build-cloud/dhcpoptionsset.rb, line 56
def read
    @compute.dhcp_options.select { |d| d.tag_set['Name'] == @options[:name] }.first
end
Also aliased as: fog_object