26 lines
825 B
Python
26 lines
825 B
Python
import syncthing_monitor.config_xml as xml
|
|
from syncthing_monitor.etcd_cluster_info import append_device_id, get_device_list
|
|
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))
|
|
|
|
append_device_id(my_device_id, 'etcd')
|
|
device_ids = get_device_list('etcd')
|
|
syncthing.post_devices(device_ids)
|
|
syncthing.print_debug_info()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
loop()
|