Exemple #1
0
 def notification_endpoints(self):
     return [
         cnotification.CapacityNotificationEndpoint(self.fake_cdmc),
         cnotification.VolumeCreateEnd(self.fake_cdmc),
         cnotification.VolumeUpdateEnd(self.fake_cdmc),
         cnotification.VolumeDeleteEnd(self.fake_cdmc),
         cnotification.VolumeAttachEnd(self.fake_cdmc),
         cnotification.VolumeDetachEnd(self.fake_cdmc),
         cnotification.VolumeResizeEnd(self.fake_cdmc),
     ]
    def test_cinder_volume_delete(self, m_cinder_helper):
        """test deleting volume"""

        # create storage_pool_by name mock
        return_pool_mock = mock.Mock()
        return_pool_mock.configure_mock(name='host_0@backend_0#pool_0',
                                        total_volumes='1',
                                        total_capacity_gb='500',
                                        free_capacity_gb='460',
                                        provisioned_capacity_gb='40',
                                        allocated_capacity_gb='40')

        m_get_storage_pool_by_name = mock.Mock(
            side_effect=lambda name: return_pool_mock)

        m_cinder_helper.return_value = mock.Mock(
            get_storage_pool_by_name=m_get_storage_pool_by_name)

        storage_model = self.fake_cdmc.generate_scenario_1()
        self.fake_cdmc.cluster_data_model = storage_model
        handler = cnotification.VolumeDeleteEnd(self.fake_cdmc)

        # volume exists before consuming
        volume_0_uuid = 'VOLUME_0'
        volume_0 = storage_model.get_volume_by_uuid(volume_0_uuid)
        self.assertEqual(volume_0_uuid, volume_0.uuid)

        message = self.load_message('scenario_1_volume-delete.json')
        handler.info(
            ctxt=self.context,
            publisher_id=message['publisher_id'],
            event_type=message['event_type'],
            payload=message['payload'],
            metadata=self.FAKE_METADATA,
        )

        # volume does not exists after consuming
        self.assertRaises(exception.VolumeNotFound,
                          storage_model.get_volume_by_uuid, volume_0_uuid)

        # check that capacity was updated
        pool_0_name = 'host_0@backend_0#pool_0'
        m_get_storage_pool_by_name.assert_called_once_with(pool_0_name)
        pool_0 = storage_model.get_pool_by_pool_name(pool_0_name)
        self.assertEqual(pool_0.name, pool_0_name)
        self.assertEqual(1, pool_0.total_volumes)
        self.assertEqual(460, pool_0.free_capacity_gb)
        self.assertEqual(40, pool_0.allocated_capacity_gb)
        self.assertEqual(40, pool_0.provisioned_capacity_gb)
Exemple #3
0
    def notification_endpoints(self):
        """Associated notification endpoints

        :return: Associated notification endpoints
        :rtype: List of :py:class:`~.EventsNotificationEndpoint` instances
        """
        return [
            cinder.CapacityNotificationEndpoint(self),
            cinder.VolumeCreateEnd(self),
            cinder.VolumeDeleteEnd(self),
            cinder.VolumeUpdateEnd(self),
            cinder.VolumeAttachEnd(self),
            cinder.VolumeDetachEnd(self),
            cinder.VolumeResizeEnd(self)
        ]