- self.name = kwargs.get('name')
- self.provider_class = kwargs.get('provider_class')
- self.control_location = kwargs.get('control_location')
- if kwargs.get('control_location'):
- self.control_location = map_control_location(
- kwargs['control_location'])
- else:
- self.control_location = None
-
- self.cipher = kwargs.get('cipher')
- self.key_size = kwargs.get('key_size')
-
- if (not self.name or not self.provider_class
- or not self.control_location):
- raise VolumeTypeSettingsError(
- 'The attributes name, provider_class, and control_location '
- 'are required')
-
- def __eq__(self, other):
- return (self.name == other.name
- and self.provider_class == other.provider_class
- and self.control_location == other.control_location
- and self.cipher == other.cipher
- and self.key_size == other.key_size)
-
-
-def map_control_location(control_location):
- """
- Takes a the protocol value maps it to the Consumer enum. When None return
- None
- :param control_location: the value to map to the Enum
- :return: a ControlLocation enum object
- :raise: Exception if control_location parameter is invalid
- """
- if not control_location:
- return None
- elif isinstance(control_location, ControlLocation):
- return control_location
- else:
- proto_str = str(control_location)
- if proto_str == 'front-end':
- return ControlLocation.front_end
- elif proto_str == 'back-end':
- return ControlLocation.back_end
- else:
- raise VolumeTypeSettingsError('Invalid Consumer - ' + proto_str)
-
-
-class VolumeTypeSettingsError(Exception):