1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

* Fix: do not try to retrive guest_metrics when guest_metrics ref is nil

* ruby 1.8.7 compatibility fixes
* Sane defaults for create_server_raw request
This commit is contained in:
Sergio Rubio 2012-04-13 18:17:19 +02:00
parent d7edfcd443
commit d81ab200e8
3 changed files with 15 additions and 17 deletions

View file

@ -108,12 +108,9 @@ module Fog
# This is not always present in XenServer VMs
# Guest needs XenTools installed to report this AFAIK
def guest_metrics
begin
rec = connection.get_record( __guest_metrics, 'VM_guest_metrics' )
Fog::Compute::XenServer::GuestMetrics.new(rec)
rescue Fog::XenServer::RequestFailed
nil
end
return nil unless __guest_metrics
rec = connection.get_record( __guest_metrics, 'VM_guest_metrics' )
Fog::Compute::XenServer::GuestMetrics.new(rec)
end
def tools_installed?

View file

@ -30,9 +30,9 @@ module Fog
HVM_boot_params
HVM_boot_params
}.each do |k|
if config[k.to_sym.downcase]
config[k.to_sym] = config[k.to_sym.downcase]
config.delete k.to_sym.downcase
if config[k.downcase.to_sym]
config[k.to_sym] = config[k.downcase.to_sym]
config.delete k.downcase.to_sym
end
end
vm_record = {
@ -42,10 +42,10 @@ module Fog
:affinity => '',
:is_a_template => true,
:auto_power_on => false,
:memory_static_max => '512',
:memory_static_min => '512',
:memory_dynamic_max => '512',
:memory_dynamic_min => '512',
:memory_static_max => '536870912',
:memory_static_min => '536870912',
:memory_dynamic_max => '536870912',
:memory_dynamic_min => '536870912',
:VCPUs_params => {},
:VCPUs_max => '1',
:VCPUs_at_startup => '1',
@ -59,7 +59,7 @@ module Fog
:PV_bootloader => 'pygrub', #pvgrub, eliloader
:PV_kernel => '',
:PV_ramdisk => '',
:PV_args => '',
:PV_args => '-- quiet console=hvc0',
:PV_bootloader_args => '',
:PV_legacy_args => '',
:HVM_boot_policy => '',
@ -67,7 +67,8 @@ module Fog
:PCI_bus => '',
:recommendations => '',
}.merge config
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.create' }, vm_record)
ref = @connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.create' }, vm_record)
ref
end
def create_server( name_label, template = nil, networks = [], extra_args = {})

View file

@ -95,7 +95,7 @@ Shindo.tests('Fog::Compute[:xenserver] | create_server request', ['xenserver'])
{
:name_label => test_ephemeral_vm_name,
:affinity => compute.hosts.first,
a.to_sym.downcase => {:foo => :bar},
a.downcase.to_sym => {:foo => :bar},
}
)
eval "(compute.servers.get ref).#{a.to_s.downcase}['foo'] == 'bar'"
@ -114,7 +114,7 @@ Shindo.tests('Fog::Compute[:xenserver] | create_server request', ['xenserver'])
{
:name_label => test_ephemeral_vm_name,
:affinity => compute.hosts.first,
a.to_sym.downcase => '1',
a.downcase.to_sym => '1',
}
)
eval "(compute.servers.get ref).#{a.to_s.downcase} == '1'"