def test_nova_instance_create(self):
        compute_model = self.fake_cdmc.generate_scenario_3_with_2_nodes()
        self.fake_cdmc.cluster_data_model = compute_model
        handler = novanotification.InstanceCreated(self.fake_cdmc)

        instance0_uuid = 'c03c0bf9-f46e-4e4f-93f1-817568567ee2'

        self.assertRaises(exception.InstanceNotFound,
                          compute_model.get_instance_by_uuid, instance0_uuid)

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

        instance0 = compute_model.get_instance_by_uuid(instance0_uuid)

        self.assertEqual(element.InstanceState.ACTIVE.value, instance0.state)
        self.assertEqual(1, instance0.vcpus)
        self.assertEqual(1, instance0.disk_capacity)
        self.assertEqual(512, instance0.memory)
Exemple #2
0
    def __init__(self):
        self.api_version = self.API_VERSION
        self.service_name = None

        # fake cluster instead on Nova CDM
        self.fake_cdmc = faker_cluster_state.FakerModelCollector()

        self.publisher_id = 'test_publisher_id'
        self.conductor_topic = 'test_conductor_topic'
        self.status_topic = 'test_status_topic'
        self.notification_topics = ['nova']

        self.conductor_endpoints = []  # Disable audit endpoint
        self.status_endpoints = []

        self.notification_endpoints = [
            novanotification.ServiceUpdated(self.fake_cdmc),
            novanotification.InstanceCreated(self.fake_cdmc),
            novanotification.InstanceUpdated(self.fake_cdmc),
            novanotification.InstanceDeletedEnd(self.fake_cdmc),
            novanotification.LegacyInstanceCreatedEnd(self.fake_cdmc),
            novanotification.LegacyInstanceUpdated(self.fake_cdmc),
            novanotification.LegacyLiveMigratedEnd(self.fake_cdmc),
            novanotification.LegacyInstanceDeletedEnd(self.fake_cdmc),
        ]
 def notification_endpoints(self):
     return [
         novanotification.ServiceUpdated(self.fake_cdmc),
         novanotification.InstanceCreated(self.fake_cdmc),
         novanotification.InstanceUpdated(self.fake_cdmc),
         novanotification.InstanceDeletedEnd(self.fake_cdmc),
         novanotification.LegacyInstanceCreatedEnd(self.fake_cdmc),
         novanotification.LegacyInstanceUpdated(self.fake_cdmc),
         novanotification.LegacyLiveMigratedEnd(self.fake_cdmc),
         novanotification.LegacyInstanceDeletedEnd(self.fake_cdmc),
     ]
Exemple #4
0
    def notification_endpoints(self):
        """Associated notification endpoints

        :return: Associated notification endpoints
        :rtype: List of :py:class:`~.EventsNotificationEndpoint` instances
        """
        return [
            nova.ServiceUpdated(self),
            nova.InstanceCreated(self),
            nova.InstanceUpdated(self),
            nova.InstanceDeletedEnd(self),
            nova.LegacyInstanceCreatedEnd(self),
            nova.LegacyInstanceUpdated(self),
            nova.LegacyInstanceDeletedEnd(self),
            nova.LegacyLiveMigratedEnd(self),
        ]