Class: OpenNebula::Acl
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Acl
- Defined in:
- lib/opennebula/acl.rb
Overview
Abstract rules of the type USER RESOURCE RIGHTS which are:
USER -> #<num>
@<num>
ALL
RESOURCE -> + separated list and "/{#,@,%}<num>|ALL"
VM
HOST
NET
IMAGE
USER
TEMPLATE
GROUP
DATASTORE
CLUSTER
DOCUMENT
ZONE
SECGROUP
VDC
VROUTER
MARKETPLACE
MARKETPLACEAPP
VMGROUP
RIGHTS -> + separated list
USE
MANAGE
ADMIN
CREATE
Constant Summary collapse
- USERS =
{ "UID" => 0x100000000, "GID" => 0x200000000, "ALL" => 0x400000000, "CLUSTER" => 0x800000000 }
- RESOURCES =
{ "VM" => 0x1000000000, "HOST" => 0x2000000000, "NET" => 0x4000000000, "IMAGE" => 0x8000000000, "USER" => 0x10000000000, "TEMPLATE" => 0x20000000000, "GROUP" => 0x40000000000, "DATASTORE" => 0x100000000000, "CLUSTER" => 0x200000000000, "DOCUMENT" => 0x400000000000, "ZONE" => 0x800000000000, "SECGROUP" => 0x1000000000000, "VDC" => 0x2000000000000, "VROUTER" => 0x4000000000000, "MARKETPLACE" => 0x8000000000000, "MARKETPLACEAPP"=> 0x10000000000000, "VMGROUP" => 0x20000000000000, "VNTEMPLATE" => 0x40000000000000, "BACKUPJOB" =>0x100000000000000 }
- RIGHTS =
{ "USE" => 0x1, # Auth. to use an object "MANAGE" => 0x2, # Auth. to perform management actions "ADMIN" => 0x4, # Auth. to perform administrative actions "CREATE" => 0x8 # Auth. to create an object }
Instance Attribute Summary
Attributes inherited from PoolElement
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ String
Creates an empty XML representation.
-
.parse_rule(rule_str) ⇒ Array
Parses a rule string, e.g.
Instance Method Summary collapse
-
#allocate(user, resource, rights, zone = nil) ⇒ nil, OpenNebula::Error
Creates a new ACL rule.
-
#delete ⇒ nil, OpenNebula::Error
Deletes the Acl rule.
-
#info ⇒ nil
(also: #info!)
Does nothing, individual ACL rules info can’t be retrieved from OpenNebula.
-
#initialize(xml, client) ⇒ Acl
constructor
Constructor.
Methods inherited from PoolElement
#id, new_with_id, #replace, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?
Constructor Details
#initialize(xml, client) ⇒ Acl
Constructor
92 93 94 |
# File 'lib/opennebula/acl.rb', line 92 def initialize(xml, client) super(xml,client) end |
Class Method Details
.build_xml(pe_id = nil) ⇒ String
Creates an empty XML representation. It contains the id, if it is specified.
102 103 104 105 106 107 108 109 110 |
# File 'lib/opennebula/acl.rb', line 102 def self.build_xml(pe_id=nil) if pe_id acl_xml = "<ACL><ID>#{pe_id}</ID></ACL>" else acl_xml = "<ACL></ACL>" end XMLElement.build_xml(acl_xml,'ACL') end |
.parse_rule(rule_str) ⇒ Array
Parses a rule string, e.g. “#5 HOST+VM/@12 INFO+CREATE+DELETE”
or OpenNebula::Error objects
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/opennebula/acl.rb', line 164 def self.parse_rule(rule_str) ret = Array.new rule_str = rule_str.split(" ") if rule_str.length != 3 && rule_str.length != 4 return OpenNebula::Error.new( "String needs three components: User, Resource, Rights") end ret << parse_users(rule_str[0]) ret << parse_resources(rule_str[1]) ret << parse_rights(rule_str[2]) if rule_str.length > 3 ret << parse_zone(rule_str[3]) end errors=ret.map do |arg| if OpenNebula.is_error?(arg) arg. else nil end end errors.compact! if errors.length>0 return OpenNebula::Error.new(errors.join(', ')) end return ret end |
Instance Method Details
#allocate(user, resource, rights, zone = nil) ⇒ nil, OpenNebula::Error
Creates a new ACL rule.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/opennebula/acl.rb', line 125 def allocate(user, resource, rights, zone=nil) if !zone.nil? return super( AclPool::ACL_POOL_METHODS[:addrule], user, resource, rights, zone ) else return super( AclPool::ACL_POOL_METHODS[:addrule], user, resource, rights) end end |
#delete ⇒ nil, OpenNebula::Error
Deletes the Acl rule
144 145 146 |
# File 'lib/opennebula/acl.rb', line 144 def delete() super(AclPool::ACL_POOL_METHODS[:delrule]) end |
#info ⇒ nil Also known as: info!
Does nothing, individual ACL rules info can’t be retrieved from OpenNebula
152 153 154 |
# File 'lib/opennebula/acl.rb', line 152 def info() return nil end |