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