def create_vm(session, instance, vm_folder, config_spec, res_pool_ref):
 LOG.debug('Creating VM on the ESX host', instance=instance)
 vm_create_task = session._call_method(session.vim, 'CreateVM_Task', vm_folder, config=config_spec, pool=res_pool_ref)
 try:
  task_info = session._wait_for_task(vm_create_task)
 except vexc.VMwareDriverException:
  with excutils.save_and_reraise_exception():
   if (config_spec.guestId not in constants.VALID_OS_TYPES):
    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"), {'ostype': config_spec.guestId})
 LOG.debug('Created VM on the ESX host', instance=instance)
 return task_info.result

def create_vm ( session , instance , vm_folder , config_spec , res_pool_ref ) : LOG . debug ( 'Creating VM on the ESX host' , instance = instance ) vm_create_task = session . _call_method ( session . vim , 'CreateVM_Task' , vm_folder , config = config_spec , pool = res_pool_ref ) try : task_info = session . _wait_for_task ( vm_create_task ) except vexc . VMwareDriverException : with excutils . save_and_reraise_exception ( ) : if ( config_spec . guestId not in constants . VALID_OS_TYPES ) : 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" ) , { 'ostype' : config_spec . guestId } ) LOG . debug ( 'Created VM on the ESX host' , instance = instance ) return task_info . result
create vm on esx host .