List all available pods.

        :param namespace: str, if not specified list pods for all namespaces
        :return: collection of instances of :class:`conu.backend.k8s.pod.Pod`
776762
def list_pods(self, namespace=None):
        

        if namespace:
            return [Pod(name=p.metadata.name, namespace=namespace, spec=p.spec)
                    for p in self.core_api.list_namespaced_pod(namespace, watch=False).items]

        return [Pod(name=p.metadata.name, namespace=p.metadata.namespace, spec=p.spec)
                for p in self.core_api.list_pod_for_all_namespaces(watch=False).items]
806228
def get_namespaces(self):
        
        namespaces = list(self._commands.keys())
        namespaces.remove(DEFAULT_NAMESPACE)
        namespaces.sort()
        return namespaces
593061
def list(self):
    '''
    '''
    if not self._list:
      self._list = map(Namespace, self._string.split('/'))
    return self._list
1315343
def list(self, all_tenants=False, **search_opts):
        
        if not all_tenants:
            tenant_id = self.request.user.tenant_id
            # In Neutron, list_floatingips returns Floating IPs from
            # all tenants when the API is called with admin role, so
            # we need to filter them with tenant_id.
            search_opts['tenant_id'] = tenant_id
            port_search_opts = {'tenant_id': tenant_id}
        else:
            port_search_opts = {}
        fips = self.client.list_floatingips(**search_opts)
        fips = fips.get('floatingips')
        # Get port list to add instance_id to floating IP list
        # instance_id is stored in device_id attribute
        ports = port_list(self.request, **port_search_opts)
        port_dict = collections.OrderedDict([(p['id'], p) for p in ports])
        for fip in fips:
            self._set_instance_info(fip, port_dict.get(fip['port_id']))
        return [FloatingIp(fip) for fip in fips]
433606
def _get_ext_namespaces(config):
    '''
    
    '''
    namespaces = {}
    if not config:
        return namespaces

    for ns in config:
        constraint_version = tuple(config[ns].get('py-version', []))
        if not constraint_version:
            raise salt.exceptions.SaltSystemExit("An alternative version is configured, but not defined "
                                                 "to what Python's major/minor version it should be constrained.")
        else:
            namespaces[ns] = constraint_version

    return namespaces
1065630
def GET_namespace_num_names(self, path_info, namespace_id):
        
        if not check_namespace(namespace_id):
            return self._reply_json({'error': 'Invalid namespace'}, status_code=400)

        blockstackd_url = get_blockstackd_url()
        name_count = blockstackd_client.get_num_names_in_namespace(namespace_id, hostport=blockstackd_url)
        if json_is_error(name_count):
            log.error("Failed to load namespace count for {}: {}".format(namespace_id, name_count['error']))
            return self._reply_json({'error': 'Failed to load namespace count: {}'.format(name_count['error'])}, status_code=404)

        self._reply_json({'names_count': name_count})
895867
def list_connections(self, status=None):
        '''  '''
        if status is None:
            status = 'ALL'
        response, status_code = self.__pod__.Connection.get_v1_connection_list(
            sessionToken=self.__session__,
            status=status
        ).result()
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response
989250
def get_all_preordered_namespace_hashes( self ):
        
        cur = self.db.cursor()
        namespace_hashes = namedb_get_all_preordered_namespace_hashes( cur, self.lastblock )
        return namespace_hashes
183477
def namespaces ns = "root", cn = "__Namespace"
    result = []
    each_instance( ns, cn ) do |inst|
      name = "#{ns}/#{inst.Name}"
      result << name
      result.concat namespaces name, cn
    end
    result.uniq
  end
252397
def info(self):
        
        result = dict()
        for name, namespace in self._namespaces.items():
            result[name] = namespace.info_all()
        return result
