2021-01-29 10:13:59 +00:00
|
|
|
import syncthing_monitor.config_xml as xml
|
2021-01-29 09:59:59 +00:00
|
|
|
from syncthing_monitor.etcd_cluster_info import append_device_id, get_device_list
|
2021-01-29 10:13:59 +00:00
|
|
|
from syncthing_monitor.syncthing_rest import SyncthingClient
|
|
|
|
|
|
|
|
DEFAULT_CONFIG_XML_PATH = '/config/config.xml'
|
2021-01-28 10:56:11 +00:00
|
|
|
|
|
|
|
|
2021-01-28 13:31:25 +00:00
|
|
|
def loop(gui_port="8384", host="sync"):
|
2021-01-29 10:13:59 +00:00
|
|
|
api_key = xml.parse_api_key(DEFAULT_CONFIG_XML_PATH)
|
2021-01-28 10:56:11 +00:00
|
|
|
print("Found API Key: {0}".format(api_key))
|
|
|
|
|
2021-01-29 10:13:59 +00:00
|
|
|
xml.set_listen_ip_to_any(DEFAULT_CONFIG_XML_PATH, DEFAULT_CONFIG_XML_PATH, 8384)
|
2021-01-28 13:31:25 +00:00
|
|
|
|
2021-01-29 10:13:59 +00:00
|
|
|
syncthing = SyncthingClient(host, gui_port, api_key)
|
|
|
|
my_device_id = syncthing.get_my_device_id()
|
|
|
|
print("Found Device ID: {0}".format(my_device_id))
|
2021-01-28 13:31:25 +00:00
|
|
|
|
2021-01-29 10:13:59 +00:00
|
|
|
append_device_id(my_device_id, 'etcd')
|
2021-01-29 09:59:59 +00:00
|
|
|
device_ids = get_device_list('etcd')
|
2021-01-29 10:13:59 +00:00
|
|
|
syncthing.post_devices(device_ids)
|
|
|
|
syncthing.print_debug_info()
|
2021-01-29 08:28:35 +00:00
|
|
|
|
2021-01-28 10:56:11 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
loop()
|