Exemplo n.º 1
0
    def test_save_should_persist_nova_rawdata_to_database(self):
        body = {
            "event_type": "compute.instance.exists",
            '_context_request_id': REQUEST_ID_1,
            '_context_project_id': TENANT_ID_1,
            "timestamp": TIMESTAMP_1,
            "publisher_id": "compute.global.preprod-ord.ohthree.com",
            "payload": {
                'instance_id': INSTANCE_ID_1,
                "status": "saving",
                "container_format": "ovf",
                "properties": {
                    "image_type": "snapshot",
                },
                "tenant": "5877054",
                "old_state": 'old_state',
                "old_task_state": 'old_task',
                "image_meta": {
                    "org.openstack__1__architecture": 'os_arch',
                    "org.openstack__1__os_distro": 'os_distro',
                    "org.openstack__1__os_version": 'os_version',
                    "com.rackspace__1__options": 'rax_opt',
                },
                "state": 'state',
                "new_task_state": 'task'
            }
        }
        deployment = "1"
        routing_key = "monitor.info"
        json_body = json.dumps([routing_key, body])
        raw = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(db, 'create_nova_rawdata')
        db.create_nova_rawdata(
            deployment="1",
            tenant=TENANT_ID_1,
            json=json_body,
            routing_key=routing_key,
            when=utils.str_time_to_unix(TIMESTAMP_1),
            publisher="compute.global.preprod-ord.ohthree.com",
            event="compute.instance.exists",
            service="compute",
            host="global.preprod-ord.ohthree.com",
            instance=INSTANCE_ID_1,
            request_id=REQUEST_ID_1,
            image_type=image_type.get_numeric_code(body['payload']),
            old_state='old_state',
            old_task='old_task',
            os_architecture='os_arch',
            os_distro='os_distro',
            os_version='os_version',
            rax_options='rax_opt',
            state='state',
            task='task').AndReturn(raw)

        self.mox.ReplayAll()

        notification = NovaNotification(body, deployment, routing_key, json_body)
        self.assertEquals(notification.save(), raw)
        self.mox.VerifyAll()
Exemplo n.º 2
0
 def save(self):
     return db.create_nova_rawdata(deployment=self.deployment,
                                   routing_key=self.routing_key,
                                   tenant=self.tenant,
                                   json=self.json,
                                   when=self.when,
                                   publisher=self.publisher,
                                   event=self.event,
                                   service=self.service,
                                   host=self.host,
                                   instance=self.instance,
                                   request_id=self.request_id,
                                   state=self.state,
                                   old_state=self.old_state,
                                   task=self.task,
                                   old_task=self.old_task,
                                   os_architecture=self.os_architecture,
                                   os_distro=self.os_distro,
                                   os_version=self.os_version,
                                   rax_options=self.rax_options)
Exemplo n.º 3
0
 def save(self):
     return db.create_nova_rawdata(deployment=self.deployment,
                                   routing_key=self.routing_key,
                                   tenant=self.tenant,
                                   json=self.json,
                                   when=self.when,
                                   publisher=self.publisher,
                                   event=self.event,
                                   service=self.service,
                                   host=self.host,
                                   instance=self.instance,
                                   request_id=self.request_id,
                                   image_type=self.image_type,
                                   state=self.state,
                                   old_state=self.old_state,
                                   task=self.task,
                                   old_task=self.old_task,
                                   os_architecture=self.os_architecture,
                                   os_distro=self.os_distro,
                                   os_version=self.os_version,
                                   rax_options=self.rax_options)
Exemplo n.º 4
0
    def test_save_should_persist_nova_rawdata_to_database(self):
        body = {
            "event_type": "compute.instance.exists",
            '_context_request_id': REQUEST_ID_1,
            '_context_project_id': TENANT_ID_1,
            "timestamp": TIMESTAMP_1,
            "publisher_id": "compute.global.preprod-ord.ohthree.com",
            "payload": {
                'instance_id': INSTANCE_ID_1,
                "status": "saving",
                "container_format": "ovf",
                "properties": {
                    "image_type": "snapshot",
                },
                "tenant": "5877054",
                "old_state": 'old_state',
                "old_task_state": 'old_task',
                "image_meta": {
                    "org.openstack__1__architecture": 'os_arch',
                    "org.openstack__1__os_distro": 'os_distro',
                    "org.openstack__1__os_version": 'os_version',
                    "com.rackspace__1__options": 'rax_opt',
                },
                "state": 'state',
                "new_task_state": 'task',
                "bandwidth": {
                    "private": {
                        "bw_in": 0,
                        "bw_out": 264902
                    },
                    "public": {
                        "bw_in": 0,
                        "bw_out": 1697240969
                    }
                }
            }
        }
        deployment = "1"
        routing_key = "monitor.info"
        json_body = json.dumps([routing_key, body])
        raw = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(db, 'create_nova_rawdata')
        db.create_nova_rawdata(
            deployment="1",
            tenant=TENANT_ID_1,
            json=json_body,
            routing_key=routing_key,
            when=utils.str_time_to_unix(TIMESTAMP_1),
            publisher="compute.global.preprod-ord.ohthree.com",
            event="compute.instance.exists",
            service="compute",
            host="global.preprod-ord.ohthree.com",
            instance=INSTANCE_ID_1,
            request_id=REQUEST_ID_1,
            image_type=image_type.get_numeric_code(body['payload']),
            old_state='old_state',
            old_task='old_task',
            os_architecture='os_arch',
            os_distro='os_distro',
            os_version='os_version',
            rax_options='rax_opt',
            state='state',
            task='task').AndReturn(raw)

        self.mox.ReplayAll()

        notification = NovaNotification(body, deployment, routing_key,
                                        json_body)
        self.assertEquals(notification.save(), raw)
        self.mox.VerifyAll()