docs: def vm_configured(name, vm_name, cpu, memory, image, version, interfaces,
                    disks, scsi_devices, serial_ports, datacenter, datastore,
                    placement, cd_dvd_drives=None, sata_controllers=None,
                    advanced_configs=None, template=None, tools=True,
                    power_on=False, deploy=False):
      '''
      Selects the correct operation to be executed on a virtual machine, non
      existing machines will be created, existing ones will be updated if the
      config differs.
      '''
      result = {'name': name,
                'result': None,
                'changes': {},
                'comment': ''}
  
      log.trace('Validating virtual machine configuration')
      schema = ESXVirtualMachineConfigSchema.serialize()
      log.trace('schema = %s', schema)
      try:
          jsonschema.validate({'vm_name': vm_name,
                               'cpu': cpu,
                               'memory': memory,
                               'image': image,
                               'version': version,
                               'interfaces': interfaces,
                               'disks': disks,
                               'scsi_devices': scsi_devices,
                               'serial_ports': serial_ports,
                               'cd_dvd_drives': cd_dvd_drives,
                               'sata_controllers': sata_controllers,
                               'datacenter': datacenter,
                               'datastore': datastore,
                               'placement': placement,
                               'template': template,
                               'tools': tools,
                               'power_on': power_on,
                               'deploy': deploy}, schema)
      except jsonschema.exceptions.ValidationError as exc:
          raise salt.exceptions.InvalidConfigError(exc)
  
      service_instance = __salt__['vsphere.get_service_instance_via_proxy']()
      try:
          __salt__['vsphere.get_vm'](vm_name, vm_properties=['name'],
                                     service_instance=service_instance)
      except salt.exceptions.VMwareObjectRetrievalError:
          vm_file = __salt__['vsphere.get_vm_config_file'](
              vm_name, datacenter,
              placement, datastore,
              service_instance=service_instance)
          if vm_file:
              if __opts__['test']:
                  result.update({'comment': 'The virtual machine {0}'
                                            ' will be registered.'.format(vm_name)})
                  __salt__['vsphere.disconnect'](service_instance)
                  return result
              result = vm_registered(vm_name, datacenter, placement,
                                     vm_file, power_on=power_on)
              return result
          else:
              if __opts__['test']:
                  result.update({'comment': 'The virtual machine {0}'
                                            ' will be created.'.format(vm_name)})
                  __salt__['vsphere.disconnect'](service_instance)
                  return result
              if template:
                  result = vm_cloned(name)
              else:
                  result = vm_created(name, vm_name, cpu, memory, image, version,
                                      interfaces, disks, scsi_devices,
                                      serial_ports, datacenter, datastore,
                                      placement, cd_dvd_drives=cd_dvd_drives,
                                      advanced_configs=advanced_configs,
                                      power_on=power_on)
              return result
  
      result = vm_updated(name, vm_name, cpu, memory, image, version,
                          interfaces, disks, scsi_devices,
                          serial_ports, datacenter, datastore,
                          cd_dvd_drives=cd_dvd_drives,
                          sata_controllers=sata_controllers,
                          advanced_configs=advanced_configs,
                          power_on=power_on)
      __salt__['vsphere.disconnect'](service_instance)
  
      log.trace(result)
      return result