예제 #1
0
    def _make_container(self, container, con_struct, deep=False):
        con_obj = Container(container, backend=self)
        if not deep:
            con_obj.id = con_struct['id']
            con_obj.image = con_struct['image_id']
            con_obj.image_name = con_struct['image']
            con_obj.created = time.mktime(
                time.strptime(con_struct['createdAt'].split(".")[0],
                              "%Y-%m-%dT%H:%M:%S"))
            con_obj.status = con_struct['status']
            con_obj.state = con_obj.status.split()[0]
            con_obj.name = con_struct['names']
            con_obj.labels = con_struct['labels']
            con_obj.running = True if con_obj.status.lower().startswith(
                "up") else False
            con_obj.runtime = "runc"
        else:
            con_obj.id = con_struct['ID']
            con_obj.image = con_struct['ImageID']
            con_obj.image_name = con_struct['Image']
            con_obj.created = time.mktime(
                time.strptime(con_struct['State']['created'].split(".")[0],
                              "%Y-%m-%dT%H:%M:%S"))
            con_obj.command = con_struct['Config']['Cmd']
            con_obj.state = con_struct['State']['status']
            con_obj.running = True if con_obj.state.upper() not in [
                'STOPPED'
            ] else False
            con_obj.name = con_struct['Name']
            con_obj.labels = con_struct['Labels']
            con_obj.original_structure = con_struct

        return con_obj
예제 #2
0
    def _make_container(self, info):
        container_id = info['Id']

        runtime = self.syscontainers.get_container_runtime_info(container_id)

        container = Container(container_id, backend=self)
        container.name = container_id
        container.id = container_id
        container.created = info['Created']
        container.status = runtime['status']
        container.input_name = container_id
        container.original_structure = info
        container.deep = True
        container.image = info['Image']

        return container
예제 #3
0
 def _make_container(self, info):
     container_id = info['Id']
     runtime = self.syscontainers.get_container_runtime_info(container_id)
     container = Container(container_id, backend=self)
     container.name = container_id
     container.command = info['Command']
     container.id = container_id
     container.runtime = info['Runtime']
     container.image_name = info['Image']
     container.image = info['ImageID']
     container.created = info['Created']
     container.status = container.state = runtime['status']
     container.input_name = container_id
     container.original_structure = info
     container.deep = True
     container.running = False if container.status == 'inactive' else True
     return container
예제 #4
0
    def _make_container(self, container, con_struct, deep=False):
        con_obj = Container(container, backend=self)
        con_obj.id = con_struct['Id']
        try:
            con_obj.created = float(con_struct['Created'])
        except ValueError:
            con_obj.created = dateparse(con_struct['Created']).strftime(
                "%F %H:%M")  # pylint: disable=no-member
        con_obj.original_structure = con_struct
        try:
            con_obj.name = con_struct['Names'][0]
        except KeyError:
            con_obj.name = con_struct['Name']
        con_obj.input_name = container
        con_obj.backend = self
        try:
            con_obj.command = con_struct['Command']
        except KeyError:
            con_obj.command = con_struct['Config']['Cmd']

        try:
            con_obj.state = con_struct.get(
                'State', None) or con_struct.get['State'].get('Status', None)
        except TypeError:
            # Docker 1.10 on F24 has a different structure
            con_obj.state = con_struct['Status']

        if isinstance(con_obj.state, dict):
            con_obj.state = con_obj.state['Status']
        con_obj.running = True if con_obj.state.lower() in ['true', 'running'
                                                            ] else False

        if deep:
            # Add in the deep inspection stuff
            con_obj.status = con_struct['State']['Status']
            con_obj.image = con_struct['Image']
            con_obj.image_name = con_struct['Config']['Image']
            con_obj.labels = con_struct['Config']['Labels']

        else:
            con_obj.status = con_struct['Status']
            con_obj.image = con_struct['ImageID']
            con_obj.image_name = con_struct['Image']

        return con_obj
예제 #5
0
    def _make_container(self, container, con_struct, deep=False):
        con_obj = Container(container)
        con_obj.id = con_struct['Id']
        con_obj.created = con_struct['Created']
        con_obj.original_structure = con_struct
        con_obj.input_name = container
        con_obj.backend = self

        if deep:
            # Add in the deep inspection stuff
            con_obj.status = con_struct['State']['Status']
            con_obj.running = con_struct['State']['Running']
            con_obj.image = con_struct['Image']

        else:
            con_obj.status = con_struct['Status']
            con_obj.image = con_struct['ImageID']

        return con_obj