def _init_compose_mode_links(): try: try: docker = docker_client() except: docker = docker_client(os.environ) docker.ping() container_id = os.environ.get("HOSTNAME", "") haproxy_container = docker.inspect_container(container_id) except Exception as e: logger.info( "Docker API error, regressing to legacy links mode: %s" % e) return None try: links, Haproxy.cls_linked_services = ComposeModeLinkHelper.get_compose_mode_links( docker, haproxy_container) except Exception as e: logger.info( "Docker API error, regressing to legacy links mode: %s" % e) return None if ADDITIONAL_SERVICES: additional_links, additional_services = ComposeModeLinkHelper.get_additional_links( docker, ADDITIONAL_SERVICES) if additional_links and additional_services: links.update(additional_links) Haproxy.cls_linked_services.update(additional_services) logger.info( "Linked service: %s", ", ".join(ComposeModeLinkHelper.get_service_links_str(links))) logger.info( "Linked container: %s", ", ".join(ComposeModeLinkHelper.get_container_links_str(links))) return links
def _init_compose_mode_links(): try: try: docker = docker_client() except: docker = docker_client(os.environ) docker.ping() container_id = os.environ.get("HOSTNAME", "") haproxy_container = docker.inspect_container(container_id) except Exception as e: logger.info("Docker API error, regressing to legacy links mode: %s" % e) return None try: links, Haproxy.cls_linked_services = ComposeModeLinkHelper.get_compose_mode_links(docker, haproxy_container) except Exception as e: logger.info("Docker API error, regressing to legacy links mode: %s" % e) return None if ADDITIONAL_SERVICES: additional_links, additional_services = ComposeModeLinkHelper.get_additional_links(docker, ADDITIONAL_SERVICES) if additional_links and additional_services: links.update(additional_links) Haproxy.cls_linked_services.update(additional_services) logger.info("Linked service: %s", ", ".join(ComposeModeLinkHelper.get_service_links_str(links))) logger.info("Linked container: %s", ", ".join(ComposeModeLinkHelper.get_container_links_str(links))) return links