class OpenNebula::SecurityGroup
Constants
- SECGROUP_METHODS
Constants and Class Methods
Public Class Methods
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
Class constructor
# File lib/opennebula/security_group.rb, line 52 def initialize(xml, client) super(xml,client) @client = client end
Public Instance Methods
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
# File lib/opennebula/security_group.rb, line 75 def allocate(description) super(SECGROUP_METHODS[:allocate], description) end
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
# 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
Changes the SecurityGroup permissions.
@param octet [String] Permissions octed , e.g. 640 @return [nil, OpenNebula::Error] nil in case of success, Error
otherwise
# File lib/opennebula/security_group.rb, line 111 def chmod_octet(octet) super(SECGROUP_METHODS[:chmod], octet) end
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
# File lib/opennebula/security_group.rb, line 102 def chown(uid, gid) super(SECGROUP_METHODS[:chown], uid, gid) end
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
Deletes the SecurityGroup
# File lib/opennebula/security_group.rb, line 80 def delete() super(SECGROUP_METHODS[:delete]) end
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
Retrieves the information of the given SecurityGroup.
# File lib/opennebula/security_group.rb, line 63 def info() super(SECGROUP_METHODS[:info], 'SECURITY_GROUP') end
# File lib/opennebula/security_group.rb, line 160 def owner_id self['UID'].to_i end
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
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
# File lib/opennebula/security_group.rb, line 92 def update(new_securitygroup, append=false) super(SECGROUP_METHODS[:update], new_securitygroup, append ? 1 : 0) end