class Occi::Resource
OCCI Resource
class.
Public Class Methods
inherited(childclass)
click to toggle source
Callback invoked whenever a subclass is created. This method dynamically defines virtual @endpoint attribute located in child instance, which contains backslash + name of inheriting class. It is used for request building.
Calls superclass method
# File lib/probe/occi/nocci/resource.rb, line 36 def self.inherited(childclass) super(childclass) path = childclass.to_s.split('::').last.downcase childclass.send(:define_method, :endpoint) { "/#{path}" } end
new(connection)
click to toggle source
# File lib/probe/occi/nocci/resource.rb, line 24 def initialize(connection) self.class.base_uri "#{connection[:endpoint]}" # nebula OCCI format self.class.basic_auth "#{connection[:auth][:username]}", Digest::SHA1.hexdigest(connection[:auth][:password]) # Low-level debugging # self.class.debug_output end
Public Instance Methods
all()
click to toggle source
Returns the contents of the pool. 200 OK: An XML representation of the pool in the http body. This means query the point /network, /storage etc.
# File lib/probe/occi/nocci/resource.rb, line 51 def all begin response = self.class.get(endpoint) rescue => e raise e.class, 'Could not initiate basic endpoint connectivity query, maybe HTTP/SSL server problem?' ensure if !response.nil? fail HTTPResponseError, "Basic pool availibility request failed! #{response.body}" unless response.code.between?(200, 300) response.body else fail HTTPResponseError, 'Basic pool availibility request failed!' end end end
entity(id)
click to toggle source
# File lib/probe/occi/nocci/resource.rb, line 44 def entity(id) "#{endpoint}/#{id}" end
find(id)
click to toggle source
Returns the representation of specific resource identified by id
. 200 OK: An XML representation of the pool in the http body.
# File lib/probe/occi/nocci/resource.rb, line 68 def find(id) begin response = self.class.get(entity(id)) rescue => e raise e.class, 'Could not initiate specific resource query, maybe HTTP/SSL server problem?' ensure if !response.nil? fail HTTPResponseError, "Specific resource request failed! #{response.body}" unless response.code.between?(200, 300) response.body else fail HTTPResponseError, 'Specific resource request failed!' end end end