class OpenNebula::VirtualRouter

Constants

VIRTUAL_ROUTER_METHODS

Constants and Class Methods

Public Class Methods

build_xml(pe_id=nil) click to toggle source

Creates a VirtualRouter description with just its identifier this method should be used to create plain VirtualRouter objects. id the id of the user

Example:

vrouter = VirtualRouter.new(VirtualRouter.build_xml(3),rpc_client)
# File lib/opennebula/virtual_router.rb, line 48
def VirtualRouter.build_xml(pe_id=nil)
    if pe_id
        obj_xml = "<VROUTER><ID>#{pe_id}</ID></VROUTER>"
    else
        obj_xml = "<VROUTER></VROUTER>"
    end

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

Class constructor

Calls superclass method OpenNebula::PoolElement::new
# File lib/opennebula/virtual_router.rb, line 59
def initialize(xml, client)
    LockableExt.make_lockable(self, VIRTUAL_ROUTER_METHODS)

    super(xml,client)

    @client = client
end

Public Instance Methods

allocate(description) click to toggle source

Allocates a new VirtualRouter in OpenNebula

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

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

otherwise
Calls superclass method OpenNebula::PoolElement#allocate
# File lib/opennebula/virtual_router.rb, line 84
def allocate(description)
    super(VIRTUAL_ROUTER_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 VirtualRouter 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/virtual_router.rb, line 148
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
        other_m, other_a)
    super(VIRTUAL_ROUTER_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 VirtualRouter 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/virtual_router.rb, line 139
def chmod_octet(octet)
    super(VIRTUAL_ROUTER_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/virtual_router.rb, line 130
def chown(uid, gid)
    super(VIRTUAL_ROUTER_METHODS[:chown], uid, gid)
end
delete() click to toggle source

Deletes the VirtualRouter

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

Returns the group identifier @return [Integer] the element’s group ID

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

Retrieves the information of the given Virtual Router

Calls superclass method OpenNebula::PoolElement#info
# File lib/opennebula/virtual_router.rb, line 72
def info()
    super(VIRTUAL_ROUTER_METHODS[:info], 'VROUTER')
end
Also aliased as: info!
info!()
Alias for: info
instantiate(n_vms, template_id, name="", hold=false, template="") click to toggle source

Creates VM instances from a VM Template. New VMs will be associated to this Virtual Router, and its Virtual Networks

@para n_vms [Integer] Number of VMs to instantiate @para template_id [Integer] VM Template id to instantiate @param name [String] Name for the VM instances. If it is an empty

string OpenNebula will set a default name. Wildcard %i can be used.

@param hold [true,false] false to create the VM in pending state,

true to create it on hold

@param template [String] User provided Template to merge with the

one being instantiated

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

otherwise
# File lib/opennebula/virtual_router.rb, line 102
def instantiate(n_vms, template_id, name="", hold=false, template="")
    return call(VIRTUAL_ROUTER_METHODS[:instantiate], @pe_id,
                n_vms.to_i, template_id.to_i, name, hold, template)
end
nic_attach(nic_template) click to toggle source

Attaches a NIC to this VirtualRouter, and each one of its VMs

@param nic_template [String] Template containing a NIC element @return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
# File lib/opennebula/virtual_router.rb, line 169
def nic_attach(nic_template)
    return call(VIRTUAL_ROUTER_METHODS[:attachnic], @pe_id, nic_template)
end
nic_detach(nic_id) click to toggle source

Detaches a NIC from this VirtualRouter, and each one of its VMs

@param nic_id [Integer] Id of the NIC to be detached @return [nil, OpenNebula::Error] nil in case of success, Error

otherwise
# File lib/opennebula/virtual_router.rb, line 178
def nic_detach(nic_id)
    return call(VIRTUAL_ROUTER_METHODS[:detachnic], @pe_id, nic_id)
end
owner_id() click to toggle source
# File lib/opennebula/virtual_router.rb, line 192
def owner_id
    self['UID'].to_i
end
rename(name) click to toggle source

Renames this VirtualRouter

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

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

otherwise
# File lib/opennebula/virtual_router.rb, line 160
def rename(name)
    return call(VIRTUAL_ROUTER_METHODS[:rename], @pe_id, name)
end
update(new_template, append=false) click to toggle source

Replaces the template contents

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

replace the whole template

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

otherwise
Calls superclass method OpenNebula::PoolElement#update
# File lib/opennebula/virtual_router.rb, line 121
def update(new_template, append=false)
    super(VIRTUAL_ROUTER_METHODS[:update], new_template, append ? 1 : 0)
end
vm_ids() click to toggle source

Returns an array with the numeric VM ids

# File lib/opennebula/virtual_router.rb, line 197
def vm_ids
    array = Array.new

    self.each("VMS/ID") do |id|
        array << id.text.to_i
    end

    return array
end