From 96ada811493f5049df460631cd9cd4c4375aa206 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Tue, 6 Sep 2011 16:53:56 -0700 Subject: [PATCH] (#9241) Make the reload action of the server models work Without this patch, we could not call the reload method of a server model instance. This is because the Fog library would try to call the get method using the existing identity (instance_uuid) as the key. This patch implements the get method by instantiating a new model instance from a set of attributes obtained from the vmware managed object instance. The logic reflects that inside of the backspace servers collection implementation. As a side effect of this patch we also get wait_for. For example: server = Fog::Compute[:vsphere].servers.last server.start server.wait_for { ipaddress } --- lib/fog/vsphere/models/compute/servers.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fog/vsphere/models/compute/servers.rb b/lib/fog/vsphere/models/compute/servers.rb index 55a627243..885aa6022 100644 --- a/lib/fog/vsphere/models/compute/servers.rb +++ b/lib/fog/vsphere/models/compute/servers.rb @@ -19,11 +19,11 @@ module Fog load(vm_attributes) end - def get(server_id) - raise NotImplementedError - # FIXME: (TODO) Make a raw API call - # Massage the data into an attribute hash - # Pass the attribute hash to new() to create a new instance of the model. + def get(instance_uuid) + vm_mob = connection.find_all_by_instance_uuid(instance_uuid).first + if server_attributes = model.attribute_hash_from_mob(vm_mob) + new(server_attributes) + end rescue Fog::Compute::Vsphere::NotFound nil end