Class: Archipel::Api::VmApi
Instance Method Summary
collapse
#call, #in_connection, #wait_for_reply
Constructor Details
#initialize(login: nil, password: nil, server: nil, hypervisor: nil) ⇒ VmApi
Returns a new instance of VmApi.
6
7
8
9
10
11
|
# File 'lib/archipel/api/vm_api.rb', line 6
def initialize login: nil, password: nil, server: nil, hypervisor: nil
@api = Archipel::Api::Internal::VmXmlMessages.new
super({login: login,
password: password,
server: server})
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
31
32
33
34
35
|
# File 'lib/archipel/api/vm_api.rb', line 31
def method_missing symbol, *args
to = args[0]
xml = @api.send symbol, *args
call xml, to
end
|
Instance Method Details
#list_disks(jid) ⇒ Object
21
22
23
24
|
# File 'lib/archipel/api/vm_api.rb', line 21
def list_disks jid
out = method_missing :list_disks, jid
out['query'][0]['disk'] || []
end
|
#remove_disk(jid, name, format) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/archipel/api/vm_api.rb', line 13
def remove_disk jid, name, format
disks = list_disks jid
found_disk = disks.find do |disk|
disk['name'] == name && disk['format'] == format
end
method_missing :remove_disk, jid, found_disk['path']
end
|
#xml(jid) ⇒ Object
26
27
28
29
|
# File 'lib/archipel/api/vm_api.rb', line 26
def xml jid
out = method_missing :xml, jid
out['query'][0]['domain'][0]
end
|