Class: OpenNebula::SecurityGroup
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::SecurityGroup
- Defined in:
- lib/opennebula/security_group.rb
Constant Summary collapse
- SECGROUP_METHODS =
{ :allocate => "secgroup.allocate", :info => "secgroup.info", :update => "secgroup.update", :delete => "secgroup.delete", :chown => "secgroup.chown", :chmod => "secgroup.chmod", :clone => "secgroup.clone", :rename => "secgroup.rename" }
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a SecurityGroup description with just its identifier this method should be used to create plain SecurityGroup objects.
Instance Method Summary collapse
-
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new SecurityGroup in OpenNebula.
-
#chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) ⇒ nil, OpenNebula::Error
Changes the SecurityGroup permissions.
-
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the SecurityGroup permissions.
-
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group.
-
#clone(name) ⇒ Integer, OpenNebula::Error
Clones this SecurityGroup into a new one.
-
#delete ⇒ Object
Deletes the SecurityGroup.
-
#gid ⇒ Object
Returns the group identifier [return] Integer the element’s group ID.
-
#info ⇒ Object
(also: #info!)
Retrieves the information of the given SecurityGroup.
-
#initialize(xml, client) ⇒ SecurityGroup
constructor
Class constructor.
- #owner_id ⇒ Object
-
#rename(name) ⇒ nil, OpenNebula::Error
Renames this SecurityGroup.
-
#update(new_securitygroup, append = false) ⇒ nil, OpenNebula::Error
Replaces the securitygroup contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
#initialize(xml, client) ⇒ SecurityGroup
Class constructor
52 53 54 55 56 |
# File 'lib/opennebula/security_group.rb', line 52 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
Creates a SecurityGroup description with just its identifier this method should be used to create plain SecurityGroup objects.
41 42 43 44 45 46 47 48 49 |
# 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 |
Instance Method Details
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new SecurityGroup in OpenNebula
75 76 77 |
# 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) ⇒ nil, OpenNebula::Error
Changes the SecurityGroup permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
120 121 122 123 124 |
# 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) ⇒ nil, OpenNebula::Error
Changes the SecurityGroup permissions.
111 112 113 |
# File 'lib/opennebula/security_group.rb', line 111 def chmod_octet(octet) super(SECGROUP_METHODS[:chmod], octet) end |
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group
102 103 104 |
# File 'lib/opennebula/security_group.rb', line 102 def chown(uid, gid) super(SECGROUP_METHODS[:chown], uid, gid) end |
#clone(name) ⇒ Integer, OpenNebula::Error
Clones this SecurityGroup into a new one
132 133 134 135 136 137 138 |
# 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 ⇒ Object
Deletes the SecurityGroup
80 81 82 |
# File 'lib/opennebula/security_group.rb', line 80 def delete() super(SECGROUP_METHODS[:delete]) end |
#gid ⇒ Object
Returns the group identifier
- return
-
Integer the element’s group ID
156 157 158 |
# File 'lib/opennebula/security_group.rb', line 156 def gid self['GID'].to_i end |
#info ⇒ Object Also known as: info!
Retrieves the information of the given SecurityGroup.
63 64 65 |
# File 'lib/opennebula/security_group.rb', line 63 def info() super(SECGROUP_METHODS[:info], 'SECURITY_GROUP') end |
#owner_id ⇒ Object
160 161 162 |
# File 'lib/opennebula/security_group.rb', line 160 def owner_id self['UID'].to_i end |
#rename(name) ⇒ nil, OpenNebula::Error
Renames this SecurityGroup
146 147 148 |
# 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) ⇒ nil, OpenNebula::Error
Replaces the securitygroup contents
92 93 94 |
# File 'lib/opennebula/security_group.rb', line 92 def update(new_securitygroup, append=false) super(SECGROUP_METHODS[:update], new_securitygroup, append ? 1 : 0) end |