From d2066c899598a27f45f2583e3990c004f7007e6d Mon Sep 17 00:00:00 2001 From: Kyrylo Maksymenko Date: Thu, 17 Aug 2023 20:12:24 +0200 Subject: [PATCH] fix removing network --- cloudshell/cp/vcenter/flows/connectivity_flow.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cloudshell/cp/vcenter/flows/connectivity_flow.py b/cloudshell/cp/vcenter/flows/connectivity_flow.py index 415bc49..c2b0cd1 100644 --- a/cloudshell/cp/vcenter/flows/connectivity_flow.py +++ b/cloudshell/cp/vcenter/flows/connectivity_flow.py @@ -15,6 +15,7 @@ ) from cloudshell.shell.flows.connectivity.models.connectivity_model import ( ConnectionModeEnum, + is_set_action, ) from cloudshell.cp.vcenter.exceptions import BaseVCenterException @@ -100,7 +101,7 @@ def pre_connectivity( existed_pg_names = set() net_to_create = {} # {(pg_name, host_name): action} - for action in actions: + for action in filter(is_set_action, actions): if pg_name := get_existed_port_group_name(action): existed_pg_names.add(pg_name) else: @@ -306,12 +307,13 @@ def _remove_pg(self, action: VcenterConnectivityActionModel) -> set[str]: if isinstance(network, DVPortGroupHandler): network.destroy() + del network else: vm = self.get_target(action) # remove from the host where the VM is located vm.host.remove_port_group(network.name) - logger.info(f"{network} was removed") - + del network + logger.info(f"Network {pg_name} was removed") return tags def _get_network_tags(