Return linode status by ID

    status_id
        linode VM status ID
352954
def _get_status_descr_by_id(status_id):
    '''
    
    '''
    for status_name, status_data in six.iteritems(LINODE_STATUS):
        if status_data['code'] == int(status_id):
            return status_data['descr']
    return LINODE_STATUS.get(status_id, None)
844694
def get_process_status(self, pid=None):
        '''
        

        '''
        pid = self._get_pid(pid)
        return self._call_rest_api('get', '/processes/'+pid+'/status', error='Failed to fetch process status')
324482
def status(self, job_id):
        
        params = {"jobid": job_id}
        r = self._send_request("GetJobStatus", params=params)
        status = int(self._parse_single(r.text, "int"))
        return status, self.status_codes[status]
550376
def status_context(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}/context'.format(str(id))
        return self.__api_request('GET', url)
1021451
def get_status_return_level(self, ids, **kwargs):
        
        convert = kwargs['convert'] if 'convert' in kwargs else self._convert
        srl = []
        for id in ids:
            try:
                srl.extend(self._get_status_return_level((id, ),
                                                         error_handler=None, convert=convert))
            except DxlTimeoutError as e:
                if self.ping(id):
                    srl.append('never' if convert else 0)
                else:
                    if self._error_handler:
                        self._error_handler.handle_timeout(e)
                        return ()
                    else:
                        raise e

        return tuple(srl)
788984
def to(self, linode):
        
        from .linode import Instance
        if not isinstance(linode, Instance):
            raise ValueError("IP Address can only be assigned to a Linode!")
        return { "address": self.address, "linode_id": linode.id }
953777
def _get_vm_by_id(vmid, allDetails=False):
    '''
    
    '''
    for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=allDetails)):
        if six.text_type(vm_details['vmid']) == six.text_type(vmid):
            return vm_details

    log.info('VM with ID "%s" could not be found.', vmid)
    return False
798182
def set_vm_status(self, device='FLOPPY',
                      boot_option='BOOT_ONCE', write_protect='YES'):
        
        dic = {'DEVICE': device.upper()}
        xml = self._create_dynamic_xml(
            'SET_VM_STATUS', 'RIB_INFO', 'write', dic)

        if six.PY2:
            child_iterator = xml.getiterator()
        else:
            child_iterator = xml.iter()

        for child in child_iterator:
            if child.tag == 'SET_VM_STATUS':
                etree.SubElement(child, 'VM_BOOT_OPTION',
                                 VALUE=boot_option.upper())
                etree.SubElement(child, 'VM_WRITE_PROTECT',
                                 VALUE=write_protect.upper())

        d = self._request_ilo(xml)
        data = self._parse_output(d)
        return data
1020368
def status(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}'.format(str(id))
        return self.__api_request('GET', url)
270878
def StatusLine(self):
    """"""
    pid = self.inferior.pid
    curthread = None
    threadnum = 0
    if pid:
      if not self.inferior.is_running:
        logging.warning('Inferior is not running.')
        self.Detach()
        pid = None
      else:
        try:
          # get a gdb running if it wasn't already.
          if not self.inferior.attached:
            self.inferior.StartGdb()
          curthread = self.inferior.current_thread
          threadnum = len(self.inferior.threads)
        except (inferior.ProxyError,
                inferior.TimeoutError,
                inferior.PositionError) as err:
          # This is not the kind of thing we want to be held up by
          logging.debug('Error while getting information in status line:%s'
                        % err.message)
          pass
    status = ('==> pid:[%s] #threads:[%s] current thread:[%s]' %
              (pid, threadnum, curthread))
    return status
369735
def get_guest_connection_status(self, userid):
        ''''''
        rd = ' '.join(('getvm', userid, 'isreachable'))
        results = self._request(rd)
        if results['rs'] == 1:
            return True
        else:
            return False
1322018
def node_state(id_):
    '''
    
    '''
    states_int = {
        0: 'RUNNING',
        1: 'REBOOTING',
        2: 'TERMINATED',
        3: 'PENDING',
        4: 'UNKNOWN',
        5: 'STOPPED',
        6: 'SUSPENDED',
        7: 'ERROR',
        8: 'PAUSED'}
    states_str = {
        'running': 'RUNNING',
        'rebooting': 'REBOOTING',
        'starting': 'STARTING',
        'terminated': 'TERMINATED',
        'pending': 'PENDING',
        'unknown': 'UNKNOWN',
        'stopping': 'STOPPING',
        'stopped': 'STOPPED',
        'suspended': 'SUSPENDED',
        'error': 'ERROR',
        'paused': 'PAUSED',
        'reconfiguring': 'RECONFIGURING'
    }
    return states_str[id_] if isinstance(id_, six.string_types) else states_int[id_]
1142135
def status_pin(self, id):
        
        id = self.__unpack_id(id)
        url = '/api/v1/statuses/{0}/pin'.format(str(id))
        return self.__api_request('POST', url)
1311752
def _parse_vagrant_sandbox_status(self, vagrant_output):
        '''
        
        '''
        # typical output
        # [default] - snapshot mode is off
        # or
        # [default] - machine not created
        # if the box VM is down
        tokens = [token.strip() for token in vagrant_output.split(' ')]
        if tokens[0] == 'Usage:':
            sahara_status = 'not installed'
        elif "{} {}".format(tokens[-2], tokens[-1]) == 'not created':
            sahara_status = 'unknown'
        else:
            sahara_status = tokens[-1]
        return sahara_status
875676
def get_build_status(req_id, nodename):
    '''
    
    '''
    counter = 0
    req_id = six.text_type(req_id)
    while counter < 10:
        queue = clc.v1.Blueprint.GetStatus(request_id=(req_id))
        if queue["PercentComplete"] == 100:
            server_name = queue["Servers"][0]
            creds = get_creds()
            clc.v2.SetCredentials(creds["user"], creds["password"])
            ip_addresses = clc.v2.Server(server_name).ip_addresses
            internal_ip_address = ip_addresses[0]["internal"]
            return internal_ip_address
        else:
            counter = counter + 1
            log.info('Creating Cloud VM %s Time out in %s minutes',
                     nodename, six.text_type(10 - counter))
            time.sleep(60)
342819
def _GetStatus(self, two_factor=False):
    
    params = ['status']
    if two_factor:
      params += ['--twofactor']
    retcode = self._RunOsLoginControl(params)
    if retcode is None:
      if self.oslogin_installed:
        self.logger.warning('OS Login not installed.')
        self.oslogin_installed = False
      return None

    # Prevent log spam when OS Login is not installed.
    self.oslogin_installed = True
    if not os.path.exists(constants.OSLOGIN_NSS_CACHE):
      return False
    return not retcode
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