class OpenNebula::SecurityGroup

Constants

SECGROUP_METHODS

Constants and Class Methods

Public Class Methods

build_xml(pe_id=nil) click to toggle source

Creates a SecurityGroup description with just its identifier this method should be used to create plain SecurityGroup objects. @param pe_id [Integer] the id of the object

# File lib/opennebula/security_group.rb, line 41
def SecurityGroup.build_xml(pe_id=nil)
    if pe_id
        obj_xml = "<SECURITY_GROUP><ID>#{pe_id}</ID></SECURITY_GROUP>"
    else
        obj_xml = "<SECURITY_GROUP></SECURITY_GROUP>"
    end

    XMLElement.build_xml(obj_xml,'SECURITY_GROUP')
end
new(xml, client) click to toggle source

Class constructor

Calls superclass method OpenNebula::PoolElement.new
# File lib/opennebula/security_group.rb, line 52
def initialize(xml, client)
    super(xml,client)

    @client = client
end

Public Instance Methods

allocate(description) click to toggle source

Allocates a new SecurityGroup in OpenNebula

@param description [String] The contents of the SecurityGroup.

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

otherwise
Calls superclass method OpenNebula::PoolElement#allocate
# File lib/opennebula/security_group.rb, line 75
def allocate(description)
    super(SECGROUP_METHODS[:allocate], description)
end
chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) click to toggle source

Changes the SecurityGroup permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change

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

otherwise
Calls superclass method OpenNebula::PoolElement#chmod
# File lib/opennebula/security_group.rb, line 120
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
        other_m, other_a)
    super(SECGROUP_METHODS[:chmod], owner_u, owner_m, owner_a, group_u,
        group_m, group_a, other_u, other_m, other_a)
end
chmod_octet(octet) click to toggle source

Changes the SecurityGroup permissions.

@param octet [String] Permissions octed , e.g. 640 @return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method OpenNebula::PoolElement#chmod_octet
# File lib/opennebula/security_group.rb, line 111
def chmod_octet(octet)
    super(SECGROUP_METHODS[:chmod], octet)
end
chown(uid, gid) click to toggle source

Changes the owner/group

@param uid [Integer] the new owner id. Set to -1 to leave the current one @param gid [Integer] the new group id. Set to -1 to leave the current one @return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
Calls superclass method OpenNebula::PoolElement#chown
# File lib/opennebula/security_group.rb, line 102
def chown(uid, gid)
    super(SECGROUP_METHODS[:chown], uid, gid)
end
clone(name) click to toggle source

Clones this SecurityGroup into a new one

@param [String] name for the new SecurityGroup.

@return [Integer, OpenNebula::Error] The new SecurityGroup ID in case

of success, Error otherwise
# File lib/opennebula/security_group.rb, line 132
def clone(name)
    return Error.new('ID not defined') if !@pe_id

    rc = @client.call(SECGROUP_METHODS[:clone], @pe_id, name)

    return rc
end
delete() click to toggle source

Deletes the SecurityGroup

Calls superclass method OpenNebula::PoolElement#delete
# File lib/opennebula/security_group.rb, line 80
def delete()
    super(SECGROUP_METHODS[:delete])
end
gid() click to toggle source

Returns the group identifier

return

Integer the element's group ID

# File lib/opennebula/security_group.rb, line 156
def gid
    self['GID'].to_i
end
info() click to toggle source

Retrieves the information of the given SecurityGroup.

Calls superclass method OpenNebula::PoolElement#info
# File lib/opennebula/security_group.rb, line 63
def info()
    super(SECGROUP_METHODS[:info], 'SECURITY_GROUP')
end
Also aliased as: info!
info!()
Alias for: info
owner_id() click to toggle source
# File lib/opennebula/security_group.rb, line 160
def owner_id
    self['UID'].to_i
end
rename(name) click to toggle source

Renames this SecurityGroup

@param name [String] New name for the SecurityGroup.

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

otherwise
# File lib/opennebula/security_group.rb, line 146
def rename(name)
    return call(SECGROUP_METHODS[:rename], @pe_id, name)
end
update(new_securitygroup, append=false) click to toggle source

Replaces the securitygroup contents

@param new_securitygroup [String] New securitygroup contents @param append [true, false] True to append new attributes instead of

replace the whole securitygroup

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

otherwise
Calls superclass method OpenNebula::PoolElement#update
# File lib/opennebula/security_group.rb, line 92
def update(new_securitygroup, append=false)
    super(SECGROUP_METHODS[:update], new_securitygroup, append ? 1 : 0)
end