</methodCall>'.format(self.user, self.passwd, (str(id_user)), (str(id_group)))
requests.post(self.url, params)
- def new_network(self, net_name, net_type, ip_profile=None, shared=False, vlan=None): # , **vim_specific):
+ def new_network(self, net_name, net_type, ip_profile=None, shared=False, provider_network_profile=None): # , **vim_specific):
"""Adds a tenant network to VIM
Params:
'net_name': name of the network
'dhcp_start_address': ip_schema, first IP to grant
'dhcp_count': number of IPs to grant.
'shared': if this network can be seen/use by other tenants/organization
- 'vlan': in case of a data or ptp net_type, the intended vlan tag to be used for the network
+ 'provider_network_profile': (optional) contains {segmentation-id: vlan, provider-network: vim_netowrk}
Returns a tuple with the network identifier and created_items, or raises an exception on error
created_items can be None or a dictionary where this method can include key-values that will be passed to
the method delete_network. Can be used to store created segments, created l2gw connections, etc.
# oca library method cannot be used in this case (problem with cluster parameters)
try:
+ vlan = None
+ if provider_network_profile:
+ vlan = provider_network_profile.get("segmentation-id")
+ created_items = {}
one = self._new_one_connection()
- ip_prefix_type = "IP"
size = "254"
if ip_profile is None:
subnet_rand = random.randint(0, 255)
vlan_id = vlan
else:
vlan_id = str(random.randint(100, 4095))
-
+ #if "internal" in net_name:
+ # OpenNebula not support two networks with same name
+ random_net_name = str(random.randint(1, 1000000))
+ net_name = net_name + random_net_name
net_id = one.vn.allocate({
'NAME': net_name,
'VN_MAD': '802.1Q',
'PHYDEV': self.config["network"]["phydev"],
'VLAN_ID': vlan_id
}, self.config["cluster"]["id"])
-
- one.vn.add_ar(net_id, {
- 'AR_POOL': {
- 'AR': {
- 'TYPE': 'IP4',
- ip_prefix_type: ip_start,
- 'SIZE': size
+ arpool = {'AR_POOL': {
+ 'AR': {
+ 'TYPE': 'IP4',
+ 'IP': ip_start,
+ 'SIZE': size
+ }
}
- }
- })
-
- return net_id
+ }
+ one.vn.add_ar(net_id, arpool)
+ return net_id, created_items
except Exception as e:
self.logger.error("Create new network error: " + str(e))
raise vimconn.vimconnException(e)
interfaces.append(interface)
return interfaces
except Exception as e:
- self.logger.error("Error getting vm interface_information of vm_id: "+str(vm_element.ID))
-
+ self.logger.error("Error getting vm interface_information of vm_id: " + str(vm_element.ID))