758460
public static List<String> getAllNameSpaces() throws ApiException {
    V1NamespaceList listNamespace =
        COREV1_API.listNamespace(
            null, "true", null, null, null, 0, null, Integer.MAX_VALUE, Boolean.FALSE);
    List<String> list =
        listNamespace
            .getItems()
            .stream()
            .map(v1Namespace -> v1Namespace.getMetadata().getName())
            .collect(Collectors.toList());
    return list;
  }
981766
def pods(namespace='default', **kwargs):
    '''
    
    '''
    cfg = _setup_conn(**kwargs)
    try:
        api_instance = kubernetes.client.CoreV1Api()
        api_response = api_instance.list_namespaced_pod(namespace)

        return [pod['metadata']['name'] for pod in api_response.to_dict().get('items')]
    except (ApiException, HTTPError) as exc:
        if isinstance(exc, ApiException) and exc.status == 404:
            return None
        else:
            log.exception(
                'Exception when calling '
                'CoreV1Api->list_namespaced_pod'
            )
            raise CommandExecutionError(exc)
    finally:
        _cleanup(**cfg)
789458
def namedb_get_names_in_namespace( cur, namespace_id, current_block, offset=None, count=None ):
    

    unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )

    query = "SELECT name FROM name_records JOIN namespaces ON name_records.namespace_id = namespaces.namespace_id WHERE name_records.namespace_id = ? AND " + unexpired_query + " ORDER BY name "
    args = (namespace_id,) + unexpired_args

    offset_count_query, offset_count_args = namedb_offset_count_predicate( offset=offset, count=count )
    query += offset_count_query + ";"
    args += offset_count_args

    name_rows = namedb_query_execute( cur, query, tuple(args) )
    ret = []
    for name_row in name_rows:
        rec = {}
        rec.update( name_row )
        ret.append( rec['name'] )

    return ret
438532
def is_first_instance_k8s(current_pod_name=None):
    
    current_pod_name = current_pod_name or os.environ.get('POD_NAME')
    if not current_pod_name:
        raise StackInterrogationException('Pod name not known')

    namespace = 'money-to-prisoners-%s' % settings.ENVIRONMENT
    try:
        load_incluster_config()
    except ConfigException as e:
        raise StackInterrogationException(e)
    try:
        response = k8s_client.CoreV1Api().list_namespaced_pod(
            namespace=namespace,
            label_selector='app=%s' % settings.APP,
            watch=False,
        )
    except ApiException as e:
        raise StackInterrogationException(e)
    pod_names = sorted(pod.metadata.name for pod in filter(lambda pod: pod.status.phase == 'Running', response.items))
    return bool(pod_names and pod_names[0] == current_pod_name)
520106
def GET_namespaces( self, path_info ):
        
        qs_values = path_info['qs_values']
        offset = qs_values.get('offset', None)
        count = qs_values.get('count', None)

        blockstackd_url = get_blockstackd_url()
        namespaces = blockstackd_client.get_all_namespaces(offset=offset, count=count, hostport=blockstackd_url)
        if json_is_error(namespaces):
            # error
            status_code = namespaces.get('http_status', 502)
            return self._reply_json({'error': namespaces['error']}, status_code=status_code)

        self._reply_json(namespaces)
        return
945470
def _cleanup_pods(namespace, labels):
    
    api = kubernetes.client.CoreV1Api()
    pods = api.list_namespaced_pod(namespace, label_selector=format_labels(labels))
    for pod in pods.items:
        try:
            api.delete_namespaced_pod(pod.metadata.name, namespace)
            logger.info('Deleted pod: %s', pod.metadata.name)
        except kubernetes.client.rest.ApiException as e:
            # ignore error if pod is already removed
            if e.status != 404:
                raise
1193764
def _find_convertable_object(self, data):
        
        data = list(data)
        convertable_object_idxs = [
            idx
            for idx, obj
            in enumerate(data)
            if obj.get('kind') in self.pod_types.keys()
        ]
        if len(convertable_object_idxs) < 1:
            raise Exception("Kubernetes config didn't contain any of {}".format(
                ', '.join(self.pod_types.keys())
            ))
        return list(data)[convertable_object_idxs[0]]