mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[xenserver] Added support to get VM by uuid
This commit is contained in:
parent
ab59464bc5
commit
d2676005b1
3 changed files with 10 additions and 0 deletions
|
@ -48,6 +48,11 @@ module Fog
|
||||||
get ref
|
get ref
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_by_uuid( uuid )
|
||||||
|
ref = service.get_vm_by_uuid( uuid )
|
||||||
|
get ref
|
||||||
|
end
|
||||||
|
|
||||||
def get( vm_ref )
|
def get( vm_ref )
|
||||||
if vm_ref && vm = service.get_record( vm_ref, 'VM' )
|
if vm_ref && vm = service.get_record( vm_ref, 'VM' )
|
||||||
new(vm)
|
new(vm)
|
||||||
|
|
|
@ -7,6 +7,10 @@ module Fog
|
||||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.get_by_name_label' }, label)
|
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.get_by_name_label' }, label)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_vm_by_uuid(uuid)
|
||||||
|
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.get_by_uuid' }, uuid)
|
||||||
|
end
|
||||||
|
|
||||||
def create_server_raw(config = {})
|
def create_server_raw(config = {})
|
||||||
config[:name_label] = config[:name] if config[:name]
|
config[:name_label] = config[:name] if config[:name]
|
||||||
config.delete :name
|
config.delete :name
|
||||||
|
|
|
@ -76,6 +76,7 @@ Shindo.tests('Fog::Compute[:xenserver] | servers collection', ['xenserver']) do
|
||||||
server = conn.servers.create(:name => test_ephemeral_vm_name,
|
server = conn.servers.create(:name => test_ephemeral_vm_name,
|
||||||
:template_name => test_template_name)
|
:template_name => test_template_name)
|
||||||
test('by name') { servers.get_by_name(test_ephemeral_vm_name).kind_of? Fog::Compute::XenServer::Server }
|
test('by name') { servers.get_by_name(test_ephemeral_vm_name).kind_of? Fog::Compute::XenServer::Server }
|
||||||
|
test('by instance uuid') { servers.get_by_uuid(server.uuid).kind_of? Fog::Compute::XenServer::Server }
|
||||||
test('by instance reference') { servers.get(server.reference).kind_of? Fog::Compute::XenServer::Server }
|
test('by instance reference') { servers.get(server.reference).kind_of? Fog::Compute::XenServer::Server }
|
||||||
server.destroy
|
server.destroy
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue