added services to reload

This commit is contained in:
2025-10-24 02:39:27 +00:00
parent a24c81160f
commit 807b5c21d6

View File

@@ -425,6 +425,8 @@ if __name__ == '__main__':
URI = config['URI']
VERIFY_TLS = config['Verify TLS']
API_KEY = config['API Key']
# Services excluded from being reloaded
EXCLUDED_SERVICES = ["ssh", "snmp", "ups"]
with Client(uri="wss://{}/api/current".format(URI), verify_ssl=VERIFY_TLS) as c:
if c.call("auth.login_with_api_key", API_KEY):
logger.debug('Successfully logged into {}'.format(URI))
@@ -455,6 +457,14 @@ if __name__ == '__main__':
logger.error('Dataset {} was NOT unlocked'.format(pool_name))
else:
logger.info('Dataset {} is already unlocked'.format(pool_name))
services = c.call("service.query")
for service in services:
if service['enable'] and service['service'] not in EXCLUDED_SERVICES:
logger.debug('Service {} is enabled'.format(service['service']))
reloaded = c.call("service.control", "RELOAD", service['service'], job=True)
if reloaded:
logger.info('Service {} successfully reloaded'.format(service['service']))
else:
logger.error('Service {} was NOT reloaded'.format(service['service']))
client.close()
sys.exit(0)