def inspect_instance(self, name): try: container = self.client.containers.get(name) return new_operator_instance( container.short_id, container.name, container.status, container.attrs["NetworkSettings"]["IPAddress"], container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def inspect_instance(self, name): try: container = self.client.containers.get(name) return new_operator_instance(container.short_id, container.name, container.status, self.get_container_ip(container), container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def delete_instance(self, name): try: container = self.client.containers.get(name) container.remove(force=True) return new_operator_instance( container.short_id, container.name, "deleted", container.attrs["NetworkSettings"]["IPAddress"], container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def delete_instance(self, name): try: container = self.client.containers.get(name) container.remove(force=True) return new_operator_instance(container.short_id, container.name, "deleted", self.get_container_ip(container), container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def create_instance(self, name, image, ports, args=None): try: container = self.client.containers.run(image=image, name=name, detach=True, ports=ports, labels=self.labels) return new_operator_instance( container.short_id, container.name, container.status, container.attrs["NetworkSettings"]["IPAddress"], container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def create_instance(self, name, image, ports, args=None): try: self.client.containers.run(image=image, name=name, detach=True, ports=ports, labels=self.labels, network=self.network) containers = self.client.containers.list(all=False, filters={"name": name}) container = containers[0] return new_operator_instance(container.short_id, container.name, container.status, self.get_container_ip(container), container.ports) except APIError as e: raise DockerRuntimeError(e.explanation, e)
def list_instances(self, name): try: res = [] containers = self.client.containers.list(all=True, filters={ "name": f"phantoscope_{name}", "label": self.labels }) for container in containers: res.append( new_operator_instance( container.short_id, container.name, container.status, container.attrs["NetworkSettings"]["IPAddress"], container.ports)) return res except APIError as e: raise DockerRuntimeError(e.explanation, e)