Class: Rocci::Resource

Inherits:
Object
  • Object
show all
Includes:
Occi::Api::Dsl
Defined in:
lib/probe/occi/rocci/resource.rb

Overview

rOCCI Resource class.

Direct Known Subclasses

Compute, Network, Storage

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Resource

Returns a new instance of Resource.



24
25
26
27
# File 'lib/probe/occi/rocci/resource.rb', line 24

def initialize(opts)
  @opts = opts
  connect(:http, opts)
end

Class Method Details

.inherited(childclass) ⇒ Object

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.



32
33
34
35
36
37
38
# File 'lib/probe/occi/rocci/resource.rb', line 32

def self.inherited(childclass)
  super(childclass)

  path = childclass.to_s.split('::').last.downcase

  childclass.send(:define_method, :resource_uri) { "#{path}" }
end

Instance Method Details

#allObject

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. Please read Occi::Api documentation here github.com/arax/rOCCI-api.



48
49
50
# File 'lib/probe/occi/rocci/resource.rb', line 48

def all
  describe(resource_uri)
end

#create_check_destroyObject



58
59
60
# File 'lib/probe/occi/rocci/resource.rb', line 58

def create_check_destroy
  # Overriden in sibling (compute)
end

#entity(id) ⇒ Object



40
41
42
# File 'lib/probe/occi/rocci/resource.rb', line 40

def entity(id)
  "/#{resource_uri}/#{id}"
end

#find(id) ⇒ Object

Returns the representation of specific resource identified by id. 200 OK: An XML representation of the pool in the http body.



54
55
56
# File 'lib/probe/occi/rocci/resource.rb', line 54

def find(id)
  describe(entity(id))
end