Class: OpenNebula::VirtualRouter
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::VirtualRouter
- Defined in:
- lib/opennebula/virtual_router.rb
Constant Summary collapse
- VIRTUAL_ROUTER_METHODS =
Constants and Class Methods
{ :allocate => "vrouter.allocate", :instantiate => "vrouter.instantiate", :info => "vrouter.info", :update => "vrouter.update", :delete => "vrouter.delete", :chown => "vrouter.chown", :chmod => "vrouter.chmod", :rename => "vrouter.rename", :attachnic => "vrouter.attachnic", :detachnic => "vrouter.detachnic", :lock => "vrouter.lock", :unlock => "vrouter.unlock" }
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a VirtualRouter description with just its identifier this method should be used to create plain VirtualRouter objects.
Instance Method Summary collapse
-
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new VirtualRouter 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 VirtualRouter permissions.
-
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the VirtualRouter permissions.
-
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group.
-
#delete ⇒ Object
Deletes the VirtualRouter.
-
#gid ⇒ Integer
Returns the group identifier.
-
#info ⇒ Object
(also: #info!)
Retrieves the information of the given Virtual Router.
-
#initialize(xml, client) ⇒ VirtualRouter
constructor
Class constructor.
-
#instantiate(n_vms, template_id, name = "", hold = false, template = "") ⇒ nil, OpenNebula::Error
Creates VM instances from a VM Template.
-
#lock(level) ⇒ Object
Lock a VRouter.
-
#nic_attach(nic_template) ⇒ nil, OpenNebula::Error
Attaches a NIC to this VirtualRouter, and each one of its VMs.
-
#nic_detach(nic_id) ⇒ nil, OpenNebula::Error
Detaches a NIC from this VirtualRouter, and each one of its VMs.
- #owner_id ⇒ Object
-
#rename(name) ⇒ nil, OpenNebula::Error
Renames this VirtualRouter.
-
#unlock ⇒ Object
Unlock a VRouter.
-
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents.
-
#vm_ids ⇒ Object
Returns an array with the numeric VM ids.
Methods inherited from PoolElement
#id, #name, 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) ⇒ VirtualRouter
Class constructor
59 60 61 62 63 |
# File 'lib/opennebula/virtual_router.rb', line 59 def initialize(xml, client) super(xml,client) @client = client end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
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)
48 49 50 51 52 53 54 55 56 |
# 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 |
Instance Method Details
#allocate(description) ⇒ nil, OpenNebula::Error
Allocates a new VirtualRouter in OpenNebula
82 83 84 |
# File 'lib/opennebula/virtual_router.rb', line 82 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) ⇒ nil, OpenNebula::Error
Changes the VirtualRouter permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
146 147 148 149 150 |
# 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 |
#chmod_octet(octet) ⇒ nil, OpenNebula::Error
Changes the VirtualRouter permissions.
137 138 139 |
# File 'lib/opennebula/virtual_router.rb', line 137 def chmod_octet(octet) super(VIRTUAL_ROUTER_METHODS[:chmod], octet) end |
#chown(uid, gid) ⇒ nil, OpenNebula::Error
Changes the owner/group
128 129 130 |
# File 'lib/opennebula/virtual_router.rb', line 128 def chown(uid, gid) super(VIRTUAL_ROUTER_METHODS[:chown], uid, gid) end |
#delete ⇒ Object
Deletes the VirtualRouter
107 108 109 |
# File 'lib/opennebula/virtual_router.rb', line 107 def delete() super(VIRTUAL_ROUTER_METHODS[:delete]) end |
#gid ⇒ Integer
Returns the group identifier
196 197 198 |
# File 'lib/opennebula/virtual_router.rb', line 196 def gid self['GID'].to_i end |
#info ⇒ Object Also known as: info!
Retrieves the information of the given Virtual Router
70 71 72 |
# File 'lib/opennebula/virtual_router.rb', line 70 def info() super(VIRTUAL_ROUTER_METHODS[:info], 'VROUTER') end |
#instantiate(n_vms, template_id, name = "", hold = false, template = "") ⇒ nil, OpenNebula::Error
Creates VM instances from a VM Template. New VMs will be associated to this Virtual Router, and its Virtual Networks
100 101 102 103 |
# 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(level) ⇒ Object
Lock a VRouter
181 182 183 |
# File 'lib/opennebula/virtual_router.rb', line 181 def lock(level) return call(VIRTUAL_ROUTER_METHODS[:lock], @pe_id, level) end |
#nic_attach(nic_template) ⇒ nil, OpenNebula::Error
Attaches a NIC to this VirtualRouter, and each one of its VMs
167 168 169 |
# File 'lib/opennebula/virtual_router.rb', line 167 def nic_attach(nic_template) return call(VIRTUAL_ROUTER_METHODS[:attachnic], @pe_id, nic_template) end |
#nic_detach(nic_id) ⇒ nil, OpenNebula::Error
Detaches a NIC from this VirtualRouter, and each one of its VMs
176 177 178 |
# File 'lib/opennebula/virtual_router.rb', line 176 def nic_detach(nic_id) return call(VIRTUAL_ROUTER_METHODS[:detachnic], @pe_id, nic_id) end |
#owner_id ⇒ Object
200 201 202 |
# File 'lib/opennebula/virtual_router.rb', line 200 def owner_id self['UID'].to_i end |
#rename(name) ⇒ nil, OpenNebula::Error
Renames this VirtualRouter
158 159 160 |
# File 'lib/opennebula/virtual_router.rb', line 158 def rename(name) return call(VIRTUAL_ROUTER_METHODS[:rename], @pe_id, name) end |
#unlock ⇒ Object
Unlock a VRouter
186 187 188 |
# File 'lib/opennebula/virtual_router.rb', line 186 def unlock() return call(VIRTUAL_ROUTER_METHODS[:unlock], @pe_id) end |
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents
119 120 121 |
# 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 |
#vm_ids ⇒ Object
Returns an array with the numeric VM ids
205 206 207 208 209 210 211 212 213 |
# 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 |