import syncthing_monitor.config_xml as xml from syncthing_monitor.etcd_cluster_info import EtcdClient from syncthing_monitor.syncthing_rest import SyncthingClient DEFAULT_CONFIG_XML_PATH = '/config/config.xml' def loop(gui_port="8384", host="sync"): api_key = xml.parse_api_key(DEFAULT_CONFIG_XML_PATH) print("Found API Key: {0}".format(api_key)) xml.set_listen_ip_to_any(DEFAULT_CONFIG_XML_PATH, DEFAULT_CONFIG_XML_PATH, 8384) syncthing = SyncthingClient(host, gui_port, api_key) my_device_id = syncthing.get_my_device_id() print("Found Device ID: {0}".format(my_device_id)) etcd = EtcdClient('etcd') etcd.append_device_id(my_device_id) device_ids = etcd.get_device_list() syncthing.add_devices(device_ids) syncthing.print_debug_info() if __name__ == "__main__": loop()