def setUp(self): """ Creates objects for testing cinder_utils.py """ guid = uuid.uuid4() self.qos_name = self.__class__.__name__ + '-' + str(guid) + '-qos' self.vol_type_name = self.__class__.__name__ + '-' + str(guid) self.specs = {'foo': 'bar'} self.cinder = cinder_utils.cinder_client( self.os_creds, self.os_session) qos_settings = QoSConfig( name=self.qos_name, specs=self.specs, consumer=Consumer.both) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.volume_type = None
def create(self): """ Creates the qos in OpenStack if it does not already exist and returns the domain QoS object :return: The QoS domain object or None """ self.initialize() if not self.__qos: self.__qos = cinder_utils.create_qos(self._cinder, self.qos_settings) logger.info('Created qos with name - %s', self.qos_settings.name) return self.__qos
def test_create_qos_back(self): """ Tests the cinder_utils.create_qos() """ qos_settings = QoSConfig( name=self.qos_name, specs=self.specs, consumer=Consumer.back_end) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.assertIsNotNone(self.qos) qos1 = cinder_utils.get_qos(self.cinder, qos_settings=qos_settings) self.assertIsNotNone(qos1) validation_utils.objects_equivalent(self.qos, qos1) qos2 = cinder_utils.get_qos_by_id(self.cinder, qos1.id) self.assertIsNotNone(qos2) validation_utils.objects_equivalent(self.qos, qos2)
def test_create_delete_qos(self): """ Tests the cinder_utils.create_qos() """ qos_settings = QoSConfig(name=self.qos_name, consumer=Consumer.both) self.qos = cinder_utils.create_qos(self.cinder, qos_settings) self.assertIsNotNone(self.qos) self.assertEqual(self.qos_name, self.qos.name) qos = cinder_utils.get_qos( self.cinder, qos_settings=qos_settings) self.assertIsNotNone(qos) validation_utils.objects_equivalent(self.qos, qos) cinder_utils.delete_qos(self.cinder, self.qos) self.assertIsNone(cinder_utils.get_qos( self.cinder, qos_settings=qos_settings))