def build_bootstrap_action(path, name='Bootstrap Action', args=None): if path is None: raise exceptions.MissingParametersError( object_name='ScriptBootstrapActionConfig', missing='Path') ba_config = {} apply_dict(ba_config, 'Name', name) script_config = {} apply_dict(script_config, 'Args', args) script_config['Path'] = path apply_dict(ba_config, 'ScriptBootstrapAction', script_config) return ba_config
def _verify_emrfs_args(emrfs_args): # Encryption should have a valid value if 'Encryption' in emrfs_args \ and emrfs_args['Encryption'].upper() not in ENCRYPTION_TYPES: raise exceptions.UnknownEncryptionTypeError( encryption=emrfs_args['Encryption']) # Only one of SSE and Encryption should be configured if 'SSE' in emrfs_args and 'Encryption' in emrfs_args: raise exceptions.BothSseAndEncryptionConfiguredError( sse=emrfs_args['SSE'], encryption=emrfs_args['Encryption']) # CSE should be configured correctly # ProviderType should be present and should have valid value # Given the type, the required parameters should be present if ('Encryption' in emrfs_args and emrfs_args['Encryption'].upper() == constants.EMRFS_CLIENT_SIDE): if 'ProviderType' not in emrfs_args: raise exceptions.MissingParametersError( object_name=CSE_OPTION_NAME, missing='ProviderType') elif emrfs_args['ProviderType'].upper() not in CSE_PROVIDER_TYPES: raise exceptions.UnknownCseProviderTypeError( provider_type=emrfs_args['ProviderType']) elif emrfs_args['ProviderType'].upper() == 'KMS': _verify_required_args(emrfs_args.keys(), CSE_KMS_REQUIRED_KEYS, CSE_KMS_OPTION_NAME) elif emrfs_args['ProviderType'].upper() == 'CUSTOM': _verify_required_args(emrfs_args.keys(), CSE_CUSTOM_REQUIRED_KEYS, CSE_CUSTOM_OPTION_NAME) # No child attributes should be present if the parent feature is not # configured if 'Consistent' not in emrfs_args: _verify_child_args(emrfs_args.keys(), CONSISTENT_OPTIONAL_KEYS, CONSISTENT_OPTION_NAME) if not _need_to_configure_cse(emrfs_args, 'KMS'): _verify_child_args(emrfs_args.keys(), CSE_KMS_REQUIRED_KEYS, CSE_KMS_OPTION_NAME) if not _need_to_configure_cse(emrfs_args, 'CUSTOM'): _verify_child_args(emrfs_args.keys(), CSE_CUSTOM_REQUIRED_KEYS, CSE_CUSTOM_OPTION_NAME)
def check_required_field(structure, name, value): if not value: raise exceptions.MissingParametersError( object_name=structure, missing=name)
def _verify_required_args(actual_keys, required_keys, object_name): if any(x not in actual_keys for x in required_keys): missing_keys = list( sorted(set(required_keys).difference(set(actual_keys)))) raise exceptions.MissingParametersError( object_name=object_name, missing=emrutils.join(missing_keys))