Class: OpenNebula::VirtualNetwork
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::VirtualNetwork
- Defined in:
- opennebula/virtual_network.rb
Constant Summary
- VN_METHODS =
{ :info => "vn.info", :allocate => "vn.allocate", :delete => "vn.delete", :addleases => "vn.addleases", :rmleases => "vn.rmleases", :chown => "vn.chown", :chmod => "vn.chmod", :update => "vn.update", :hold => "vn.hold", :release => "vn.release", :rename => "vn.rename" }
- VN_TYPES =
%w{RANGED FIXED}
- SHORT_VN_TYPES =
{ "RANGED" => "R", "FIXED" => "F" }
Class Method Summary (collapse)
-
+ (Object) build_xml(pe_id = nil)
Creates a VirtualNetwork description with just its identifier this method should be used to create plain VirtualNetwork objects.
Instance Method Summary (collapse)
-
- (Object) addleases(ip, mac = nil)
Adds a lease to the VirtualNetwork.
-
- (Integer, OpenNebula::Error) allocate(description, cluster_id = ClusterPool::NONE_CLUSTER_ID)
Allocates a new VirtualNetwork in OpenNebula.
-
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the virtual network permissions.
-
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the virtual network permissions.
-
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group.
-
- (Object) delete
Deletes the VirtualNetwork.
-
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID.
-
- (Object) hold(ip)
Holds a virtual network Lease as used.
-
- (Object) info
(also: #info!)
Retrieves the information of the given VirtualNetwork.
-
- (VirtualNetwork) initialize(xml, client)
constructor
Class constructor.
- - (Boolean) public?
-
- (Object) publish
Publishes the VirtualNetwork, to be used by other users.
-
- (Object) release(ip)
Releases a virtual network Lease on hold.
-
- (nil, OpenNebula::Error) rename(name)
Renames this virtual network.
-
- (Object) rmleases(ip)
Removes a lease from the VirtualNetwork.
-
- (Object) short_type_str
Returns the state of the Virtual Network (string value).
-
- (Object) type
Returns the type of the Virtual Network (numeric value).
-
- (Object) type_str
Returns the type of the Virtual Network (string value).
-
- (Object) unpublish
Unplubishes the VirtualNetwork.
-
- (Object) update(new_template = nil)
Replaces the template 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
- (VirtualNetwork) initialize(xml, client)
Class constructor
66 67 68 |
# File 'opennebula/virtual_network.rb', line 66 def initialize(xml, client) super(xml,client) end |
Class Method Details
+ (Object) build_xml(pe_id = nil)
Creates a VirtualNetwork description with just its identifier this method should be used to create plain VirtualNetwork objects. id the id of the network
Example:
vnet = VirtualNetwork.new(VirtualNetwork.build_xml(3),rpc_client)
55 56 57 58 59 60 61 62 63 |
# File 'opennebula/virtual_network.rb', line 55 def VirtualNetwork.build_xml(pe_id=nil) if pe_id vn_xml = "<VNET><ID>#{pe_id}</ID></VNET>" else vn_xml = "<VNET></VNET>" end XMLElement.build_xml(vn_xml, 'VNET') end |
Instance Method Details
- (Object) addleases(ip, mac = nil)
Adds a lease to the VirtualNetwork
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'opennebula/virtual_network.rb', line 116 def addleases(ip, mac = nil) return Error.new('ID not defined') if !@pe_id lease_template = "LEASES = [ IP = #{ip}" lease_template << ", MAC = #{mac}" if mac lease_template << " ]" rc = @client.call(VN_METHODS[:addleases], @pe_id, lease_template) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (Integer, OpenNebula::Error) allocate(description, cluster_id = ClusterPool::NONE_CLUSTER_ID)
Allocates a new VirtualNetwork in OpenNebula
88 89 90 |
# File 'opennebula/virtual_network.rb', line 88 def allocate(description,cluster_id=ClusterPool::NONE_CLUSTER_ID) super(VN_METHODS[:allocate], description, cluster_id) end |
- (nil, OpenNebula::Error) chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a)
Changes the virtual network permissions. Each [Integer] argument must be 1 to allow, 0 deny, -1 do not change
192 193 194 195 196 |
# File 'opennebula/virtual_network.rb', line 192 def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) super(VN_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a) end |
- (nil, OpenNebula::Error) chmod_octet(octet)
Changes the virtual network permissions.
183 184 185 |
# File 'opennebula/virtual_network.rb', line 183 def chmod_octet(octet) super(VN_METHODS[:chmod], octet) end |
- (nil, OpenNebula::Error) chown(uid, gid)
Changes the owner/group
174 175 176 |
# File 'opennebula/virtual_network.rb', line 174 def chown(uid, gid) super(VN_METHODS[:chown], uid, gid) end |
- (Object) delete
Deletes the VirtualNetwork
111 112 113 |
# File 'opennebula/virtual_network.rb', line 111 def delete() super(VN_METHODS[:delete]) end |
- (Object) gid
Returns the group identifier
- return
-
Integer the element's group ID
214 215 216 |
# File 'opennebula/virtual_network.rb', line 214 def gid self['GID'].to_i end |
- (Object) hold(ip)
Holds a virtual network Lease as used
143 144 145 146 147 148 149 150 151 152 |
# File 'opennebula/virtual_network.rb', line 143 def hold(ip) return Error.new('ID not defined') if !@pe_id lease_template = "LEASES = [ IP = #{ip} ]" rc = @client.call(VN_METHODS[:hold], @pe_id, lease_template) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (Object) info Also known as: info!
Retrieves the information of the given VirtualNetwork.
75 76 77 |
# File 'opennebula/virtual_network.rb', line 75 def info() super(VN_METHODS[:info], 'VNET') end |
- (Boolean) public?
233 234 235 236 237 238 239 |
# File 'opennebula/virtual_network.rb', line 233 def public? if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" true else false end end |
- (Object) publish
Publishes the VirtualNetwork, to be used by other users
101 102 103 |
# File 'opennebula/virtual_network.rb', line 101 def publish set_publish(true) end |
- (Object) release(ip)
Releases a virtual network Lease on hold
156 157 158 159 160 161 162 163 164 165 |
# File 'opennebula/virtual_network.rb', line 156 def release(ip) return Error.new('ID not defined') if !@pe_id lease_template = "LEASES = [ IP = #{ip} ]" rc = @client.call(VN_METHODS[:release], @pe_id, lease_template) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (nil, OpenNebula::Error) rename(name)
Renames this virtual network
204 205 206 |
# File 'opennebula/virtual_network.rb', line 204 def rename(name) return call(VN_METHODS[:rename], @pe_id, name) end |
- (Object) rmleases(ip)
Removes a lease from the VirtualNetwork
130 131 132 133 134 135 136 137 138 139 |
# File 'opennebula/virtual_network.rb', line 130 def rmleases(ip) return Error.new('ID not defined') if !@pe_id lease_template = "LEASES = [ IP = #{ip} ]" rc = @client.call(VN_METHODS[:rmleases], @pe_id, lease_template) rc = nil if !OpenNebula.is_error?(rc) return rc end |
- (Object) short_type_str
Returns the state of the Virtual Network (string value)
229 230 231 |
# File 'opennebula/virtual_network.rb', line 229 def short_type_str SHORT_VN_TYPES[type_str] end |
- (Object) type
Returns the type of the Virtual Network (numeric value)
219 220 221 |
# File 'opennebula/virtual_network.rb', line 219 def type self['TYPE'].to_i end |
- (Object) type_str
Returns the type of the Virtual Network (string value)
224 225 226 |
# File 'opennebula/virtual_network.rb', line 224 def type_str VN_TYPES[type] end |
- (Object) unpublish
Unplubishes the VirtualNetwork
106 107 108 |
# File 'opennebula/virtual_network.rb', line 106 def unpublish set_publish(false) end |
- (Object) update(new_template = nil)
Replaces the template contents
new_template New template contents. If no argument is provided
the object will be updated using the @xml variable
96 97 98 |
# File 'opennebula/virtual_network.rb', line 96 def update(new_template=nil) super(VN_METHODS[:update], new_template) end |