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 42 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
OpenNebula::PoolElement::new
# File lib/opennebula/security_group.rb, line 53 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
OpenNebula::PoolElement#allocate
# File lib/opennebula/security_group.rb, line 76 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
OpenNebula::PoolElement#chmod
# File lib/opennebula/security_group.rb, line 121 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
OpenNebula::PoolElement#chmod_octet
# File lib/opennebula/security_group.rb, line 112 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
OpenNebula::PoolElement#chown
# File lib/opennebula/security_group.rb, line 103 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 133 def clone(name) return Error.new('ID not defined') if !@pe_id rc = @client.call(SECGROUP_METHODS[:clone], @pe_id, name) return rc end
Commit SG changes to associated VMs
@param recover [Bool] If true will only operate on outdated and error VMs. This is intended for retrying updates of VMs or reinitialize the updating process if oned stopped or fail.
@return [nil, OpenNebula::Error] nil in case of success, Error
otherwise
# File lib/opennebula/security_group.rb, line 159 def commit(recover) return call(SECGROUP_METHODS[:commit], @pe_id, recover) end
Deletes the SecurityGroup
OpenNebula::PoolElement#delete
# File lib/opennebula/security_group.rb, line 81 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 197 def gid self['GID'].to_i end
Retrieves the information of the given SecurityGroup
.
OpenNebula::PoolElement#info
# File lib/opennebula/security_group.rb, line 64 def info() super(SECGROUP_METHODS[:info], 'SECURITY_GROUP') end
# File lib/opennebula/security_group.rb, line 201 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 147 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
OpenNebula::PoolElement#update
# File lib/opennebula/security_group.rb, line 93 def update(new_securitygroup, append=false) super(SECGROUP_METHODS[:update], new_securitygroup, append ? 1 : 0) end
Returns three arrays with the numeric vm ids for vms updated, outdated (include updating) and error
# File lib/opennebula/security_group.rb, line 169 def vm_ids updated = Array.new self.each("UPDATED_VMS/ID") do |id| updated << id.text.to_i end outdated = Array.new self.each("OUTDATED_VMS/ID") do |id| outdated << id.text.to_i end self.each("UPDATING_VMS/ID") do |id| outdated << id.text.to_i end error = Array.new self.each("ERROR_VMS/ID") do |id| error << id.text.to_i end return [updated, outdated, error] end