Skip to content

Commit 2d2a140

Browse files
committed
Added debug output
1 parent 7000b3c commit 2d2a140

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

exasol/nb_connector/itde_manager.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
from exasol.nb_connector.container_by_ip import ContainerByIp, IPRetriever
2424
from exasol.nb_connector.secret_store import Secrets
2525

26+
import logging
27+
LOG = logging.getLogger(__name__)
28+
LOG.setLevel(logging.DEBUG)
29+
logging.basicConfig(
30+
format="%(asctime)s %(levelname)-7s %(filename)s: %(message)s",
31+
datefmt="%Y-%m-%d %X",
32+
)
33+
34+
# if __name__ == "__main__":
35+
# LOG.info("info")
36+
# LOG.debug("debug")
37+
38+
2639
ENVIRONMENT_NAME = "DemoDb"
2740
NAME_SERVER_ADDRESS = "8.8.8.8"
2841

@@ -100,17 +113,25 @@ def bring_itde_up(conf: Secrets, env_info: Optional[EnvironmentInfo] = None) ->
100113

101114
def _get_current_container(docker_client: docker.DockerClient):
102115
ip_addresses = _get_ipv4_addresses()
116+
LOG.debug(f"_get_current_container: ip_addresses = {ip_addresses}")
103117
return ContainerByIp(docker_client).find(ip_addresses)
104118

105119

106120
def _add_current_container_to_db_network(network_name: str) -> None:
121+
LOG.debug(f"_add_current_container_to_db_network({network_name})")
107122
with ContextDockerClient() as docker_client:
108123
container = _get_current_container(docker_client)
124+
LOG.debug(f"- container = {container and container.name}")
109125
if not container:
110126
return
111127
network = _get_docker_network(docker_client, network_name)
128+
LOG.debug(f"- network = {network}")
112129
if network and not _is_container_connected_to_network(container, network):
130+
LOG.debug(f"- connecting container {container.id} to the network")
113131
network.connect(container.id)
132+
else:
133+
LOG.debug("- either network is falsy or container is already connected")
134+
114135

115136

116137
def _is_container_connected_to_network(container, network) -> bool:
@@ -272,4 +293,3 @@ def remove_container(conf):
272293
if container_name:
273294
remove_docker_container([container_name])
274295
conf.remove(AILabConfig.itde_container)
275-

0 commit comments

Comments
 (0)