class DecryptionMarkConfig(object):
    def __init__(self, logger, encryption_environment):
        self.logger = logger
        self.encryption_environment = encryption_environment
        self.command = None
        self.volume_type = None
        self.decryption_mark_config = ConfigUtil(self.encryption_environment.azure_decrypt_request_queue_path,
                                                 'decryption_request_queue',
                                                 self.logger)

    def get_current_command(self):
        return self.decryption_mark_config.get_config(CommonVariables.EncryptionEncryptionOperationKey)

    def config_file_exists(self):
        return self.decryption_mark_config.config_file_exists()
    
    def commit(self):
        key_value_pairs = []

        command = ConfigKeyValuePair(CommonVariables.EncryptionEncryptionOperationKey, self.command)
        key_value_pairs.append(command)

        volume_type = ConfigKeyValuePair(CommonVariables.EncryptionVolumeTypeKey, self.volume_type)
        key_value_pairs.append(volume_type)

        self.decryption_mark_config.save_configs(key_value_pairs)

    def clear_config(self):
        try:
            if(os.path.exists(self.encryption_environment.azure_decrypt_request_queue_path)):
                os.remove(self.encryption_environment.azure_decrypt_request_queue_path)
            return True
        except OSError as e:
            self.logger.log("Failed to clear_queue with error: {0}, stack trace: {1}".format(e, traceback.format_exc()))
            return False
Example #2
0
class EncryptionMarkConfig(object):
    def __init__(self, logger, encryption_environment):
        self.logger = logger
        self.encryption_environment = encryption_environment
        self.command = None
        self.volume_type = None
        self.diskFormatQuery = None
        self.encryption_mark_config = ConfigUtil(
            self.encryption_environment.azure_crypt_request_queue_path,
            'encryption_request_queue', self.logger)

    def get_volume_type(self):
        return self.encryption_mark_config.get_config(
            CommonVariables.EncryptionVolumeTypeKey)

    def get_current_command(self):
        return self.encryption_mark_config.get_config(
            CommonVariables.EncryptionEncryptionOperationKey)

    def get_encryption_disk_format_query(self):
        return self.encryption_mark_config.get_config(
            CommonVariables.EncryptionDiskFormatQueryKey)

    def config_file_exists(self):
        """
        we should compare the timestamp of the file with the current system time
        if not match (in 30 minutes, then should skip the file)
        """
        return self.encryption_mark_config.config_file_exists()

    def commit(self):
        key_value_pairs = []
        command = ConfigKeyValuePair(
            CommonVariables.EncryptionEncryptionOperationKey, self.command)
        key_value_pairs.append(command)
        volume_type = ConfigKeyValuePair(
            CommonVariables.EncryptionVolumeTypeKey, self.volume_type)
        key_value_pairs.append(volume_type)
        disk_format_query = ConfigKeyValuePair(
            CommonVariables.EncryptionDiskFormatQueryKey, self.diskFormatQuery)
        key_value_pairs.append(disk_format_query)
        self.encryption_mark_config.save_configs(key_value_pairs)

    def clear_config(self):
        try:
            if os.path.exists(self.encryption_environment.
                              azure_crypt_request_queue_path):
                os.remove(
                    self.encryption_environment.azure_crypt_request_queue_path)
            return True
        except OSError as e:
            self.logger.log(
                "Failed to clear_queue with error: {0}, stack trace: {1}".
                format(e, traceback.format_exc()))
            return False
class EncryptionMarkConfig(object):
    def __init__(self, logger, encryption_environment):
        self.logger = logger
        self.encryption_environment = encryption_environment
        self.command = None
        self.volume_type = None
        self.diskFormatQuery = None
        self.encryption_mark_config = ConfigUtil(self.encryption_environment.azure_crypt_request_queue_path,
                                                 'encryption_request_queue',
                                                 self.logger)

    def get_volume_type(self):
        return self.encryption_mark_config.get_config(CommonVariables.EncryptionVolumeTypeKey)

    def get_current_command(self):
        return self.encryption_mark_config.get_config(CommonVariables.EncryptionEncryptionOperationKey)

    def get_encryption_disk_format_query(self):
        return self.encryption_mark_config.get_config(CommonVariables.EncryptionDiskFormatQueryKey)

    def config_file_exists(self):
        """
        we should compare the timestamp of the file with the current system time
        if not match (in 30 minutes, then should skip the file)
        """
        return self.encryption_mark_config.config_file_exists()
    
    def commit(self):
        key_value_pairs = []
        command = ConfigKeyValuePair(CommonVariables.EncryptionEncryptionOperationKey, self.command)
        key_value_pairs.append(command)
        volume_type = ConfigKeyValuePair(CommonVariables.EncryptionVolumeTypeKey, self.volume_type)
        key_value_pairs.append(volume_type)
        disk_format_query = ConfigKeyValuePair(CommonVariables.EncryptionDiskFormatQueryKey, self.diskFormatQuery)
        key_value_pairs.append(disk_format_query)
        self.encryption_mark_config.save_configs(key_value_pairs)

    def clear_config(self):
        try:
            if os.path.exists(self.encryption_environment.azure_crypt_request_queue_path):
                os.remove(self.encryption_environment.azure_crypt_request_queue_path)
            return True
        except OSError as e:
            self.logger.log("Failed to clear_queue with error: {0}, stack trace: {1}".format(e, traceback.format_exc()))
            return False
class DecryptionMarkConfig(object):
    def __init__(self, logger, encryption_environment):
        self.logger = logger
        self.encryption_environment = encryption_environment
        self.command = None
        self.volume_type = None
        self.decryption_mark_config = ConfigUtil(
            self.encryption_environment.azure_decrypt_request_queue_path,
            'decryption_request_queue', self.logger)

    def get_current_command(self):
        return self.decryption_mark_config.get_config(
            CommonVariables.EncryptionEncryptionOperationKey)

    def config_file_exists(self):
        return self.decryption_mark_config.config_file_exists()

    def commit(self):
        key_value_pairs = []

        command = ConfigKeyValuePair(
            CommonVariables.EncryptionEncryptionOperationKey, self.command)
        key_value_pairs.append(command)

        volume_type = ConfigKeyValuePair(
            CommonVariables.EncryptionVolumeTypeKey, self.volume_type)
        key_value_pairs.append(volume_type)

        self.decryption_mark_config.save_configs(key_value_pairs)

    def clear_config(self):
        try:
            if (os.path.exists(self.encryption_environment.
                               azure_decrypt_request_queue_path)):
                os.remove(self.encryption_environment.
                          azure_decrypt_request_queue_path)
            return True
        except OSError as e:
            self.logger.log(
                "Failed to clear_queue with error: {0}, stack trace: {1}".
                format(e, traceback.format_exc()))
            return False