def main(content,vm_name):
VM = get_obj(content, [vim.VirtualMachine], vm_name)
if not VM:
print(VM, '不存在')
return
print("Found: {0}".format(VM.name))
print("The current powerState is: {0}".format(VM.runtime.powerState))
if format(VM.runtime.powerState) == "poweredOn":
print("Attempting to power off {0}".format(VM.name))
TASK = VM.PowerOffVM_Task()
wait_for_tasks(content, [TASK])
print("{0}".format(TASK.info.state))
print("Destroying VM from vSphere.")
TASK = VM.Destroy_Task()
wait_for_tasks(content, [TASK])
请教一下这段代码,哪些地方会出现线程安全问题?
我自己的想法是: 每个线程携带进来的参数不同,虽然,存在if判断,但是每个线程获得的VM是不相同的。下面的if语句同理。请教大神指点指点。 |