diff --git a/truenas_kmip_unlock.py b/truenas_kmip_unlock.py index 7c0dbae..3c84bc6 100644 --- a/truenas_kmip_unlock.py +++ b/truenas_kmip_unlock.py @@ -457,6 +457,9 @@ if __name__ == '__main__': services_to_restart = request('pool/unlock_services_restart_choices', api_key, "POST", pool['id'])['response'] first = True for service_to_restart in services_to_restart: + if service_to_restart == "jails": + logger.debug('Skipping adding the {} service'.format(services_to_restart[service_to_restart])) + continue if first: pool_services = "'{}'".format(service_to_restart) first = False @@ -484,6 +487,9 @@ if __name__ == '__main__': logger.info('Restarting services') services_to_restart = request('pool/unlock_services_restart_choices', api_key, "POST", pool['id'])['response'] for service_to_restart in services_to_restart: + if service_to_restart == "jails": + logger.debug('Skipping restarting the {} service'.format(services_to_restart[service_to_restart])) + continue logger.debug('Restarting the {} service'.format(services_to_restart[service_to_restart])) response = request('service/restart', api_key, 'POST', {'service': service_to_restart}) if response['ok']: @@ -500,6 +506,14 @@ if __name__ == '__main__': response = request('jail/activate', api_key, 'POST', '{}'.format(jail_storage_pool)) if response['ok']: logger.info('Successfully set jail storage pool to {}'.format(jail_storage_pool)) + # restart the jails service + jails_service_name = 'jails' + logger.debug('Restarting the {} service'.format(jails_service_name)) + response = request('service/restart', api_key, 'POST', {'service': jails_service_name}) + if response['ok']: + logger.debug('Service {} was restarted successfully'.format(jails_service_name)) + else: + logger.error('Service {} was NOT restarted'.format(jails_service_name)) # start any jails that are set to start on boot but are most likely on an encrypted pool API_JAILS = request('jail', api_key)['response'] for jail in API_JAILS: