Class: OpenNebula::VMGroup

Inherits:
PoolElement show all
Defined in:
lib/opennebula/vm_group.rb

Constant Summary collapse

VMGROUP_METHODS =

Constants and Class Methods

{
    :allocate    => "vmgroup.allocate",
    :info        => "vmgroup.info",
    :update      => "vmgroup.update",
    :delete      => "vmgroup.delete",
    :chown       => "vmgroup.chown",
    :chmod       => "vmgroup.chmod",
    :rename      => "vmgroup.rename",
    :lock        => "vmgroup.lock",
    :unlock      => "vmgroup.unlock",
    :roleadd     => "vmgroup.roleadd",
    :roledelete  => "vmgroup.roledelete",
    :roleupdate  => "vmgroup.roleupdate"
}

Instance Attribute Summary

Attributes inherited from PoolElement

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PoolElement

#id, new_with_id, #replace, #to_str

Methods inherited from XMLElement

#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?

Constructor Details

#initialize(xml, client) ⇒ VMGroup

Class constructor



54
55
56
57
58
59
60
# File 'lib/opennebula/vm_group.rb', line 54

def initialize(xml, client)
    LockableExt.make_lockable(self, VMGROUP_METHODS)

    super(xml,client)

    @client = client
end

Class Method Details

.build_xml(pe_id = nil) ⇒ Object

Creates a VMGroup description with just its identifier this method should be used to create plain VMGroup objects.

Parameters:

  • pe_id (Integer) (defaults to: nil)

    the id of the object



43
44
45
46
47
48
49
50
51
# File 'lib/opennebula/vm_group.rb', line 43

def VMGroup.build_xml(pe_id=nil)
    if pe_id
        obj_xml = "<VM_GROUP><ID>#{pe_id}</ID></VM_GROUP>"
    else
        obj_xml = "<VM_GROUP></VM_GROUP>"
    end

    XMLElement.build_xml(obj_xml,'VM_GROUP')
end

Instance Method Details

#allocate(description) ⇒ nil, OpenNebula::Error

Allocates a new VMGroup in OpenNebula

Parameters:

  • description (String)

    The contents of the VMGroup.

Returns:



79
80
81
# File 'lib/opennebula/vm_group.rb', line 79

def allocate(description)
    super(VMGROUP_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

Returns:



124
125
126
127
128
# File 'lib/opennebula/vm_group.rb', line 124

def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
        other_m, other_a)
    super(VMGROUP_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.

Parameters:

  • octet (String)

    Permissions octed , e.g. 640

Returns:



115
116
117
# File 'lib/opennebula/vm_group.rb', line 115

def chmod_octet(octet)
    super(VMGROUP_METHODS[:chmod], octet)
end

#chown(uid, gid) ⇒ nil, OpenNebula::Error

Changes the owner/group

Parameters:

  • uid (Integer)

    the new owner id. Set to -1 to leave the current one

  • gid (Integer)

    the new group id. Set to -1 to leave the current one

Returns:



106
107
108
# File 'lib/opennebula/vm_group.rb', line 106

def chown(uid, gid)
    super(VMGROUP_METHODS[:chown], uid, gid)
end

#deleteObject

Deletes the SecurityGroup



84
85
86
# File 'lib/opennebula/vm_group.rb', line 84

def delete()
    super(VMGROUP_METHODS[:delete])
end

#gidObject

Returns the group identifier

return

Integer the element’s group ID



177
178
179
# File 'lib/opennebula/vm_group.rb', line 177

def gid
    self['GID'].to_i
end

#infoObject Also known as: info!

Retrieves the information of the VMGroup.



67
68
69
# File 'lib/opennebula/vm_group.rb', line 67

def info()
    super(VMGROUP_METHODS[:info], 'VM_GROUP')
end

#owner_idObject



181
182
183
# File 'lib/opennebula/vm_group.rb', line 181

def owner_id
    self['UID'].to_i
end

#rename(name) ⇒ nil, OpenNebula::Error

Renames this VMGroup

Parameters:

  • name (String)

    New name for the VMGroup.

Returns:



136
137
138
# File 'lib/opennebula/vm_group.rb', line 136

def rename(name)
    return call(VMGROUP_METHODS[:rename], @pe_id, name)
end

#role_add(template) ⇒ nil, OpenNebula::Error

Add role to VM Group

Parameters:

  • template (String)

    String template for the new role

Returns:



146
147
148
# File 'lib/opennebula/vm_group.rb', line 146

def role_add(template)
    return call(VMGROUP_METHODS[:roleadd], @pe_id, template)
end

#role_delete(roleid) ⇒ nil, OpenNebula::Error

Delete role from VM Group

Parameters:

  • roleid (Integer)

    ID of the role to remove

Returns:



156
157
158
# File 'lib/opennebula/vm_group.rb', line 156

def role_delete(roleid)
    return call(VMGROUP_METHODS[:roledelete], @pe_id, roleid)
end

#role_namesObject

return

Array with the name of roles



186
187
188
# File 'lib/opennebula/vm_group.rb', line 186

def role_names
    self.retrieve_elements('ROLES/ROLE/NAME')
end

#role_update(roleid, template) ⇒ nil, OpenNebula::Error

Update VM Group role

Parameters:

  • roleid (Integer)

    ID of the role to remove

  • template (String)

    String template with updated values

Returns:



167
168
169
# File 'lib/opennebula/vm_group.rb', line 167

def role_update(roleid, template)
    return call(VMGROUP_METHODS[:roleupdate], @pe_id, roleid, template)
end

#update(new_vmgroup, append = false) ⇒ nil, OpenNebula::Error

Replaces the vm group contents

Parameters:

  • new_vmgroup (String)

    New vmgroup contents

  • append (true, false) (defaults to: false)

    True to append new attributes instead of replace the whole securitygroup

Returns:



96
97
98
# File 'lib/opennebula/vm_group.rb', line 96

def update(new_vmgroup, append=false)
    super(VMGROUP_METHODS[:update], new_vmgroup, append ? 1 : 0)
end