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
This commit is contained in:
Anthony Xu 2012-08-20 18:09:27 -07:00
parent 6d06b84879
commit 368f972cc4
1 changed files with 4 additions and 10 deletions

View File

@ -1053,17 +1053,11 @@ def cleanup_rules(session, args):
cleanup = []
for chain in vmchains:
vmname = chain
vm = session.xenapi.VM.get_by_name_label(vmname)
if len(vm) != 1:
vmname = chain + "-untagged"
vm = session.xenapi.VM.get_by_name_label(vmname)
if len(vm) != 1:
util.SMlog("chain " + chain + " does not correspond to a vm, cleaning up")
cleanup.append(vmname)
continue
if vmname not in resident_vms:
util.SMlog("vm " + vmname + " is not running on this host, cleaning up")
cleanup.append(vmname)
vmname = chain + "-untagged"
if vmname not in resident_vms:
util.SMlog("vm " + chain + " is not running on this host, cleaning up")
cleanup.append(chain)
for vm_name in cleanup:
destroy_network_rules_for_vm(session, {'vmName':vm_name})