diff options
author | Peter Stachowski <peter@tesora.com> | 2016-03-08 00:24:41 -0500 |
---|---|---|
committer | Peter Stachowski <peter@tesora.com> | 2016-03-15 12:21:55 -0400 |
commit | 7d33401ee322e92416399a70a9d3116a2aba4335 (patch) | |
tree | f8ea60e3fc03de8ca892c59f052f2b0583ae2551 /trove/common/utils.py | |
parent | f7cda9912da2ca92a23f46cdc6f3c51ce1ac8499 (diff) | |
download | trove-7d33401ee322e92416399a70a9d3116a2aba4335.tar.gz |
Server support for instance module feature
This changeset handles the details of applying,
removing, listing and retrieving 'modules'
from Trove instances.
See https://review.openstack.org/#/c/290177 for
the corresponding troveclient changes.
Scenario tests have been extended to cover the
new functionality. These tests can be run by:
./redstack int-tests --group=module
A sample module type 'driver' - ping - is included
that simply parses the module contents for a
message=Text string and returns the 'Text' as the
status message. If no 'message=' tag is found, then
the driver reports an error message.
Due to time constraints, a few unimplemented
parts/tests of the blueprint have been triaged as bugs
and are scheduled to be fixed before mitaka-rc1.
These include:
Vertica license module driver:
https://bugs.launchpad.net/trove/+bug/1554898
Incomplete module-instances command:
https://bugs.launchpad.net/trove/+bug/1554900
Incomplete 'live-update' of modules:
https://bugs.launchpad.net/trove/+bug/1554903
Co-Authored-by: Peter Stachowski <peter@tesora.com>
Co-Authored-by: Simon Chang <schang@tesora.com>
Partially Implements: blueprint module-management
Change-Id: Ia8d3ff2f4560a6d997df99d41012ea61fb0096f7
Depends-On: If62f5e51d4628cc6a8b10303d5c3893b3bd5057e
Diffstat (limited to 'trove/common/utils.py')
-rw-r--r-- | trove/common/utils.py | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/trove/common/utils.py b/trove/common/utils.py index 2aeaf885..f86b306d 100644 --- a/trove/common/utils.py +++ b/trove/common/utils.py @@ -14,12 +14,8 @@ # under the License. """I totally stole most of this from melange, thx guys!!!""" -import base64 import collections -from Crypto.Cipher import AES -from Crypto import Random import datetime -import hashlib import inspect import os import shutil @@ -331,44 +327,3 @@ def is_collection(item): """ return (isinstance(item, collections.Iterable) and not isinstance(item, types.StringTypes)) - - -# Encryption/decryption handling methods -IV_BIT_COUNT = 16 - - -def encode_string(data_str): - byte_array = bytearray(data_str) - return base64.b64encode(byte_array) - - -def decode_string(data_str): - return base64.b64decode(data_str) - - -# Pad the data string to an multiple of pad_size -def pad_for_encryption(data_str, pad_size=IV_BIT_COUNT): - pad_count = pad_size - (len(data_str) % pad_size) - return data_str + chr(pad_count) * pad_count - - -# Unpad the data string by stripping off excess characters -def unpad_after_decryption(data_str): - return data_str[:len(data_str) - ord(data_str[-1])] - - -def encrypt_string(data_str, key, iv_bit_count=IV_BIT_COUNT): - md5_key = hashlib.md5(key).hexdigest() - iv = encode_string(Random.new().read(iv_bit_count))[:iv_bit_count] - aes = AES.new(md5_key, AES.MODE_CBC, iv) - data_str = pad_for_encryption(data_str, iv_bit_count) - encrypted_str = aes.encrypt(data_str) - return iv + encrypted_str - - -def decrypt_string(data_str, key, iv_bit_count=IV_BIT_COUNT): - md5_key = hashlib.md5(key).hexdigest() - iv = data_str[:iv_bit_count] - aes = AES.new(md5_key, AES.MODE_CBC, iv) - decrypted_str = aes.decrypt(data_str[iv_bit_count:]) - return unpad_after_decryption(decrypted_str) |