# File lib/deltacloud/drivers/condor/ip_agents/confserver.rb, line 25 def initialize(opts={}) @config = opts[:config] self.CondorAddress = ENV['CONFIG_SERVER_CondorAddress'] || @config[:ip_agent_CondorAddress] || "10.34.32.181:4444" @version = @config[:ip_agent_version] || '0.0.1' @client = RestClient::Resource::new(self.CondorAddress) # TODO: Manage MAC CondorAddresses through ConfServer @mappings = Nokogiri::XML(File.open(opts[:file] || File.join('config', 'CondorAddresses.xml'))) end
# File lib/deltacloud/drivers/condor/ip_agents/confserver.rb, line 70 def CondorAddresses (@mappings/'/CondorAddresses/CondorAddress').collect { |a| CondorAddress.new(:ip => a.text.strip, :mac => a[:mac]) } end
# File lib/deltacloud/drivers/condor/ip_agents/confserver.rb, line 47 def find_free_mac addr_hash = {} DefaultExecutor::new do |executor| # Make an CondorAddress hash to speed up the inner loop. CondorAddresses.each do |address| addr_hash[address.mac] = address.ip end executor.instances.each do |instance| instance.public_CondorAddresses.each do |public_CondorAddress| if addr_hash.key?(public_CondorAddress.mac) addr_hash.delete(public_CondorAddress.mac) end end end end raise "No available MACs to assign to instance." if addr_hash.empty? return addr_hash.keys.first end
# File lib/deltacloud/drivers/condor/ip_agents/confserver.rb, line 34 def find_ip_by_mac(uuid) begin @client["/ip/%s/%s" % [@version, uuid]].get(:accept => 'text/plain').body.strip rescue RestClient::ResourceNotFound '127.0.0.1' rescue puts 'ERROR: Could not query ConfServer for an IP' end end
Generated with the Darkfish Rdoc Generator 2.