added services to reload
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user