lib/openstack/compute/server.rb in openstack-1.0.1 vs lib/openstack/compute/server.rb in openstack-1.0.2

- old
+ new

@@ -15,10 +15,11 @@ attr_reader :image attr_reader :flavor attr_reader :metadata attr_accessor :adminPass attr_reader :key_name + 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. # # Will be called via the get_server or create_server methods on the OpenStack::Compute::Connection object, and will likely not be called directly. @@ -51,20 +52,21 @@ if data.nil? then response = @compute.connection.req("GET", path) OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/) data = JSON.parse(response.body)["server"] end - @id = data["id"] + @id = data["uuid"] @name = data["name"] @status = data["status"] @progress = data["progress"] @addresses = get_addresses(data["addresses"]) @metadata = OpenStack::Compute::Metadata.new(@compute, path, data["metadata"]) @hostId = data["hostId"] @image = data["image"] @flavor = data["flavor"] @key_name = data["key_name"] # if provider uses the keys API extension for accessing servers + @security_groups = data["security_groups"].inject([]){|res, c| res << c["id"] ; res} true end alias :refresh :populate # Sends an API request to reboot this server. Takes an optional argument for the type of reboot, which can be "SOFT" (graceful shutdown) @@ -232,9 +234,10 @@ @compute.connection.req('POST', "/servers/#{@id}/action", :data => json) @adminPass = password end def get_addresses(address_info) + address_info = OpenStack::Compute::Address.fix_labels(address_info) address_list = OpenStack::Compute::AddressList.new address_info.each do |label, addr| addr.each do |address| address_list << OpenStack::Compute::Address.new(label,address) if address_list.last.version == 4 && (!@accessipv4 || accessipv4 == "") then