Updated to have jail storage pool and activate pool after unlock
This commit is contained in:
@@ -266,6 +266,7 @@ def new_pool_details():
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("The pool encryption passphrases do not match, please try again.")
|
print("The pool encryption passphrases do not match, please try again.")
|
||||||
|
|
||||||
array = dict()
|
array = dict()
|
||||||
array[pool_name] = dict()
|
array[pool_name] = dict()
|
||||||
array[pool_name]["pool_passphrase"] = pool_passphrase
|
array[pool_name]["pool_passphrase"] = pool_passphrase
|
||||||
@@ -356,9 +357,9 @@ if __name__ == '__main__':
|
|||||||
user_input = input("n/q> ")
|
user_input = input("n/q> ")
|
||||||
if user_input.casefold() == "n":
|
if user_input.casefold() == "n":
|
||||||
config = dict()
|
config = dict()
|
||||||
api_key = input("Please enter your API key: ")
|
config['API Key'] = input("Please enter your API key: ")
|
||||||
config['API Key'] = api_key
|
|
||||||
config['Pools'] = new_pool_details()
|
config['Pools'] = new_pool_details()
|
||||||
|
config['jailStoragePool'] = select_pool(config['Pools'], "select for jail storage")
|
||||||
write_config_file(config, secrets_config_file)
|
write_config_file(config, secrets_config_file)
|
||||||
break
|
break
|
||||||
elif user_input.casefold() == "q":
|
elif user_input.casefold() == "q":
|
||||||
@@ -371,20 +372,26 @@ if __name__ == '__main__':
|
|||||||
print(" ")
|
print(" ")
|
||||||
for pool in config['Pools']:
|
for pool in config['Pools']:
|
||||||
print(pool)
|
print(pool)
|
||||||
|
print("Jail storage pool: {}".format(config['jailStoragePool']))
|
||||||
print(" ")
|
print(" ")
|
||||||
print("a) Edit API Key")
|
print("a) Edit API Key")
|
||||||
print("e) Edit pool")
|
print("e) Edit pool")
|
||||||
|
print("j) Edit jail storage pool")
|
||||||
print("n) New pool")
|
print("n) New pool")
|
||||||
print("d) Delete pool")
|
print("d) Delete pool")
|
||||||
print("q) Quit config")
|
print("q) Quit config")
|
||||||
user_input = input("a/e/n/d/q> ")
|
user_input = input("a/e/j/n/d/q> ")
|
||||||
# Edit API Key
|
# Edit API Key
|
||||||
if user_input.casefold() == "a":
|
if user_input.casefold() == "a":
|
||||||
api_key = input("Please enter your API key: ")
|
config['API Key'] = input("Please enter your API key: ")
|
||||||
config['API Key'] = api_key
|
|
||||||
write_config_file(config, secrets_config_file)
|
write_config_file(config, secrets_config_file)
|
||||||
# Editing an account
|
# Editing an account
|
||||||
elif user_input.casefold() == "e":
|
elif user_input.casefold() == "e":
|
||||||
|
config['jailStoragePool'] = select_pool(config['Pools'], "select for jail storage")
|
||||||
|
write_config_file(config, secrets_config_file)
|
||||||
|
break
|
||||||
|
# Editing jail storage pool
|
||||||
|
elif user_input.casefold() == "j":
|
||||||
pool_to_edit = select_pool(config['Pools'])
|
pool_to_edit = select_pool(config['Pools'])
|
||||||
pool_details = edit_pool_details(config['Pools'], pool_to_edit)
|
pool_details = edit_pool_details(config['Pools'], pool_to_edit)
|
||||||
del config['Pools'][pool_to_edit]
|
del config['Pools'][pool_to_edit]
|
||||||
@@ -425,6 +432,7 @@ if __name__ == '__main__':
|
|||||||
# run the decryption of the keys and unlock the pool
|
# run the decryption of the keys and unlock the pool
|
||||||
config = read_config_file(secrets_config_file)
|
config = read_config_file(secrets_config_file)
|
||||||
api_key = config['API Key']
|
api_key = config['API Key']
|
||||||
|
jail_storage_pool = config['jailStoragePool']
|
||||||
API_POOLS = request('pool', api_key)['response']
|
API_POOLS = request('pool', api_key)['response']
|
||||||
API_DATASETS = request('pool/dataset', api_key)['response']
|
API_DATASETS = request('pool/dataset', api_key)['response']
|
||||||
for pool_dataset_name in config['Pools']:
|
for pool_dataset_name in config['Pools']:
|
||||||
@@ -465,6 +473,11 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
logger.info('Dataset {} is already unlocked'.format(dataset['name']))
|
logger.info('Dataset {} is already unlocked'.format(dataset['name']))
|
||||||
|
|
||||||
|
# make sure jail storage pool is set
|
||||||
|
logger.info('Setting jail storage pool to {}'.format(jail_storage_pool))
|
||||||
|
response = request('jail/activate', api_key, 'POST', '{}'.format(jail_storage_pool))
|
||||||
|
if response['ok']:
|
||||||
|
logger.info('Successfully set jail storage pool to {} successfully'.format(jail_storage_pool))
|
||||||
# start any jails that are set to start on boot but are most likely on an encrypted pool
|
# start any jails that are set to start on boot but are most likely on an encrypted pool
|
||||||
API_JAILS = request('jail', api_key)['response']
|
API_JAILS = request('jail', api_key)['response']
|
||||||
for jail in API_JAILS:
|
for jail in API_JAILS:
|
||||||
@@ -480,5 +493,7 @@ if __name__ == '__main__':
|
|||||||
logger.error('Jail {} was NOT started successfully'.format(jail['id']))
|
logger.error('Jail {} was NOT started successfully'.format(jail['id']))
|
||||||
else:
|
else:
|
||||||
logger.info('Jail {} is already started'.format(jail['id']))
|
logger.info('Jail {} is already started'.format(jail['id']))
|
||||||
|
else:
|
||||||
|
logger.error('Unable to set jail storage pool to {}'.format(jail_storage_pool))
|
||||||
client.close()
|
client.close()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
Reference in New Issue
Block a user