incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1154880 - in /incubator/deltacloud/trunk/server/lib/deltacloud: drivers/rhevm/rhevm_client.rb drivers/rhevm/rhevm_driver.rb helpers/application_helper.rb
Date Mon, 08 Aug 2011 09:14:12 GMT
Author: mfojtik
Date: Mon Aug  8 09:14:11 2011
New Revision: 1154880

URL: http://svn.apache.org/viewvc?rev=1154880&view=rev
Log:
RHEVM: Added VNC address type for VNC access

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb?rev=1154880&r1=1154879&r2=1154880&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb Mon Aug
 8 09:14:11 2011
@@ -197,7 +197,7 @@ module RHEVM
   class VM < BaseObject
     attr_reader :description, :status, :memory, :profile, :display, :host, :cluster, :template,
:macs
     attr_reader :storage, :cores, :username, :creation_time
-    attr_reader :ip
+    attr_reader :ip, :vnc
 
     def initialize(client, xml)
       super(client, xml[:id], xml[:href], (xml/'name').first.text)
@@ -227,6 +227,10 @@ module RHEVM
       @macs = (xml/'nics/nic/mac').collect { |mac| mac[:address] }
       @creation_time = (xml/'creation_time').text
       @ip = ((xml/'guest_info/ip').first[:address] rescue nil)
+      unless @ip
+        @vnc = ((xml/'display/address').first.text rescue "127.0.0.1")
+        @vnc += ":#{((xml/'display/port').first.text rescue "5890")}"
+      end
     end
 
   end

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb?rev=1154880&r1=1154879&r2=1154880&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb Mon Aug
 8 09:14:11 2011
@@ -214,6 +214,7 @@ class RHEVMDriver < Deltacloud::BaseDriv
     # If everything fails fallback to report MAC address
     public_addresses = inst.macs if public_addresses.empty?
     public_addresses.flatten!
+    public_addresses << inst.vnc if inst.vnc
     Instance.new(
       :id => inst.id,
       :name => inst.name,

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb?rev=1154880&r1=1154879&r2=1154880&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/application_helper.rb Mon Aug
 8 09:14:11 2011
@@ -247,9 +247,18 @@ module ApplicationHelper
     end
   end
 
+  # FIXME: It would be cleaner if we stored the type of address explicitly in
+  # public_addresses instead of guessing it; especially since now a RHEV-M
+  # vnc address in theory could look like type ipv4.
+  #
+  # Instead of pushing just the address onto public_addresses, we should
+  # just push a pair [type, address], i.e. [:vnc, "172.16.0.1"] or a hash
+  # { :vnc => "172.16.0.1" }
+  #
   def address_type(address)
     case address
       when /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/; :ipv4
+      when /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?:([\-\d]+)$/; :vnc
       when /^(\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2}:\S{1,2})?$/; :mac
       else :hostname
     end



Mime
View raw message