(self, pods)
return parsed_containers
Parse pods and retrieve memory and cpu details about each pod

        :param pods: The output of k8s_api.list_namespaced_pod()
        For example:
        {
            'items': [{
                'status': {
                    'container_statuses': None,
                    'pod_ip': None,
                    'phase': 'Pending',
                    'message': None,
                    'conditions': None,
                },
                'spec': {
                    'containers': [{
                        'image': 'nginx',
                        'resources': {'requests': None,
                              'limits': "{u'cpu': u'500m',
                                          u'memory': u'1280e3'}"},
                    }],
                },
                'api_version': None,
            }],
            'kind': 'PodList',
        }

        The above output is the dict form of:
        k8sclient.client.models.v1_pod_list.
        V1PodList object

        :return: Memory size of each pod. Example:
            [{'Memory': 1280000.0, cpu: 0.5},
             {'Memory': 1280000.0, cpu: 0.5}]
Parse pods and retrieve memory and cpu details about each pod
Parse pods and retrieve memory and cpu details about each pod
def _parse_pod_info(self, pods):
        """Parse pods and retrieve memory and cpu details about each pod

        :param pods: The output of k8s_api.list_namespaced_pod()
        For example:
        {
            'items': [{
                'status': {
                    'container_statuses': None,
                    'pod_ip': None,
                    'phase': 'Pending',
                    'message': None,
                    'conditions': None,
                },
                'spec': {
                    'containers': [{
                        'image': 'nginx',
                        'resources': {'requests': None,
                              'limits': "{u'cpu': u'500m',
                                          u'memory': u'1280e3'}"},
                    }],
                },
                'api_version': None,
            }],
            'kind': 'PodList',
        }

        The above output is the dict form of:
        k8sclient.client.models.v1_pod_list.
        V1PodList object

        :return: Memory size of each pod. Example:
            [{'Memory': 1280000.0, cpu: 0.5},
             {'Memory': 1280000.0, cpu: 0.5}]
        """
        pods = pods.items
        parsed_containers = []
        for pod in pods:
            containers = pod.spec.containers
            for container in containers:
                memory = 0
                cpu = 0
                resources = container.resources
                limits = resources.limits
                if limits is not None:
                    # Output of resources.limits is string
                    # for example:
                    # limits = "{cpu': '500m': 'memory': '1000Ki'}"
                    limits = ast.literal_eval(limits)
                    if limits.get('memory', ''):
                        memory = utils.get_k8s_quantity(limits['memory'])
                    if limits.get('cpu', ''):
                        cpu = utils.get_k8s_quantity(limits['cpu'])
                container_dict = {
                    'Memory': memory,
                    'Cpu': cpu,
                }
                parsed_containers.append(container_dict)
        return parsed_containers
def _parse_pod_info ( self , pods ) : pods = pods . items parsed_containers = [ ] for pod in pods : containers = pod . spec . containers for container in containers : memory = 0 cpu = 0 resources = container . resources limits = resources . limits if limits is not None : # Output of resources.limits is string # for example: # limits = "{cpu': '500m': 'memory': '1000Ki'}" limits = ast . literal_eval ( limits ) if limits . get ( 'memory' , '' ) : memory = utils . get_k8s_quantity ( limits [ 'memory' ] ) if limits . get ( 'cpu' , '' ) : cpu = utils . get_k8s_quantity ( limits [ 'cpu' ] ) container_dict = { 'Memory' : memory , 'Cpu' : cpu , } parsed_containers . append ( container_dict ) return parsed_containers