self._reload_connection()
network_dict = {"name": net_name, "admin_state_up": True}
- if net_type in ("data", "ptp"):
+ if net_type in ("data", "ptp") or provider_network_profile:
provider_physical_network = None
if provider_network_profile and provider_network_profile.get(
# For VF
elif net["type"] == "VF" or net["type"] == "SR-IOV":
-
port_dict["binding:vnic_type"] = "direct"
# VIO specific Changes
key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id"
if disk.get(key_id):
-
block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id]
existing_vim_volumes.append({"id": disk[key_id]})
key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id"
if disk.get(key_id):
-
# Use existing persistent volume
block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id]
existing_vim_volumes.append({"id": disk[key_id]})
return self.neutron.show_floatingip(free_floating_ip)
def _get_free_floating_ip(
- self, server: object, floating_network: dict, created_items: dict
+ self, server: object, floating_network: dict
) -> Optional[str]:
"""Get the free floating IP address.
Args:
server (object): Server Object
floating_network (dict): Floating network details
- created_items (dict): All created items belongs to new VM instance
Returns:
free_floating_ip (str): Free floating ip addr
# Randomize
random.shuffle(floating_ips)
- return self._find_floating_ip(
- server, floating_ips, floating_network, created_items
- )
+ return self._find_floating_ip(server, floating_ips, floating_network)
def _prepare_external_network_for_vminstance(
self,
# In case of RO in HA there can be conflicts, two RO trying to assign same floating IP, so retry
# several times
while not assigned:
-
free_floating_ip = self._get_free_floating_ip(
- server, floating_network, created_items
+ server, floating_network
)
if not free_floating_ip:
self.neutron.update_port(port[0], port_update)
except Exception:
-
raise vimconn.VimConnException(
"It was not possible to disable port security for port {}".format(
port[0]
k_id (str): Port id in the VIM
"""
try:
-
port_dict = self.neutron.list_ports()
existing_ports = [port["id"] for port in port_dict["ports"] if port_dict]
self.neutron.delete_port(k_id)
except Exception as e:
-
self.logger.error("Error deleting port: {}: {}".format(type(e).__name__, e))
def _delete_volumes_by_id_wth_cinder(
k_item, k_id = self._get_item_name_id(k)
if k_item == "volume":
-
unavailable_vol = self._delete_volumes_by_id_wth_cinder(
k, k_id, volumes_to_hold, created_items
)
keep_waiting = True
elif k_item == "floating_ip":
-
self._delete_floating_ip_by_id(k, k_id, created_items)
except Exception as e:
def action_vminstance(self, vm_id, action_dict, created_items={}):
"""Send and action over a VM instance from VIM
- Returns None or the console dict if the action was successfully sent to the VIM"""
+ Returns None or the console dict if the action was successfully sent to the VIM
+ """
self.logger.debug("Action over VM '%s': %s", vm_id, str(action_dict))
try: