From 5d5d69cd516138e838e96edf61d2dd28a5d30dba Mon Sep 17 00:00:00 2001 From: Anthony Xu Date: Fri, 7 Sep 2012 17:25:41 -0700 Subject: [PATCH] CS-15921 : in 2.1 timeframe, -untagged string is appended to the end of instance name, in cleanup_rules function, we need to convert chain name to vm name correclty --- scripts/vm/hypervisor/xenserver/vmops | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops index 79b67e71380..05a2ccf6949 100755 --- a/scripts/vm/hypervisor/xenserver/vmops +++ b/scripts/vm/hypervisor/xenserver/vmops @@ -1087,17 +1087,13 @@ def cleanup_rules(session, args): cleaned = 0 cleanup = [] for chain in vmchains: - vm = session.xenapi.VM.get_by_name_label(chain) - if len(vm) != 1: - vm = session.xenapi.VM.get_by_name_label(chain + "-untagged") - if len(vm) != 1: - util.SMlog("chain " + chain + " does not correspond to a vm, cleaning up") + vmname = chain + if vmname not in resident_vms: + vmname = chain + "-untagged" + if vmname not in resident_vms: + util.SMlog("vm " + chain + " is not running on this host, cleaning up") cleanup.append(chain) - continue - if chain not in resident_vms: - util.SMlog("vm " + chain + " is not running, cleaning up") - cleanup.append(chain) - + for vm_name in cleanup: destroy_network_rules_for_vm(session, {'vmName':vm_name})