|
23 | 23 | from exasol.nb_connector.container_by_ip import ContainerByIp, IPRetriever
|
24 | 24 | from exasol.nb_connector.secret_store import Secrets
|
25 | 25 |
|
| 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 | + |
26 | 39 | ENVIRONMENT_NAME = "DemoDb"
|
27 | 40 | NAME_SERVER_ADDRESS = "8.8.8.8"
|
28 | 41 |
|
@@ -100,17 +113,25 @@ def bring_itde_up(conf: Secrets, env_info: Optional[EnvironmentInfo] = None) ->
|
100 | 113 |
|
101 | 114 | def _get_current_container(docker_client: docker.DockerClient):
|
102 | 115 | ip_addresses = _get_ipv4_addresses()
|
| 116 | + LOG.debug(f"_get_current_container: ip_addresses = {ip_addresses}") |
103 | 117 | return ContainerByIp(docker_client).find(ip_addresses)
|
104 | 118 |
|
105 | 119 |
|
106 | 120 | def _add_current_container_to_db_network(network_name: str) -> None:
|
| 121 | + LOG.debug(f"_add_current_container_to_db_network({network_name})") |
107 | 122 | with ContextDockerClient() as docker_client:
|
108 | 123 | container = _get_current_container(docker_client)
|
| 124 | + LOG.debug(f"- container = {container and container.name}") |
109 | 125 | if not container:
|
110 | 126 | return
|
111 | 127 | network = _get_docker_network(docker_client, network_name)
|
| 128 | + LOG.debug(f"- network = {network}") |
112 | 129 | if network and not _is_container_connected_to_network(container, network):
|
| 130 | + LOG.debug(f"- connecting container {container.id} to the network") |
113 | 131 | network.connect(container.id)
|
| 132 | + else: |
| 133 | + LOG.debug("- either network is falsy or container is already connected") |
| 134 | + |
114 | 135 |
|
115 | 136 |
|
116 | 137 | def _is_container_connected_to_network(container, network) -> bool:
|
@@ -272,4 +293,3 @@ def remove_container(conf):
|
272 | 293 | if container_name:
|
273 | 294 | remove_docker_container([container_name])
|
274 | 295 | conf.remove(AILabConfig.itde_container)
|
275 |
| - |
|
0 commit comments