Skip to content

Commit

Permalink
Added debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
ckunki committed Oct 22, 2024
1 parent 7000b3c commit 2d2a140
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion exasol/nb_connector/itde_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
from exasol.nb_connector.container_by_ip import ContainerByIp, IPRetriever
from exasol.nb_connector.secret_store import Secrets

import logging
LOG = logging.getLogger(__name__)
LOG.setLevel(logging.DEBUG)
logging.basicConfig(
format="%(asctime)s %(levelname)-7s %(filename)s: %(message)s",
datefmt="%Y-%m-%d %X",
)

# if __name__ == "__main__":
# LOG.info("info")
# LOG.debug("debug")


ENVIRONMENT_NAME = "DemoDb"
NAME_SERVER_ADDRESS = "8.8.8.8"

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

def _get_current_container(docker_client: docker.DockerClient):
ip_addresses = _get_ipv4_addresses()
LOG.debug(f"_get_current_container: ip_addresses = {ip_addresses}")
return ContainerByIp(docker_client).find(ip_addresses)


def _add_current_container_to_db_network(network_name: str) -> None:
LOG.debug(f"_add_current_container_to_db_network({network_name})")
with ContextDockerClient() as docker_client:
container = _get_current_container(docker_client)
LOG.debug(f"- container = {container and container.name}")
if not container:
return
network = _get_docker_network(docker_client, network_name)
LOG.debug(f"- network = {network}")
if network and not _is_container_connected_to_network(container, network):
LOG.debug(f"- connecting container {container.id} to the network")
network.connect(container.id)
else:
LOG.debug("- either network is falsy or container is already connected")



def _is_container_connected_to_network(container, network) -> bool:
Expand Down Expand Up @@ -272,4 +293,3 @@ def remove_container(conf):
if container_name:
remove_docker_container([container_name])
conf.remove(AILabConfig.itde_container)

0 comments on commit 2d2a140

Please sign in to comment.