Skip to content
Snippets Groups Projects
Commit b79256b2 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:ambulance: fix start-py3o

The code was still using old API, updated it.
parent 8ffb3e01
No related branches found
No related tags found
1 merge request!44🚑 fix start-py3o
......@@ -11,6 +11,8 @@
Changed following base image changes.
Make start-py3o option work again.
8.0.1
-----
......
......@@ -33,7 +33,10 @@
fusion_name = "py3o_fusion"
fusion_image = "{}:{}".format(fusion_repository, fusion_version)
try:
docker_client.pull(repository=fusion_repository, tag=fusion_version)
_logger.debug("Pulling %s", fusion_repository)
docker_client.images.pull(
repository=fusion_repository, tag=fusion_version
)
except Exception as e:
_logger.warning("Exception when trying to pull: %s", e)
if any(
......@@ -37,10 +40,10 @@
except Exception as e:
_logger.warning("Exception when trying to pull: %s", e)
if any(
"/{}".format(fusion_name) in container["Names"]
for container in docker_client.containers()
fusion_name == container.name
for container in docker_client.containers.list()
):
_logger.debug("%s Container already running", fusion_name)
remove_and_stop(docker_client, fusion_name)
# TODO handle --host-network option
port_bindings = {8765: host_fusion_port}
......@@ -42,9 +45,6 @@
):
_logger.debug("%s Container already running", fusion_name)
remove_and_stop(docker_client, fusion_name)
# TODO handle --host-network option
port_bindings = {8765: host_fusion_port}
host_config = docker_client.create_host_config(
binds=[], port_bindings=port_bindings
)
_logger.debug("Starting %s container", fusion_name)
......@@ -50,5 +50,5 @@
_logger.debug("Starting %s container", fusion_name)
fusion = docker_client.create_container(
image=fusion_image, host_config=host_config, name=fusion_name
fusion = docker_client.containers.create(
image=fusion_image, ports=port_bindings, name=fusion_name
)
_logger.debug("Starting %s container", fusion_name)
......@@ -53,5 +53,5 @@
)
_logger.debug("Starting %s container", fusion_name)
docker_client.start(container=fusion.get("Id"))
fusion.start()
def stop_py3o():
......@@ -56,10 +56,11 @@
def stop_py3o():
# TODO test if still exists
_logger.info("Stopping fusion")
docker_client.stop(fusion.get("Id"))
_logger.info("Removing containers")
docker_client.remove_container(fusion.get("Id"))
# TODO test if still exists (no error if already stopped)
_logger.info("Stopping fusion container")
fusion.stop()
fusion.wait()
_logger.info("Removing fusion container")
fusion.remove()
if stop_at_exit:
atexit.register(stop_py3o)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment