Beispiel #1
0
    def test_vol_type_settings_from_vol(self):
        encryption = VolumeTypeEncryption(
            volume_encryption_id='vol-encrypt-id',
            volume_type_id='vol-typ-id',
            control_location='front-end',
            provider='FooClass',
            cipher='1',
            key_size=1)
        qos_spec = QoSSpec(name='qos-spec-name',
                           spec_id='qos-spec-id',
                           consumer=Consumer.back_end)
        volume_type = VolumeType(name='vol-type-name',
                                 volume_type_id='vol-type-id',
                                 public=True,
                                 encryption=encryption,
                                 qos_spec=qos_spec)

        settings = settings_utils.create_volume_type_config(volume_type)
        self.assertEqual(volume_type.name, settings.name)
        self.assertEqual(volume_type.public, settings.public)

        encrypt_settings = settings.encryption
        self.assertIsNotNone(encrypt_settings)
        self.assertEqual(encryption.control_location,
                         encrypt_settings.control_location.value)
        self.assertEqual(encryption.cipher, encrypt_settings.cipher)
        self.assertEqual(encryption.key_size, encrypt_settings.key_size)

        self.assertEqual(qos_spec.name, settings.qos_spec_name)
Beispiel #2
0
def get_qos_by_id(cinder, qos_id):
    """
    Returns an OpenStack qos object for a given name
    :param cinder: the Cinder client
    :param qos_id: the qos ID to lookup
    :return: the SNAPS-OO Domain Volume object or None
    """
    qos = cinder.qos_specs.get(qos_id)
    return QoSSpec(name=qos.name, spec_id=qos.id, consumer=qos.consumer)
Beispiel #3
0
    def test_construction_positional(self):
        encryption = VolumeTypeEncryption('id-encrypt1', 'id-vol-type1',
                                          'loc1', 'provider1', 'cipher1', 99)
        qos_spec = QoSSpec('name', 'id', 'consumer')

        volume_type = VolumeType('name', 'id', True, encryption, qos_spec)
        self.assertEqual('name', volume_type.name)
        self.assertEqual('id', volume_type.id)
        self.assertTrue(volume_type.public)
        self.assertEqual(encryption, volume_type.encryption)
        self.assertEqual(qos_spec, volume_type.qos_spec)
Beispiel #4
0
def create_qos(cinder, qos_settings):
    """
    Creates and returns OpenStack qos object with an external URL
    :param cinder: the cinder client
    :param qos_settings: the qos settings object
    :return: the qos domain object
    :raise Exception if using a file and it cannot be found
    """
    specs = qos_settings.specs
    specs['consumer'] = qos_settings.consumer.value
    qos = cinder.qos_specs.create(qos_settings.name, qos_settings.specs)
    return QoSSpec(name=qos.name, spec_id=qos.id, consumer=qos.consumer)
Beispiel #5
0
def get_qos(cinder, qos_name=None, qos_settings=None):
    """
    Returns an OpenStack QoS object for a given name
    :param cinder: the Cinder client
    :param qos_name: the qos name to lookup
    :param qos_settings: the qos settings used for lookups
    :return: the qos object or None
    """
    os_qos = __get_os_qos(cinder, qos_name, qos_settings)
    if os_qos:
        return QoSSpec(name=os_qos.name,
                       spec_id=os_qos.id,
                       consumer=os_qos.consumer)
Beispiel #6
0
    def test_construction_named(self):
        encryption = VolumeTypeEncryption('id-encrypt1', 'id-vol-type1',
                                          'loc1', 'provider1', 'cipher1', 99)
        qos_spec = QoSSpec('name', 'id', 'consumer')

        volume_type = VolumeType(qos_spec=qos_spec,
                                 encryption=encryption,
                                 volume_type_id='id',
                                 name='name',
                                 public='true')
        self.assertEqual('name', volume_type.name)
        self.assertEqual('id', volume_type.id)
        self.assertTrue(volume_type.public)
        self.assertEqual(encryption, volume_type.encryption)
        self.assertEqual(qos_spec, volume_type.qos_spec)
Beispiel #7
0
 def test_construction_named(self):
     qos_spec = QoSSpec(consumer='consumer', spec_id='id', name='name')
     self.assertEqual('name', qos_spec.name)
     self.assertEqual('id', qos_spec.id)
     self.assertEqual('consumer', qos_spec.consumer)
Beispiel #8
0
 def test_construction_positional(self):
     qos_spec = QoSSpec('name', 'id', 'consumer')
     self.assertEqual('name', qos_spec.name)
     self.assertEqual('id', qos_spec.id)
     self.assertEqual('consumer', qos_spec.consumer)