Ensure vm is absent on the computenode

    name : string
        hostname of vm
    archive : boolean
        toggle archiving of vm on removal

    .. note::

        State ID is used as hostname. Hostnames must be unique.
486746
def vm_absent(name, archive=False):
    '''
    

    '''
    name = name.lower()
    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    if name not in __salt__['vmadm.list'](order='hostname'):
        # we're good
        ret['result'] = True
        ret['comment'] = 'vm {0} is absent'.format(name)
    else:
        # delete vm
        if not __opts__['test']:
            # set archive to true if needed
            if archive:
                __salt__['vmadm.update'](vm=name, key='hostname', archive_on_delete=True)

            ret['result'] = __salt__['vmadm.delete'](name, key='hostname')
        else:
            ret['result'] = True

        if not isinstance(ret['result'], bool) and ret['result'].get('Error'):
            ret['result'] = False
            ret['comment'] = 'failed to delete vm {0}'.format(name)
        else:
            ret['comment'] = 'vm {0} deleted'.format(name)
            ret['changes'][name] = None

    return ret
470245
def state(vm_name)
      unless states.include? vm_name.to_sym
        raise Derelict::VirtualMachine::NotFound.new vm_name
      end

      states[vm_name.to_sym]
    end
1306019
def unregister_vm(vm_ref):
    '''
    
    '''
    vm_name = get_managed_object_name(vm_ref)
    log.trace('Destroying vm \'%s\'', vm_name)
    try:
        vm_ref.UnregisterVM()
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(
            'Not enough permissions. Required privilege: '
            '{}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        raise salt.exceptions.VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        raise salt.exceptions.VMwareRuntimeError(exc.msg)
1119056
def lv_absent(name, vgname=None):
    '''
    
    '''
    ret = {'changes': {},
           'comment': '',
           'name': name,
           'result': True}

    lvpath = '/dev/{0}/{1}'.format(vgname, name)
    if not __salt__['lvm.lvdisplay'](lvpath, quiet=True):
        ret['comment'] = 'Logical Volume {0} already absent'.format(name)
    elif __opts__['test']:
        ret['comment'] = 'Logical Volume {0} is set to be removed'.format(name)
        ret['result'] = None
        return ret
    else:
        changes = __salt__['lvm.lvremove'](name, vgname)

        if not __salt__['lvm.lvdisplay'](lvpath, quiet=True):
            ret['comment'] = 'Removed Logical Volume {0}'.format(name)
            ret['changes']['removed'] = changes
        else:
            ret['comment'] = 'Failed to remove Logical Volume {0}'.format(name)
            ret['result'] = False
    return ret
1187483
def delete_vhost(self, vname):
        
        vname = quote(vname, '')
        path = Client.urls['vhosts_by_name'] % vname
        return self._call(path, 'DELETE')
769288
def host_info(host=None):
    '''
    
    '''
    data = query(host, quiet=True)
    for id_ in data:
        if 'vm_info' in data[id_]:
            data[id_].pop('vm_info')
    __jid_event__.fire_event({'data': data, 'outputter': 'nested'}, 'progress')
    return data
203639
def _resolve_hostname(name):
    """"""
    if env.ssh_config is None:
        return name
    elif not os.path.exists(os.path.join("nodes", name + ".json")):
        resolved_name = env.ssh_config.lookup(name)['hostname']
        if os.path.exists(os.path.join("nodes", resolved_name + ".json")):
            name = resolved_name
    return name
95475
def absent(name, protocol=None, service_address=None):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    #check if service exists and remove it
    service_check = __salt__['lvs.check_service'](protocol=protocol,
                                                  service_address=service_address)
    if service_check is True:
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = 'LVS Service {0} is present and needs to be removed'.format(name)
            return ret
        service_delete = __salt__['lvs.delete_service'](protocol=protocol,
                                                        service_address=service_address)
        if service_delete is True:
            ret['comment'] = 'LVS Service {0} has been removed'.format(name)
            ret['changes'][name] = 'Absent'
            return ret
        else:
            ret['comment'] = 'LVS Service {0} removed failed({1})'.format(name, service_delete)
            ret['result'] = False
            return ret
    else:
        ret['comment'] = 'LVS Service {0} is not present, so it cannot be removed'.format(name)

    return ret
536973
def clean_delete(self):
        

        yield from self._hypervisor.send('vm clean_delete "{}"'.format(self._name))
        self._hypervisor.devices.remove(self)
        try:
            yield from wait_run_in_executor(shutil.rmtree, self._working_directory)
        except OSError as e:
            log.warn("Could not delete file {}".format(e))
        log.info('Router "{name}" [{id}] has been deleted (including associated files)'.format(name=self._name, id=self._id))
947804
def absent(name, auth=None):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    __salt__['keystoneng.setup_clouds'](auth)

    domain = __salt__['keystoneng.domain_get'](name=name)

    if domain:
        if __opts__['test'] is True:
            ret['result'] = None
            ret['changes'] = {'name': name}
            ret['comment'] = 'Domain {} will be deleted.'.format(name)
            return ret

        __salt__['keystoneng.domain_delete'](name=domain)
        ret['changes']['id'] = domain.id
        ret['comment'] = 'Deleted domain'

    return ret
457779
def _delete_idle_service_vm_hosting_devices(self, context, num, template):
        
        # Delete the "youngest" hosting devices since they are more likely
        # not to have finished booting
        num_deleted = 0
        plugging_drv = self.get_hosting_device_plugging_driver(context,
                                                               template['id'])
        hosting_device_drv = self.get_hosting_device_driver(context,
                                                            template['id'])
        if plugging_drv is None or hosting_device_drv is None or num <= 0:
            return num_deleted
        query = context.session.query(hd_models.HostingDevice)
        query = query.outerjoin(
            hd_models.SlotAllocation,
            hd_models.HostingDevice.id ==
            hd_models.SlotAllocation.hosting_device_id)
        query = query.filter(hd_models.HostingDevice.template_id ==
                             template['id'],
                             hd_models.HostingDevice.admin_state_up ==
                             expr.true(),
                             hd_models.HostingDevice.tenant_bound ==
                             expr.null(),
                             hd_models.HostingDevice.auto_delete ==
                             expr.true())
        query = query.group_by(hd_models.HostingDevice.id).having(
            func.count(hd_models.SlotAllocation.logical_resource_id) == 0)
        query = query.order_by(
            hd_models.HostingDevice.created_at.desc(),
            func.count(hd_models.SlotAllocation.logical_resource_id))
        hd_candidates = query.all()
        num_possible_to_delete = min(len(hd_candidates), num)
        for i in range(num_possible_to_delete):
            res = plugging_drv.get_hosting_device_resources(
                context, hd_candidates[i]['id'],
                hd_candidates[i]['complementary_id'], self.l3_tenant_id(),
                self.mgmt_nw_id())
            if self.svc_vm_mgr.delete_service_vm(context,
                                                 hd_candidates[i]['id']):
                with context.session.begin(subtransactions=True):
                    context.session.delete(hd_candidates[i])
                plugging_drv.delete_hosting_device_resources(
                    context, self.l3_tenant_id(), **res)
                num_deleted += 1
        LOG.info('Deleted %(num)d hosting devices based on template '
                 '%(t_id)s', {'num': num_deleted, 't_id': template['id']})
        return num_deleted
1011774
function(hostName) {
      var t = this, testHost = hostName.toLowerCase(),
          myHostName = t.get('hostName'), remoteHostName = t.get('remoteHostName');
      myHostName = myHostName && myHostName.toLowerCase();
      remoteHostName = remoteHostName && remoteHostName.toLowerCase();
      return (testHost === myHostName || testHost ===  remoteHostName);
    }
766453
private static String getFullInstanceId(String hostname, String id) {
    String str = hostname == null ? "" : hostname;
    str = str.replace('.', '_');
    str += (id == null ? "" : "-" + id);
    return str;
  }
655072
def remove_host(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        raise SaltCloudSystemExit(
            'The remove_host function must be called with '
            '-f or --function.'
        )

    host_name = kwargs.get('host') if kwargs and 'host' in kwargs else None

    if not host_name:
        raise SaltCloudSystemExit(
            'You must specify name of the host system.'
        )

    # Get the service instance
    si = _get_si()

    host_ref = salt.utils.vmware.get_mor_by_property(si, vim.HostSystem, host_name)
    if not host_ref:
        raise SaltCloudSystemExit(
            'Specified host system does not exist.'
        )

    try:
        if isinstance(host_ref.parent, vim.ClusterComputeResource):
            # This is a host system that is part of a Cluster
            task = host_ref.Destroy_Task()
        else:
            # This is a standalone host system
            task = host_ref.parent.Destroy_Task()
        salt.utils.vmware.wait_for_task(task, host_name, 'remove host', log_level='info')
    except Exception as exc:
        log.error(
            'Error while removing host %s: %s',
            host_name, exc,
            # Show the traceback if the debug logging level is enabled
            exc_info_on_loglevel=logging.DEBUG
        )
        return {host_name: 'failed to remove host'}

    return {host_name: 'removed host from vcenter'}
1356033
private DnsServerAddressStream getNameServersFromCache(String hostname) {
        int len = hostname.length();

        if (len == 0) {
            // We never cache for root servers.
            return null;
        }

        // We always store in the cache with a trailing '.'.
        if (hostname.charAt(len - 1) != '.') {
            hostname += ".";
        }

        int idx = hostname.indexOf('.');
        if (idx == hostname.length() - 1) {
            // We are not interested in handling '.' as we should never serve the root servers from cache.
            return null;
        }

        // We start from the closed match and then move down.
        for (;;) {
            // Skip '.' as well.
            hostname = hostname.substring(idx + 1);

            int idx2 = hostname.indexOf('.');
            if (idx2 <= 0 || idx2 == hostname.length() - 1) {
                // We are not interested in handling '.TLD.' as we should never serve the root servers from cache.
                return null;
            }
            idx = idx2;

            DnsServerAddressStream entries = authoritativeDnsServerCache().get(hostname);
            if (entries != null) {
                // The returned List may contain unresolved InetSocketAddress instances that will be
                // resolved on the fly in query(....).
                return entries;
            }
        }
    }
1216155
def absent(name, provider):
    '''
    
    '''
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

    is_present = list(__salt__['cloud.action']('queues_exists', provider=provider, name=name)[provider].values())[0]

    if is_present:
        if __opts__['test']:
            ret['comment'] = 'Rackspace queue {0} is set to be removed.'.format(
                name)
            ret['result'] = None
            return ret
        queue = __salt__['cloud.action']('queues_show', provider=provider, name=name)
        deleted = __salt__['cloud.action']('queues_delete', provider=provider, name=name)
        if deleted:
            ret['changes']['old'] = queue
            ret['changes']['new'] = {}
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to delete {0} Rackspace queue.'.format(name)
    else:
        ret['comment'] = '{0} does not exist.'.format(name)

    return ret
958231
def set_hostname(self, hostname):
        
        self.oem_init()
        try:
            return self._oem.set_hostname(hostname)
        except exc.UnsupportedFunctionality:
            return self.set_mci(hostname)