def _init_swarm_mode_links(): try: try: docker = docker_client() except: docker = docker_client(os.environ) docker.ping() except Exception as e: logger.info( "Docker API error, regressing to legacy links mode: %s" % e) return None haproxy_container_id = os.environ.get("HOSTNAME", "") Haproxy.cls_service_id, Haproxy.cls_nets = SwarmModeLinkHelper.get_swarm_mode_haproxy_id_nets( docker, haproxy_container_id) links, Haproxy.cls_linked_tasks = SwarmModeLinkHelper.get_swarm_mode_links( docker, Haproxy.cls_service_id, Haproxy.cls_nets) logger.info( "Linked service: %s", ", ".join(SwarmModeLinkHelper.get_service_links_str(links))) logger.info( "Linked container: %s", ", ".join(SwarmModeLinkHelper.get_container_links_str(links))) return links
def _init_swarm_mode_links(): try: try: docker = docker_client() except: docker = docker_client(os.environ) docker.ping() except Exception as e: logger.info("Docker API error, regressing to legacy links mode: %s" % e) return None haproxy_container_id = os.environ.get("HOSTNAME", "") Haproxy.cls_service_id, Haproxy.cls_nets = SwarmModeLinkHelper.get_swarm_mode_haproxy_id_nets(docker, haproxy_container_id) links, Haproxy.cls_linked_tasks = SwarmModeLinkHelper.get_swarm_mode_links(docker, Haproxy.cls_service_id, Haproxy.cls_nets) logger.info("Linked service: %s", ", ".join(SwarmModeLinkHelper.get_service_links_str(links))) logger.info("Linked container: %s", ", ".join(SwarmModeLinkHelper.get_container_links_str(links))) return links
def _init_swarm_mode_links(): try: docker = Client(base_url='unix:///var/run/docker.sock') swarm = Client(base_url=os.environ.get('DOCKER_MANAGER_URI')) docker.ping() swarm.ping() except Exception as e: logger.info( "Docker API error, regressing to legacy links mode: %s" % e) return None haproxy_container_id = os.environ.get("HOSTNAME", "") Haproxy.cls_service_id, Haproxy.cls_nets = SwarmModeLinkHelper.get_swarm_mode_haproxy_id_nets( docker, haproxy_container_id) links, Haproxy.cls_linked_tasks = SwarmModeLinkHelper.get_swarm_mode_links( swarm, Haproxy.cls_service_id, Haproxy.cls_nets) logger.info( "Linked service: %s", ", ".join(SwarmModeLinkHelper.get_service_links_str(links))) logger.info( "Linked container: %s", ", ".join(SwarmModeLinkHelper.get_container_links_str(links))) return links