#NEWLINE# def run( self , name , template_id , datacenter_id , resourcepool_id , datastore_id ) : #NEWLINE# #INDENT# template = inventory . get_virtualmachine ( self . si_content , template_id ) #NEWLINE# datacenter = inventory . get_datacenter ( relocatespec . si_content , datacenter_id ) #NEWLINE# resourcepool = inventory . get_resource_pool ( self . si_content , resourcepool_id ) #NEWLINE# datastore = inventory . get_datastore ( self . si_content , datastore_id ) #NEWLINE# target_folder = datacenter . vmFolder #NEWLINE# relocatespec = vim . vm . RelocateSpec ( ) #NEWLINE# relocatespec . datastore = datastore #NEWLINE# relocatespec . pool = resourcepool #NEWLINE# clonespec = vim . vm . CloneSpec ( ) #NEWLINE# clonespec . location = relocatespec #NEWLINE# clonespec . powerOn = False #NEWLINE# clonespec . template = False #NEWLINE# task = template . CloneVM_Task ( folder = target_folder , name = name , spec = clonespec ) #NEWLINE# self . _wait_for_task ( task ) #NEWLINE# if ( task . info . state != vim . TaskInfo . State . success ) : #NEWLINE# #INDENT# raise Exception ( task . info . error . msg ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'task_id' : task . _moId , #NEWLINE# 'vm_id' : task . info . result . _moId , #NEWLINE# #UNINDENT# }