Update 'freenas_network_unlock.py'
This commit is contained in:
@@ -8,20 +8,6 @@ logging.basicConfig(level=logging.DEBUG,format='%(asctime)s - [%(levelname)s] %(
|
||||
#requests_log.setLevel(logging.DEBUG)
|
||||
#requests_log.propagate = True
|
||||
|
||||
def ping(host):
|
||||
"""
|
||||
Returns True if host (str) responds to a ping request.
|
||||
Remember that a host may not respond to a ping (ICMP) request even if the host name is valid.
|
||||
"""
|
||||
|
||||
# Option for the number of packets as a function of
|
||||
param = '-n' if platform.system().lower()=='windows' else '-c'
|
||||
|
||||
# Building the command. Ex: "ping -c 1 google.com"
|
||||
command = ['ping', param, '1', host]
|
||||
|
||||
return subprocess.call(command) == 0
|
||||
|
||||
def request(resource, method='GET', data=None):
|
||||
if data is None:
|
||||
data = ''
|
||||
@@ -46,8 +32,7 @@ def request(resource, method='GET', data=None):
|
||||
logging.debug('Request Returned Text: {}'.format(r.text))
|
||||
return {'ok': r.ok, 'status_code': r.status_code, 'response': r.text}
|
||||
raise ValueError(r)
|
||||
|
||||
#if ping(config.HOSTNAME):
|
||||
|
||||
POOLS = request('storage/volume/', 'GET')
|
||||
|
||||
for pool in POOLS['response']:
|
||||
@@ -59,6 +44,4 @@ for pool in POOLS['response']:
|
||||
else:
|
||||
logging.error('Pool {} was NOT unlocked successfully'.format(pool['name']))
|
||||
else:
|
||||
logging.debug('Pool {} is already unlocked'.format(pool['name']))
|
||||
#else:
|
||||
#print("Host,{}, is not online".format(config.HOSTNAME))
|
||||
logging.debug('Pool {} is already unlocked'.format(pool['name']))
|
||||
Reference in New Issue
Block a user