#NEWLINE# def create_vm( session , instance , vm_folder , config_spec , res_pool_ref ) : #NEWLINE# #INDENT# 'Create VM on ESX host.' #NEWLINE# LOG . debug ( 'Creating VM on the ESX host' , instance = instance ) #NEWLINE# vm_create_task = session . _call_method ( session . vim , 'CreateVM_Task' , vm_folder , config = config_spec , pool = res_pool_ref ) #NEWLINE# try : #NEWLINE# #INDENT# task_info = session . _wait_for_task ( vm_create_task ) #NEWLINE# #UNINDENT# except vexc . VMwareDriverException : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# if ( config_spec . guestId not in constants . VALID_OS_TYPES ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( "vmware_ostype from image is not recognised: '%(ostype)s'. An invalid os type may be one cause of this instance creation failure" ) , { #NEWLINE# #INDENT# 'ostype' : config_spec . guestId , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# LOG . debug ( 'Created VM on the ESX host' , instance = instance ) #NEWLINE# return task_info . result