
Methods
public class
public instance
Constants
VN_METHODS | = | { :info => "vn.info", :allocate => "vn.allocate", :publish => "vn.publish", :delete => "vn.delete", :addleases => "vn.addleases", :rmleases => "vn.rmleases" } |
Constants and Class Methods |
Public class methods
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)
# File OpenNebula/VirtualNetwork.rb, line 40 40: def VirtualNetwork.build_xml(pe_id=nil) 41: if pe_id 42: vn_xml = "<VNET><ID>#{pe_id}</ID></VNET>" 43: else 44: vn_xml = "<VNET></VNET>" 45: end 46: 47: XMLElement.build_xml(vn_xml, 'VNET') 48: end
Class constructor
# File OpenNebula/VirtualNetwork.rb, line 51 51: def initialize(xml, client) 52: super(xml,client) 53: 54: @client = client 55: end
Public instance methods
Adds a lease to the VirtualNetwork
# File OpenNebula/VirtualNetwork.rb, line 89 89: def addleases(ip, mac = nil) 90: return Error.new('ID not defined') if !@pe_id 91: 92: lease_template = "LEASES = [ IP = #{ip}" 93: lease_template << ", MAC = #{mac}" if mac 94: lease_template << " ]" 95: 96: rc = @client.call(VN_METHODS[:addleases], @pe_id, lease_template) 97: rc = nil if !OpenNebula.is_error?(rc) 98: 99: return rc 100: end
Allocates a new VirtualNetwork in OpenNebula
description A string containing the template of the VirtualNetwork.
# File OpenNebula/VirtualNetwork.rb, line 69 69: def allocate(description) 70: super(VN_METHODS[:allocate],description) 71: end
Deletes the VirtualNetwork
# File OpenNebula/VirtualNetwork.rb, line 84 84: def delete() 85: super(VN_METHODS[:delete]) 86: end
Retrieves the information of the given VirtualNetwork.
# File OpenNebula/VirtualNetwork.rb, line 62 62: def info() 63: super(VN_METHODS[:info], 'VNET') 64: end
Publishes the VirtualNetwork, to be used by other users
# File OpenNebula/VirtualNetwork.rb, line 74 74: def publish 75: set_publish(true) 76: end
Removes a lease from the VirtualNetwork
# File OpenNebula/VirtualNetwork.rb, line 103 103: def rmleases(ip) 104: return Error.new('ID not defined') if !@pe_id 105: 106: lease_template = "LEASES = [ IP = #{ip} ]" 107: 108: rc = @client.call(VN_METHODS[:rmleases], @pe_id, lease_template) 109: rc = nil if !OpenNebula.is_error?(rc) 110: 111: return rc 112: end
Unplubishes the VirtualNetwork
# File OpenNebula/VirtualNetwork.rb, line 79 79: def unpublish 80: set_publish(false) 81: end