Add 'freenas_network_unlock.py'
This commit is contained in:
46
freenas_network_unlock.py
Normal file
46
freenas_network_unlock.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import requests # For the api calls
|
||||
import platform # For getting the operating system name
|
||||
import subprocess # For executing a shell command
|
||||
import yaml # For parsing the yaml config file
|
||||
|
||||
with open("config.yml", 'r') as ymlfile:
|
||||
cfg = yaml.load(ymlfile)
|
||||
|
||||
for section in cfg:
|
||||
print(section)
|
||||
break
|
||||
|
||||
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
|
||||
|
||||
#if ping(FREENAS_HOST):
|
||||
VOLUMES = requests.get(
|
||||
'https://{}/api/v1.0/storage/volume/'.format(FREENAS_HOST),
|
||||
auth=('root', '{}'.format(ROOT_PASSWORD)),
|
||||
verify='{}'.format(CA_CERT),
|
||||
).json()
|
||||
|
||||
|
||||
for volume in VOLUMES:
|
||||
if volume['is_decrypted'] == False:
|
||||
print(volume['vol_guid'])
|
||||
#else:
|
||||
#print("Host,{}, is not online".format(FREENAS_HOST))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user