47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
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.safe_load(ymlfile)
|
|
|
|
for section in cfg:
|
|
print(section)
|
|
exit()
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|