Class: OpenNebula::Document
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Document
- Defined in:
- OpenNebula/Document.rb
Overview
All subclasses must define the DOCUMENT_TYPE constant.
Direct Known Subclasses
Constant Summary
- DOCUMENT_METHODS =
Constants and Class Methods
{ :allocate => "document.allocate", :delete => "document.delete", :info => "document.info", :update => "document.update", :chown => "document.chown", :chmod => "document.chmod", :clone => "document.clone", }
Class Method Summary (collapse)
-
+ (Nokogiri::XML::Node, REXML::Element) build_xml(pe_id = nil)
Creates a Document Object description with just its identifier this method should be used to create plain Document objects.
Instance Method Summary (collapse)
-
- (nil, OpenNebula::Error) allocate(description)
Allocates a new Document 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 Document permissions.
-
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the Document permissions.
-
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group.
-
- (Integer, OpenNebula::Error) clone(name)
Clones this Document into a new one.
-
- (nil, OpenNebula::Error) delete
Deletes the Document.
- - (Object) document_type
-
- (Integer) gid
Returns the group identifier.
-
- (nil, OpenNebula::Error) info
Retrieves the information of the given Document.
-
- (Document) initialize(xml, client)
constructor
Class constructor.
-
- (Integer) owner_id
Returns the owner user ID.
-
- (true, false) public?
Returns true if the GROUP_U permission bit is set.
-
- (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, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
- (Document) initialize(xml, client)
Class constructor
74 75 76 |
# File 'OpenNebula/Document.rb', line 74 def initialize(xml, client) super(xml,client) end |
Class Method Details
+ (Nokogiri::XML::Node, REXML::Element) build_xml(pe_id = nil)
Creates a Document Object description with just its identifier this method should be used to create plain Document objects.
54 55 56 57 58 59 60 61 62 |
# File 'OpenNebula/Document.rb', line 54 def Document.build_xml(pe_id=nil) if pe_id obj_xml = "<DOCUMENT><ID>#{pe_id}</ID></DOCUMENT>" else obj_xml = "<DOCUMENT></DOCUMENT>" end XMLElement.build_xml(obj_xml,'DOCUMENT') end |
Instance Method Details
- (nil, OpenNebula::Error) allocate(description)
Allocates a new Document in OpenNebula
102 103 104 |
# File 'OpenNebula/Document.rb', line 102 def allocate(description) super(DOCUMENT_METHODS[:allocate], description, document_type) 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 Document permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
162 163 164 165 166 167 168 169 |
# File 'OpenNebula/Document.rb', line 162 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) rc = check_type() return rc if OpenNebula.is_error?(rc) super(DOCUMENT_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 Document permissions.
150 151 152 153 154 155 |
# File 'OpenNebula/Document.rb', line 150 def chmod_octet(octet) rc = check_type() return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:chmod], octet) end |
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group
137 138 139 140 141 142 |
# File 'OpenNebula/Document.rb', line 137 def chown(uid, gid) rc = check_type() return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:chown], uid, gid) end |
- (Integer, OpenNebula::Error) clone(name)
Clones this Document into a new one
177 178 179 180 181 182 183 184 185 186 |
# File 'OpenNebula/Document.rb', line 177 def clone(name) rc = check_type() return rc if OpenNebula.is_error?(rc) return Error.new('ID not defined') if !@pe_id rc = @client.call(DOCUMENT_METHODS[:clone], @pe_id, name) return rc end |
- (nil, OpenNebula::Error) delete
Deletes the Document
110 111 112 113 114 115 |
# File 'OpenNebula/Document.rb', line 110 def delete() rc = check_type() return rc if OpenNebula.is_error?(rc) return call(DOCUMENT_METHODS[:delete], @pe_id) end |
- (Object) document_type
214 215 216 |
# File 'OpenNebula/Document.rb', line 214 def document_type self.class::DOCUMENT_TYPE end |
- (Integer) gid
Returns the group identifier
194 195 196 |
# File 'OpenNebula/Document.rb', line 194 def gid self['GID'].to_i end |
- (nil, OpenNebula::Error) info
Retrieves the information of the given Document.
86 87 88 89 90 91 92 93 94 |
# File 'OpenNebula/Document.rb', line 86 def info() rc = super(DOCUMENT_METHODS[:info], 'DOCUMENT') if !OpenNebula.is_error?(rc) && self['TYPE'].to_i != document_type return OpenNebula::Error.new("[DocumentInfo] Error getting document [#{@pe_id}].") end return rc end |
- (Integer) owner_id
Returns the owner user ID
200 201 202 |
# File 'OpenNebula/Document.rb', line 200 def owner_id self['UID'].to_i end |
- (true, false) public?
Returns true if the GROUP_U permission bit is set
206 207 208 209 210 211 212 |
# File 'OpenNebula/Document.rb', line 206 def public? if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" true else false end end |
- (nil, OpenNebula::Error) update(new_template)
Replaces the template contents
123 124 125 126 127 128 |
# File 'OpenNebula/Document.rb', line 123 def update(new_template) rc = check_type() return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:update], new_template) end |