def _get_container_description(self, state, name, network_state=True,
                                   ip_partitions=None):
        state_container = state.containers[name]
        container_id = state_container['id']

        try:
            container = self.docker_client.inspect_container(container_id)
        except docker.errors.APIError as err:
            if err.response.status_code == 404:
                return Container(name, container_id, ContainerState.MISSING)
            else:
                raise

        state_dict = container.get('State')
        if state_dict and state_dict.get('Running'):
            container_state = ContainerState.UP
        else:
            container_state = ContainerState.DOWN

        extras = {}
        network = container.get('NetworkSettings')
        ip = None
        if network:
            ip = network.get('IPAddress')
            if ip:
                extras['ip_address'] = ip

        if (network_state and name in state.containers
                and container_state == ContainerState.UP):
            device = state_container['device']
            extras['device'] = device
            extras['network_state'] = self.network.network_state(device)

            # include partition ID if we were provided a map of them
            if ip_partitions and ip:
                extras['partition'] = ip_partitions.get(ip)
        else:
            extras['network_state'] = NetworkState.UNKNOWN
            extras['device'] = None

        # lookup 'holy' and 'neutral' containers
        # TODO: this might go into the state as well..?
        cfg_container = self.config.containers.get(name)
        extras['neutral'] = cfg_container.neutral if cfg_container else False
        extras['holy'] = cfg_container.holy if cfg_container else False

        return Container(name, container_id, container_state, **extras)
dataset/ETHPy150Open dcm-oss/blockade/blockade/core.py/Blockade._get_container_description/original