From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 25 +++++++++++++++++-- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb index a0ac64f..b0470ba 100644 --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb @@ -200,6 +200,15 @@ class RHEVMDriver < Deltacloud::BaseDriver end end + def confserver_ip(uuid) + client = RestClient::Resource::new(ENV['CONFIG_SERVER_ADDRESS']) + begin + client["/ip/0.0.1/%s" % uuid].get(:accept => 'text/plain').body.strip + rescue + nil + end + end + def convert_instance(client, inst) state = convert_state(inst.status) storage_size = inst.storage.nil? ? 1 : (inst.storage.to_i/1024/1024/1024) @@ -209,10 +218,20 @@ class RHEVMDriver < Deltacloud::BaseDriver :hwp_storage => "#{storage_size}" ) # Include VNC and SPICE addresses - if inst.ip - public_addresses = [ inst.ip ] + if env['CONFIG_SERVER_ADDRESS'] + public_addresses = [ conf_server_ip(inst.id) ].flatten + # FIXME: Remove this part once ConfServer will start handling RHEV-M + if public_addresses.empty? + public_addresses = [ + "#{rand(254+1}.#{rand(254+1)}.#{rand(254+1)}.#{rand(254+1)}" + ] + end else - public_addresses = [ inst.macs ] + if inst.ip + public_addresses = [ inst.ip ] + else + public_addresses = [ inst.macs ] + end end Instance.new( :id => inst.id, -- 1.7.4.1
