Beispiel #1
0
    def test_convert_to_cuf_format_when_launched_at_in_audit_period(self):
        audit_period_beginning = '2012-09-15 10:51:11'
        audit_period_ending = '2012-09-16 10:51:11'
        launched_at = '2012-09-15 11:51:11'
        exists_message = {
            'event_type': 'test',
            'message_id': 'some_uuid',
            '_unique_id': 'e53d007a-fc23-11e1-975c-cfa6b29bb814',
            'payload': {
                'tenant_id': '2882',
                'access_ip_v4': '5.79.20.138',
                'access_ip_v6': '2a00:1a48:7804:0110:a8a0:fa07:ff08:157a',
                'audit_period_beginning': audit_period_beginning,
                'audit_period_ending': audit_period_ending,
                'bandwidth': {
                    'private': {
                        'bw_in': 0,
                        'bw_out': 264902
                    },
                    'public': {
                        'bw_in': 1001,
                        'bw_out': 19992
                    }
                },
                'image_meta': {
                    'com.rackspace__1__options': '1'
                },
                'instance_id': '56',
                'instance_type_id': '10',
                'launched_at': launched_at,
                'deleted_at': ''
            }
        }
        self.mox.StubOutWithMock(uuid, 'uuid4')
        uuid.uuid4().AndReturn('some_other_uuid')
        self.mox.ReplayAll()
        values = utils.test_nova_xml_generator_values
        values.update({'end_time': '2012-09-16 10:51:11'})
        expected_cuf_xml = utils.verified_nova_message_in_cuf_format(values)
        notification = Notification(exists_message)
        verified_message = \
            notification.convert_to_verified_message_in_cuf_format(
                {'region':'DFW','data_center':'DFW1'})

        self.assertEquals(expected_cuf_xml['payload'],
                          verified_message['payload'])
Beispiel #2
0
    def test_convert_to_cuf_format_when_launched_at_in_audit_period(self):
        audit_period_beginning = '2012-09-15 10:51:11'
        audit_period_ending = '2012-09-16 10:51:11'
        launched_at = '2012-09-15 11:51:11'
        exists_message = {
            'event_type': 'test',
            'message_id': 'some_uuid',
            '_unique_id': 'e53d007a-fc23-11e1-975c-cfa6b29bb814',
            'payload': {
                'tenant_id': '2882',
                'access_ip_v4': '5.79.20.138',
                'access_ip_v6': '2a00:1a48:7804:0110:a8a0:fa07:ff08:157a',
                'audit_period_beginning': audit_period_beginning,
                'audit_period_ending': audit_period_ending,
                'bandwidth': {'private': {'bw_in': 0, 'bw_out': 264902},
                              'public': {'bw_in': 1001,'bw_out': 19992}},
                'display_name': 'test',
                'image_meta': {'com.rackspace__1__options': '1'},
                'instance_id': '56',
                'dummy_flavor_field_name': '10',
                'launched_at': launched_at,
                'deleted_at': '',
                'instance_type': 'm1.nano',
                'state': 'active',
                'state_description': ''
            }
        }
        self.mox.StubOutWithMock(uuid, 'uuid4')
        uuid.uuid4().AndReturn('e53d007a-fc23-11e1-975c-cfa6b29bb814')
        self.mox.ReplayAll()
        values = utils.test_nova_xml_generator_values
        values.update({'end_time': '2012-09-16T10:51:11Z'})
        expected_cuf_xml = utils.verified_nova_message_in_cuf_format(
            values)
        notification = Notification(exists_message)
        verified_message = \
            notification.convert_to_verified_message_in_cuf_format(
                {'region':'DFW','data_center':'DFW1'})

        self.assertEquals(expected_cuf_xml['payload'],
                          verified_message['payload'])
Beispiel #3
0
    def test_convert_to_cuf_deterministic_id(self):
        det_id = '00efc101-1a92-528e-bd71-7fa023d4e952'
        exists_message = {
            'event_type': 'test',
            'message_id': 'some_uuid',
            'original_message_id': '7f2f0e12-fa8a-49ac-985e-d74d06a38750',
            '_unique_id': 'e53d007a-fc23-11e1-975c-cfa6b29bb814',
            'payload': {
                'tenant_id': '2882',
                'access_ip_v4': '5.79.20.138',
                'access_ip_v6': '2a00:1a48:7804:0110:a8a0:fa07:ff08:157a',
                'audit_period_beginning': '2012-09-15 11:51:11',
                'audit_period_ending': '2012-09-16 11:51:11',
                'display_name': 'test',
                'bandwidth': {
                    'private': {
                        'bw_in': 0,
                        'bw_out': 264902
                    },
                    'public': {
                        'bw_in': 1001,
                        'bw_out': 19992
                    }
                },
                'image_meta': {
                    'com.rackspace__1__options': '1'
                },
                'instance_id': '56',
                'dummy_flavor_field_name': '10',
                'launched_at': '2012-09-14 11:51:11',
                'deleted_at': '',
                'instance_type': 'm1.nano',
                'state': 'active',
                'state_description': ''
            }
        }
        self.mox.StubOutWithMock(uuid, 'uuid4')
        uuid.uuid4().AndReturn('e53d007a-fc23-11e1-975c-cfa6b29bb814')
        self.mox.ReplayAll()
        changed_values = dict(id=det_id)
        expected_cuf_xml = utils.verified_nova_message_in_cuf_format(
            changed_values)

        notification = Notification(exists_message,
                                    event_type=self.event_type,
                                    region=self.region,
                                    data_center=self.data_center)
        verified_message = notification.\
            convert_to_verified_message_in_cuf_format()

        self.assertEquals(expected_cuf_xml['payload'],
                          verified_message['payload'])
Beispiel #4
0
    def test_convert_to_cuf_format_when_launched_at_before_audit_period(self):
        exists_message = {
            'event_type': 'test',
            'message_id': 'some_uuid',
            '_unique_id': 'e53d007a-fc23-11e1-975c-cfa6b29bb814',
            'payload': {
                'tenant_id': '2882',
                'access_ip_v4': '5.79.20.138',
                'access_ip_v6': '2a00:1a48:7804:0110:a8a0:fa07:ff08:157a',
                'audit_period_beginning': '2012-09-15 11:51:11',
                'audit_period_ending': '2012-09-16 11:51:11',
                'display_name': 'test',
                'bandwidth': {
                    'private': {
                        'bw_in': 0,
                        'bw_out': 264902
                    },
                    'public': {
                        'bw_in': 1001,
                        'bw_out': 19992
                    }
                },
                'image_meta': {
                    'com.rackspace__1__options': '1'
                },
                'instance_id': '56',
                'dummy_flavor_field_name': '10',
                'launched_at': '2012-09-14 11:51:11',
                'deleted_at': '',
                'instance_type': 'm1.nano',
                'state': 'active',
                'state_description': ''
            }
        }
        self.mox.StubOutWithMock(uuid, 'uuid4')
        uuid.uuid4().AndReturn('e53d007a-fc23-11e1-975c-cfa6b29bb814')
        self.mox.ReplayAll()
        values = utils.test_nova_xml_generator_values
        values.update({'end_time': '2012-09-16T11:51:11Z'})
        expected_cuf_xml = utils.verified_nova_message_in_cuf_format(values)

        notification = Notification(exists_message,
                                    event_type=self.event_type,
                                    region=self.region,
                                    data_center=self.data_center)
        verified_message = notification.\
            convert_to_verified_message_in_cuf_format()

        self.assertEquals(expected_cuf_xml['payload'],
                          verified_message['payload'])