updated error handling for kmip functions
This commit is contained in:
@@ -97,7 +97,7 @@ def create_encryption_key():
|
||||
logger.debug("Successfully created a new encryption key.")
|
||||
logger.debug("Encryption Key ID: {}".format(key_id))
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to create encryption key. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
# Activate the encryption key so that it can be used.
|
||||
@@ -106,7 +106,7 @@ def create_encryption_key():
|
||||
logger.debug("Successfully activated the encryption key.")
|
||||
return key_id
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to activate encryption key. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
def create_hmac_key():
|
||||
@@ -123,7 +123,7 @@ def create_hmac_key():
|
||||
logger.debug("Successfully created a new HMAC key.")
|
||||
logger.debug("HMAC Key ID: {}".format(key_id))
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to create hmac key. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
# Activate the HMAC key so that it can be used.
|
||||
@@ -132,7 +132,7 @@ def create_hmac_key():
|
||||
logger.debug("Successfully activated the HMAC key.")
|
||||
return key_id
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to activate hmac key. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
def encrypt(data):
|
||||
@@ -171,7 +171,8 @@ def encrypt(data):
|
||||
array_json_b64 = base64.b64encode(array_json.encode('utf-8')).decode()
|
||||
return array_json_b64
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to encrypt data. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
def decrypt(data):
|
||||
array_json = base64.b64decode(data)
|
||||
@@ -217,7 +218,8 @@ def decrypt_v1(array):
|
||||
plain_text = plain_text.decode('utf-8')
|
||||
return plain_text
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
logger.error("Unable to decrypt data. Error: {}".format(e))
|
||||
sys.exit(-1)
|
||||
|
||||
def new_account_details():
|
||||
print("Requesting account details to add to config.")
|
||||
|
||||
Reference in New Issue
Block a user