Class: OpenNebula::Datastore
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Datastore
- Defined in:
- OpenNebula/Datastore.rb
Constant Summary
- DATASTORE_METHODS =
Constants and Class Methods
{ :info => "datastore.info", :allocate => "datastore.allocate", :delete => "datastore.delete", :update => "datastore.update", :chown => "datastore.chown", :chmod => "datastore.chmod" }
Class Method Summary (collapse)
-
+ (Object) build_xml(pe_id = nil)
Creates a Datastore description with just its identifier this method should be used to create plain Datastore objects.
Instance Method Summary (collapse)
-
- (Integer, OpenNebula::Error) allocate(description, cluster_id = ClusterPool::NONE_CLUSTER_ID)
Allocates a new Datastore in OpenNebula.
-
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the datastore permissions.
-
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the datastore permissions.
-
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group.
-
- (Object) contains(id)
Returns whether or not the image with id 'id' is part of this datastore.
-
- (Object) delete
Deletes the Datastore.
-
- (Object) img_ids
Returns an array with the numeric image ids.
-
- (Object) info
Retrieves the information of the given Datastore.
-
- (Datastore) initialize(xml, client)
constructor
Class constructor.
-
- (nil, OpenNebula::Error) update(new_template)
Replaces the template contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
- (Datastore) initialize(xml, client)
Class constructor
53 54 55 |
# File 'OpenNebula/Datastore.rb', line 53 def initialize(xml, client) super(xml,client) end |
Class Method Details
+ (Object) build_xml(pe_id = nil)
Creates a Datastore description with just its identifier this method should be used to create plain Datastore objects. id the id of the user
Example:
datastore = Datastore.new(Datastore.build_xml(3),rpc_client)
42 43 44 45 46 47 48 49 50 |
# File 'OpenNebula/Datastore.rb', line 42 def Datastore.build_xml(pe_id=nil) if pe_id datastore_xml = "<DATASTORE><ID>#{pe_id}</ID></DATASTORE>" else datastore_xml = "<DATASTORE></DATASTORE>" end XMLElement.build_xml(datastore_xml,'DATASTORE') end |
Instance Method Details
- (Integer, OpenNebula::Error) allocate(description, cluster_id = ClusterPool::NONE_CLUSTER_ID)
Allocates a new Datastore in OpenNebula
73 74 75 |
# File 'OpenNebula/Datastore.rb', line 73 def allocate(description, cluster_id=ClusterPool::NONE_CLUSTER_ID) super(DATASTORE_METHODS[:allocate], description, cluster_id) end |
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the datastore permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
117 118 119 120 121 |
# File 'OpenNebula/Datastore.rb', line 117 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) super(DATASTORE_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end |
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the datastore permissions.
108 109 110 |
# File 'OpenNebula/Datastore.rb', line 108 def chmod_octet(octet) super(DATASTORE_METHODS[:chmod], octet) end |
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group
99 100 101 |
# File 'OpenNebula/Datastore.rb', line 99 def chown(uid, gid) super(DATASTORE_METHODS[:chown], uid, gid) end |
- (Object) contains(id)
Returns whether or not the image with id 'id' is part of this datastore
128 129 130 131 132 133 134 |
# File 'OpenNebula/Datastore.rb', line 128 def contains(id) #This doesn't work in ruby 1.8.5 #return self["DATASTORE/ID[.=#{uid}]"] != nil id_array = retrieve_elements('DATASTORE/ID') return id_array != nil && id_array.include?(uid.to_s) end |
- (Object) delete
Deletes the Datastore
78 79 80 |
# File 'OpenNebula/Datastore.rb', line 78 def delete() super(DATASTORE_METHODS[:delete]) end |
- (Object) img_ids
Returns an array with the numeric image ids
137 138 139 140 141 142 143 144 145 |
# File 'OpenNebula/Datastore.rb', line 137 def img_ids array = Array.new self.each("IMAGES/ID") do |id| array << id.text.to_i end return array end |
- (Object) info
Retrieves the information of the given Datastore.
62 63 64 |
# File 'OpenNebula/Datastore.rb', line 62 def info() super(DATASTORE_METHODS[:info], 'DATASTORE') end |
- (nil, OpenNebula::Error) update(new_template)
Replaces the template contents
88 89 90 |
# File 'OpenNebula/Datastore.rb', line 88 def update(new_template) super(DATASTORE_METHODS[:update], new_template) end |