Parent

OpenNebula::Acl

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
             ACL
RIGHTS    -> + separated list
             USE
             MANAGE
             ADMIN
             CREATE

Constants

RESOURCES
RIGHTS
USERS

Public Class Methods

build_xml(pe_id=nil) click to toggle source

Creates an empty XML representation. It contains the id, if it is specified.

@param pe_id [Integer] rule ID

@return [String] an empty XML representation

# File lib/opennebula/acl.rb, line 85
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
new(xml, client) click to toggle source

Constructor

@param xml [String] must be an xml built with {.build_xml} @param client [Client] represents an XML-RPC connection

# File lib/opennebula/acl.rb, line 75
def initialize(xml, client)
    super(xml,client)
end
parse_rule(rule_str) click to toggle source

Parses a rule string, e.g. "#5 HOST+VM/@12 INFO+CREATE+DELETE"

@param rule_str [String] an ACL rule in string format

@return [Array] an Array containing 3 strings (hex 64b numbers), or OpenNebula::Error objects

# File lib/opennebula/acl.rb, line 147
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.message
        else
            nil
        end
    end

    errors.compact!

    if errors.length>0
        return OpenNebula::Error.new(errors.join(', '))
    end

    return ret
end

Public Instance Methods

allocate(user, resource, rights, zone=nil) click to toggle source

Creates a new ACL rule.

@param user [String]

A string containing a hex number, e.g. 0x100000001

@param resource [String]

A string containing a hex number, e.g. 0x2100000001

@param rights [String]

A string containing a hex number, e.g. 0x10

@param zone [String]

A string containing a hex number, e.g. 0x100000001

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
# File lib/opennebula/acl.rb, line 108
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() click to toggle source

Deletes the Acl rule

@return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
# File lib/opennebula/acl.rb, line 127
def delete()
    super(AclPool::ACL_POOL_METHODS[:delrule])
end
info() click to toggle source

Does nothing, individual ACL rules info can't be retrieved from OpenNebula

@return [nil] nil

# File lib/opennebula/acl.rb, line 135
def info()
    return nil
end
Also aliased as: info!
info!() click to toggle source
Alias for: info

[Validate]

Generated with the Darkfish Rdoc Generator 2.