Update 'freenas_network_unlock.py'
This commit is contained in:
@@ -41,20 +41,20 @@ def request(resource, method='GET', data=None):
|
|||||||
if r.ok:
|
if r.ok:
|
||||||
try:
|
try:
|
||||||
logging.debug('Request Returned JSON: {}'.format(r.json()))
|
logging.debug('Request Returned JSON: {}'.format(r.json()))
|
||||||
return [r.ok, r.status_code, r.json()]
|
return ['ok': r.ok, 'status_code': r.status_code, 'response': r.json()]
|
||||||
except:
|
except:
|
||||||
logging.debug('Request Returned Text: {}'.format(r.text))
|
logging.debug('Request Returned Text: {}'.format(r.text))
|
||||||
return [r.ok, r.status_code, r.text]
|
return ['ok': r.ok, 'status_code': r.status_code, 'response':, r.text]
|
||||||
raise ValueError(r)
|
raise ValueError(r)
|
||||||
|
|
||||||
#if ping(config.HOSTNAME):
|
#if ping(config.HOSTNAME):
|
||||||
POOLS = request('storage/volume/', 'GET')
|
POOLS = request('storage/volume/', 'GET')
|
||||||
|
|
||||||
for pool in POOLS:
|
for pool in POOLS['response']:
|
||||||
if pool['is_decrypted'] == False:
|
if pool['is_decrypted'] == False:
|
||||||
logging.info('Pool {} is locked'.format(pool['name']))
|
logging.info('Pool {} is locked'.format(pool['name']))
|
||||||
response = request('storage/volume/{}/unlock/'.format(pool['name']), 'POST', {'passphrase': '{}'.format(config.POOLS[pool['name']])})
|
response = request('storage/volume/{}/unlock/'.format(pool['name']), 'POST', {'passphrase': '{}'.format(config.POOLS[pool['name']])})
|
||||||
if response[0]:
|
if response['ok']:
|
||||||
logging.info('Pool {} was unlocked successfully'.format(pool['name']))
|
logging.info('Pool {} was unlocked successfully'.format(pool['name']))
|
||||||
else:
|
else:
|
||||||
logging.error('Pool {} was NOT unlocked successfully'.format(pool['name']))
|
logging.error('Pool {} was NOT unlocked successfully'.format(pool['name']))
|
||||||
|
|||||||
Reference in New Issue
Block a user