power on the specified vm
        :param si:
        :param logger:
        :param session:
        :param vm_uuid: the uuid of the vm
        :param resource_fullname: the full name of the deployed app resource
        :return:
180217
def power_on(self, si, logger, session, vm_uuid, resource_fullname):
        
        logger.info('retrieving vm by uuid: {0}'.format(vm_uuid))
        vm = self.pv_service.find_by_uuid(si, vm_uuid)

        if vm.summary.runtime.powerState == 'poweredOn':
            logger.info('vm already powered on')
            task_result = 'Already powered on'
        else:
            logger.info('powering on vm')
            task = vm.PowerOn()
            task_result = self.synchronous_task_waiter.wait_for_task(task=task,
                                                                     logger=logger,
                                                                     action_name='Power On')

        return task_result
1029723
def load_all_resources():
    
    pkgname = resources.__name__
    for importer, mod_name, _ in pkgutil.iter_modules(resources.__path__):
        full_mod_name = '%s.%s' % (pkgname, mod_name)
        if full_mod_name not in sys.modules:
            module = importer.find_module(mod_name
                        ).load_module(full_mod_name)
            log.debug("Loaded resource from: %s", module)
1030807
public OvhVirtualNetworkInterface virtualNetworkInterface_uuid_GET(String uuid) throws IOException {
		String qPath = "/dedicated/server/virtualNetworkInterface/{uuid}";
		StringBuilder sb = path(qPath, uuid);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhVirtualNetworkInterface.class);
	}
18829
def _provision_vm(name=None, session=None):
    '''
    
    '''
    if session is None:
        session = _get_session()
    log.info('Provisioning VM %s', name)
    vm = _get_vm(name, session)
    task = session.xenapi.Async.VM.provision(vm)
    _run_async_task(task, session)
1264130
def list_nodes_full(session=None):
    '''
    

    '''
    if session is None:
        session = _get_session()

    ret = {}
    vms = session.xenapi.VM.get_all()
    for vm in vms:
        record = session.xenapi.VM.get_record(vm)
        if not record['is_a_template'] and not record['is_control_domain']:
            # deal with cases where the VM doesn't have 'base_template_name' attribute
            try:
                base_template_name = record['other_config']['base_template_name']
            except Exception:
                base_template_name = None
                log.debug(
                    'VM %s, doesnt have base_template_name attribute',
                    record['name_label']
                )
            vm_cfg = session.xenapi.VM.get_record(vm)
            vm_cfg['id'] = record['uuid']
            vm_cfg['name'] = record['name_label']
            vm_cfg['image'] = base_template_name
            vm_cfg['size'] = None
            vm_cfg['state'] = record['power_state']
            vm_cfg['private_ips'] = get_vm_ip(record['name_label'], session)
            vm_cfg['public_ips'] = None
            if 'snapshot_time' in vm_cfg.keys():
                del vm_cfg['snapshot_time']
            ret[record['name_label']] = vm_cfg

    provider = __active_provider_name__ or 'xen'
    if ':' in provider:
        comps = provider.split(':')
        provider = comps[0]
    log.debug('ret: %s', ret)
    log.debug('provider: %s', provider)
    log.debug('__opts__: %s', __opts__)
    __utils__['cloud.cache_node_list'](ret, provider, __opts__)
    return ret
813419
def _get_vm_status(self):
        

        result = yield from self._control_vm("info status", [
            b"debug", b"inmigrate", b"internal-error", b"io-error",
            b"paused", b"postmigrate", b"prelaunch", b"finish-migrate",
            b"restore-vm", b"running", b"save-vm", b"shutdown", b"suspended",
            b"watchdog", b"guest-panicked"
        ])
        if result is None:
            return result
        status = result.rsplit(' ', 1)[1]
        if status == "running" or status == "prelaunch":
            self.status = "started"
        elif status == "suspended":
            self.status = "suspended"
        elif status == "shutdown":
            self.status = "stopped"
        return status
1333156
def get_resource(self, name):
        ''

        if name in self.resources:
            return self.resources[name]
        elif name in self.pushable_resources:
            return self.pushable_resources[name]
        else:
            return False
929569
def destroy_vm_by_name(self, si, vm_name, vm_path, logger):
        
        if vm_name is not None:
            vm = self.find_vm_by_name(si, vm_path, vm_name)
            if vm:
                return self.destroy_vm(vm, logger)
        raise ValueError('vm not found')
1167836
def power_off
      target = entity_xml
      class_name = self.class.name.split("::").last
      Config.logger.debug "#{class_name} status: #{target[:status]}"
      if is_status?(target, :SUSPENDED)
        error_msg = "#{class_name} #{target.name} suspended, discard state before powering off."
        fail class_name == "VApp" ? VappSuspendedError : VmSuspendedError,
             error_msg
      end
      if is_status?(target, :POWERED_OFF)
        Config.logger.info "#{class_name} #{target.name} is already powered off."
        return
      end

      power_off_link = target.power_off_link
      unless power_off_link
        fail CloudError, "#{class_name} #{target.name} is not in a state that could be powered off."
      end

      task = connection.post(power_off_link.href, nil)
      monitor_task task, @session.time_limit[:power_off]
      Config.logger.info "#{class_name} #{target.name} is powered off."

      undeploy(target, class_name)
      self
    end
1272976
def find_vm(self, name):
        
        try:
            domain = self.hyper.lookupByName(name)
            VM = VirtualMachine(domain, self)
        except libvirtError:
            VM = None
        return VM
36472
def get_resource_by_id(resource_id, api_version, extract_value=None):
    '''
    
    '''
    ret = {}

    try:
        resconn = get_conn(client_type='resource')
        resource_query = resconn.resources.get_by_id(
            resource_id=resource_id,
            api_version=api_version
        )
        resource_dict = resource_query.as_dict()
        if extract_value is not None:
            ret = resource_dict[extract_value]
        else:
            ret = resource_dict
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', exc.message)
        ret = {'Error': exc.message}

    return ret
1147635
def get_vm_ids_by_ud(access_token, subscription_id, resource_group, vmssname, updatedomain):
    ''''''
    instance_viewlist = azurerm.list_vmss_vm_instance_view(access_token, subscription_id,
                                                           resource_group, vmssname)
    # print(json.dumps(instance_viewlist, sort_keys=False, indent=2, separators=(',', ': ')))

    # loop through the instance view list, and build the vm id list of VMs in
    # the matching UD
    udinstancelist = []
    for instance_view in instance_viewlist['value']:
        vmud = instance_view['properties']['instance_view']['platformUpdateDomain']
        if vmud == updatedomain:
            udinstancelist.append(instance_view['instanceId'])
    udinstancelist.sort()
    return udinstancelist
1305619
def get_vm_id(kwargs=None, call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The get_vm_id function must be called with -f or --function.'
        )

    if kwargs is None:
        kwargs = {}

    name = kwargs.get('name', None)
    if name is None:
        raise SaltCloudSystemExit(
            'The get_vm_id function requires a name.'
        )

    try:
        ret = list_nodes()[name]['id']
    except KeyError:
        raise SaltCloudSystemExit(
            'The VM \'{0}\' could not be found.'.format(name)
        )

    return ret
261125
def setmem(vm_, memory):
    '''
    
    '''
    with _get_xapi_session() as xapi:
        mem_target = int(memory) * 1024 * 1024

        vm_uuid = _get_label_uuid(xapi, 'VM', vm_)
        if vm_uuid is False:
            return False
        try:
            xapi.VM.set_memory_dynamic_max_live(vm_uuid, mem_target)
            xapi.VM.set_memory_dynamic_min_live(vm_uuid, mem_target)
            return True
        except Exception:
            return False
1039188
def resource_list(cls):
        
        items = cls.list({'items_per_page': 500})
        ret = [vm['hostname'] for vm in items]
        ret.extend([str(vm['id']) for vm in items])
        return ret
1343651
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with '
            '-a or --action.'
        )

    vm_properties = [
        "config.hardware.device",
        "summary.storage.committed",
        "summary.storage.uncommitted",
        "summary.storage.unshared",
        "layoutEx.file",
        "config.guestFullName",
        "config.guestId",
        "guest.net",
        "config.hardware.memoryMB",
        "name",
        "config.hardware.numCPU",
        "config.files.vmPathName",
        "summary.runtime.powerState",
        "guest.toolsStatus"
    ]

    vm_list = salt.utils.vmware.get_mors_with_properties(_get_si(), vim.VirtualMachine, vm_properties)

    for vm in vm_list:
        if vm['name'] == name:
            return _format_instance_info(vm)

    return {}
1169139
def get_resource(self, device_id, resource_path):
        
        resources = self.list_resources(device_id)
        for r in resources:
            if r.path == resource_path:
                return r
        raise CloudApiException("Resource not found")