Fixing Bug 1376
This fix will check the port existence before deleting the port.
It will solve the error "Error deleting port: PortNotFoundClient".
Change-Id: I2b0b841c6111578e0d1a0cde9057eb3ab0b5a86a
Signed-off-by: aticig <gulsum.atici@canonical.com>
diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
index 6b46dc1..11a50aa 100644
--- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
+++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
@@ -2295,7 +2295,12 @@
try:
k_item, _, k_id = k.partition(":")
if k_item == "port":
- self.neutron.delete_port(k_id)
+ port_dict = self.neutron.list_ports(device_id=vm_id)
+ existing_ports = [
+ port["id"] for port in port_dict["ports"] if port_dict
+ ]
+ if k_id in existing_ports:
+ self.neutron.delete_port(k_id)
except Exception as e:
self.logger.error(
"Error deleting port: {}: {}".format(type(e).__name__, e)