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

(#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 }
This commit is contained in:
Jeff McCune 2011-09-06 16:53:56 -07:00
parent 27a689b951
commit 96ada81149

View file

@ -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