From: Tim Rozet Date: Mon, 25 Jun 2018 20:05:33 +0000 (-0400) Subject: Ignore error if network already undefined X-Git-Tag: opnfv-7.0.0~47 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=6cb6b372fc0f74daf952e04b9d5712c6930cee42;p=apex.git Ignore error if network already undefined In clean we destroy a network, then undefine it. When running snapshot deploy it uses manual virsh bash commands to create the networks and other virsh resources. This leaves an admin network which our clean eventually tries to delete. However when the libvirt api network destroy command is used it is somehow undefining the newtork at the same time. Therefore just catch that possible scenario and ignore the failure as the network has already been removed. Change-Id: Id1d861fbe2a338f0828e78721c09f110030d3a4a Signed-off-by: Tim Rozet --- diff --git a/apex/clean.py b/apex/clean.py index f56287e1..3e33c8e4 100644 --- a/apex/clean.py +++ b/apex/clean.py @@ -114,7 +114,13 @@ def clean_networks(): logging.debug("Destroying virsh network: {}".format(network)) if virsh_net.isActive(): virsh_net.destroy() - virsh_net.undefine() + try: + virsh_net.undefine() + except libvirt.libvirtError as e: + if 'Network not found' in e.get_error_message(): + logging.debug('Network already undefined') + else: + raise def main():