Update 'freenas_network_unlock.py'

This commit is contained in:
2020-03-04 12:19:43 -05:00
parent 710089cb3f
commit 5cdb78cbaf

View File

@@ -10,7 +10,7 @@ def request(resource, method='GET', data=None):
data = ''
url = 'https://127.0.0.1/api/v1.0/{}'.format(resource)
logging.debug('Request URL: {}'.format(url))
logging.debug('Request Data: {}'.format(json.dumps(data)))
logging.debug('Request Data: {}'.format(data))
logging.debug('CA Certificate Path: {}'.format(config.CA_CERT_PATH))
if not config.CA_CERT_PATH:
config.CA_CERT_PATH = False
@@ -55,7 +55,7 @@ for pool in POOLS['response']:
recovery_key = open('/mnt/ramfs/{}.recoveryKey'.format(pool['name']),'rb')
recovery_key_binary = recovery_key.read()
recovery_key_string = (base64.b64encode(recovery_key_binary)).decode('ascii')
response = request('storage/volume/{}/unlock/'.format(pool['name']), 'POST', "{'recovery_key': '{}'.format(recovery_key_string)}")
response = request('storage/volume/{}/unlock/'.format(pool['name']), 'POST', {'recovery_key': {}.format(recovery_key_string)})
if response['ok']:
logging.info('Pool {} was unlocked successfully'.format(pool['name']))
else: