lib/openstack/compute/server.rb in openstack-1.0.8 vs lib/openstack/compute/server.rb in openstack-1.0.9
- old
+ new
@@ -15,10 +15,11 @@
attr_reader :image
attr_reader :flavor
attr_reader :metadata
attr_accessor :adminPass
attr_reader :key_name
+ attr_reader :created
attr_reader :security_groups
# This class is the representation of a single Server object. The constructor finds the server identified by the specified
# ID number, accesses the API via the populate method to get information about that server, and returns the object.
#
@@ -62,10 +63,11 @@
@metadata = OpenStack::Compute::Metadata.new(@compute, path, data["metadata"])
@hostId = data["hostId"]
@image = data["image"] || data["imageId"]
@flavor = data["flavor"] || data["flavorId"]
@key_name = data["key_name"] # if provider uses the keys API extension for accessing servers
+ @created = data["created"]
@security_groups = (data["security_groups"] || []).inject([]){|res, c| res << c["id"] ; res}
true
end
alias :refresh :populate
@@ -175,10 +177,10 @@
# =>
def create_image(options)
data = JSON.generate(:createImage => options)
response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
- image_id = response["Location"].scan(/.*\/(.*)/).flatten
+ image_id = response["Location"].split("/images/").last
OpenStack::Compute::Image.new(@compute, image_id)
end
# Resizes the server to the size contained in the server flavor found at ID flavorRef. The server name, ID number, and IP addresses
# will remain the same. After the resize is done, the server.status will be set to "VERIFY_RESIZE" until the resize is confirmed or reverted.