Class: Pangea::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/pangea/objects.rb

Overview

Link is the connection to the hypervisor

Every Link is associated to one host

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, username = 'foo', password = 'bar') ⇒ Link

Returns a new instance of Link.



12
13
14
15
16
# File 'lib/pangea/objects.rb', line 12

def initialize(url, username='foo', password='bar')
  @xmlrpc_url = url
  @username = username
  @password = password
end

Instance Attribute Details

#clientObject (readonly)

:nodoc:



10
11
12
# File 'lib/pangea/objects.rb', line 10

def client
  @client
end

#connectedObject (readonly)

:nodoc:



10
11
12
# File 'lib/pangea/objects.rb', line 10

def connected
  @connected
end

#sidObject (readonly)

:nodoc:



10
11
12
# File 'lib/pangea/objects.rb', line 10

def sid
  @sid
end

#urlObject (readonly)

:nodoc:



10
11
12
# File 'lib/pangea/objects.rb', line 10

def url
  @url
end

Instance Method Details

#connectObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pangea/objects.rb', line 18

def connect
  #puts "hyperlinking to #{@xmlrpc_url}"
  $stdout.flush
  begin
    @client = XMLRPC::Client.new2(@xmlrpc_url)
    @session = @client.proxy('session')
    @sid = @session.(@username, @password)['Value']
    @connected = true
  rescue Exception => e
    raise LinkConnectError.new("Error connecting to the hypervisor #{@xmlrpc_url} (#{e.message})")
  end
end