class OpenNebula::VirtualRouter
Constants
- VIRTUAL_ROUTER_METHODS
Constants and Class Methods
Public Class Methods
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
Class constructor
OpenNebula::PoolElement::new
# File lib/opennebula/virtual_router.rb, line 59 def initialize(xml, client) super(xml,client) @client = client end
Public Instance Methods
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
OpenNebula::PoolElement#allocate
# File lib/opennebula/virtual_router.rb, line 82 def allocate(description) super(VIRTUAL_ROUTER_METHODS[:allocate], description) end
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
OpenNebula::PoolElement#chmod
# File lib/opennebula/virtual_router.rb, line 146 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
Changes the VirtualRouter
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/virtual_router.rb, line 137 def chmod_octet(octet) super(VIRTUAL_ROUTER_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/virtual_router.rb, line 128 def chown(uid, gid) super(VIRTUAL_ROUTER_METHODS[:chown], uid, gid) end
Deletes the VirtualRouter
OpenNebula::PoolElement#delete
# File lib/opennebula/virtual_router.rb, line 107 def delete() super(VIRTUAL_ROUTER_METHODS[:delete]) end
Returns the group identifier @return [Integer] the element’s group ID
# File lib/opennebula/virtual_router.rb, line 196 def gid self['GID'].to_i end
Retrieves the information of the given Virtual Router
OpenNebula::PoolElement#info
# File lib/opennebula/virtual_router.rb, line 70 def info() super(VIRTUAL_ROUTER_METHODS[:info], 'VROUTER') end
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 100 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
Lock a VRouter
# File lib/opennebula/virtual_router.rb, line 181 def lock(level) return call(VIRTUAL_ROUTER_METHODS[:lock], @pe_id, level) end
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 167 def nic_attach(nic_template) return call(VIRTUAL_ROUTER_METHODS[:attachnic], @pe_id, nic_template) end
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 176 def nic_detach(nic_id) return call(VIRTUAL_ROUTER_METHODS[:detachnic], @pe_id, nic_id) end
# File lib/opennebula/virtual_router.rb, line 200 def owner_id self['UID'].to_i end
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 158 def rename(name) return call(VIRTUAL_ROUTER_METHODS[:rename], @pe_id, name) end
Unlock a VRouter
# File lib/opennebula/virtual_router.rb, line 186 def unlock() return call(VIRTUAL_ROUTER_METHODS[:unlock], @pe_id) end
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
OpenNebula::PoolElement#update
# File lib/opennebula/virtual_router.rb, line 119 def update(new_template, append=false) super(VIRTUAL_ROUTER_METHODS[:update], new_template, append ? 1 : 0) end
Returns an array with the numeric VM ids
# File lib/opennebula/virtual_router.rb, line 205 def vm_ids array = Array.new self.each("VMS/ID") do |id| array << id.text.to_i end return array end