Exemplo n.º 1
0
 def test_interface_create_and_delete(self):
     for action in ('create', 'delete'):
         msg = {
             u'_context_roles': [u'_member_', u'admin'],
             u'priority': u'INFO',
             u'_context_read_deleted': u'no',
             u'event_type': u'router.interface.%s' % action,
             u'timestamp': u'2014-04-08 17:48:42.917596',
             u'_context_tenant_id': u'4838397648d946279ad422886aabcf07',
             u'payload': {
                 u'router.interface': {
                     u'subnet_id': u'0535072e-6ef4-4916-b1f5-05fab4da3d0c',
                     u'tenant_id': u'c2a1399efbed41e5be2115afa5b5ec25',
                     u'port_id': u'63363e5f-59b7-49ca-b619-96c16883b543',
                     u'id': u'58868681-4a58-4f69-8dc0-b20955e7923f'
                 }
             },
             u'_unique_id': u'bf7cbac3c964442b841f8a0dfda1b84f',
             u'_context_is_admin': True,
             u'_context_project_id': u'4838397648d946279ad422886aabcf07',
             u'_context_timestamp': u'2014-04-08 17:48:42.838558',
             u'_context_user_id': u'22a73cb6a5bf493da6a1b0b602b61ed6',
             u'publisher_id': u'network.akanda',
             u'message_id': u'c441df90-404a-4b53-a4d6-67f042339ef2'
         }
         e = notifications._make_event_from_message(msg)
         self.assertEqual(event.UPDATE, e.crud)
         self.assertEqual(u'58868681-4a58-4f69-8dc0-b20955e7923f',
                          e.router_id)
Exemplo n.º 2
0
 def test_ignore_user(self):
     msg = {u'oslo.message': u'{"_context_roles": ["anotherrole", "Member", "admin"], "_context_read_deleted": "no", "args": {"router_id": "f37f31e9-adc2-4712-a002-4ccf0be17a99"}, "_unique_id": "c87303336c7c4bb0b097b3e97bebf7ea", "_context_timestamp": "2013-07-25 13:51:50.791338", "_context_is_admin": false, "version": "1.0", "_context_project_id": "c25992581e574b6485dbfdf39a3df46c", "_context_tenant_id": "c25992581e574b6485dbfdf39a3df46c", "_context_user_id": "472511eedebd4322a26c5fb1f52711ee", "method": "router_deleted"}', u'oslo.version': u'2.0'}  # noqa
     e = notifications._make_event_from_message(
         msg,
         "472511eedebd4322a26c5fb1f52711ee",
     )
     self.assertIsNone(e)
Exemplo n.º 3
0
    def test_notification_router_id(self):
        msg = {
            u'_context_is_admin': False,
            u'_context_project_id': u'c25992581e574b6485dbfdf39a3df46c',
            u'_context_read_deleted': u'no',
            u'_context_roles': [u'anotherrole', u'Member'],
            u'_context_tenant_id': u'c25992581e574b6485dbfdf39a3df46c',
            u'_context_timestamp': u'2013-08-01 20:17:11.569282',
            u'_context_user_id': u'472511eedebd4322a26c5fb1f52711ee',
            u'_unique_id': u'246f69b5dff44156ba56c4a2b7c3d47f',
            u'event_type': u'router.create.end',
            u'message_id': u'658c8901-6858-4dbc-be8a-242d94fc4b5d',
            u'payload': {
                u'router': {
                    u'admin_state_up': True,
                    u'external_gateway_info': None,
                    u'id': u'f95fb32d-0072-4675-b4bd-61d829a46aca',
                    u'name': u'r2',
                    u'ports': [],
                    u'status': u'ACTIVE',
                    u'tenant_id': u'c25992581e574b6485dbfdf39a3df46c',
                },
            },
            u'priority': u'INFO',
            u'publisher_id': u'network.akanda',
            u'timestamp': u'2013-08-01 20:17:11.662425',
        }

        e = notifications._make_event_from_message(msg)
        self.assertEqual(e.router_id, u'f95fb32d-0072-4675-b4bd-61d829a46aca')
Exemplo n.º 4
0
 def test_interface_create_and_delete(self):
     for action in ('create', 'delete'):
         msg = {
             u'_context_roles': [u'_member_', u'admin'],
             u'priority': u'INFO',
             u'_context_read_deleted': u'no',
             u'event_type': u'router.interface.%s' % action,
             u'timestamp': u'2014-04-08 17:48:42.917596',
             u'_context_tenant_id': u'4838397648d946279ad422886aabcf07',
             u'payload': {
                 u'router.interface': {
                     u'subnet_id': u'0535072e-6ef4-4916-b1f5-05fab4da3d0c',
                     u'tenant_id': u'c2a1399efbed41e5be2115afa5b5ec25',
                     u'port_id': u'63363e5f-59b7-49ca-b619-96c16883b543',
                     u'id': u'58868681-4a58-4f69-8dc0-b20955e7923f'
                 }
             },
             u'_unique_id': u'bf7cbac3c964442b841f8a0dfda1b84f',
             u'_context_is_admin': True,
             u'_context_project_id': u'4838397648d946279ad422886aabcf07',
             u'_context_timestamp': u'2014-04-08 17:48:42.838558',
             u'_context_user_id': u'22a73cb6a5bf493da6a1b0b602b61ed6',
             u'publisher_id': u'network.akanda',
             u'message_id': u'c441df90-404a-4b53-a4d6-67f042339ef2'
         }
         e = notifications._make_event_from_message(msg)
         self.assertEqual(event.UPDATE, e.crud)
         self.assertEqual(
             u'58868681-4a58-4f69-8dc0-b20955e7923f',
             e.router_id
         )
Exemplo n.º 5
0
    def test_notification_router_id(self):
        msg = {
            u'_context_is_admin': False,
            u'_context_project_id': u'c25992581e574b6485dbfdf39a3df46c',
            u'_context_read_deleted': u'no',
            u'_context_roles': [u'anotherrole', u'Member'],
            u'_context_tenant_id': u'c25992581e574b6485dbfdf39a3df46c',
            u'_context_timestamp': u'2013-08-01 20:17:11.569282',
            u'_context_user_id': u'472511eedebd4322a26c5fb1f52711ee',
            u'_unique_id': u'246f69b5dff44156ba56c4a2b7c3d47f',
            u'event_type': u'router.create.end',
            u'message_id': u'658c8901-6858-4dbc-be8a-242d94fc4b5d',
            u'payload': {
                u'router': {
                    u'admin_state_up': True,
                    u'external_gateway_info': None,
                    u'id': u'f95fb32d-0072-4675-b4bd-61d829a46aca',
                    u'name': u'r2',
                    u'ports': [],
                    u'status': u'ACTIVE',
                    u'tenant_id': u'c25992581e574b6485dbfdf39a3df46c',
                },
            },
            u'priority': u'INFO',
            u'publisher_id': u'network.akanda',
            u'timestamp': u'2013-08-01 20:17:11.662425',
        }

        e = notifications._make_event_from_message(msg)
        self.assertEqual(e.router_id, u'f95fb32d-0072-4675-b4bd-61d829a46aca')
Exemplo n.º 6
0
 def _test_notification(self, event_type):
     msg = {
         u'_context_is_admin': False,
         u'_context_project_id': u'c25992581e574b6485dbfdf39a3df46c',
         u'_context_read_deleted': u'no',
         u'_context_roles': [u'anotherrole', u'Member'],
         u'_context_timestamp': u'2013-07-25 14:02:55.073049',
         u'_context_user_id': u'472511eedebd4322a26c5fb1f52711ee',
         u'_unique_id': u'8825f8a6ccec4285a7ecfdad7bd53815',
         u'event_type': event_type,
         u'message_id': u'bb9bcf1d-1547-4867-b41e-f5298fa10869',
         u'payload': {
             u'port': {
                 u'admin_state_up': True,
                 u'device_id': u'',
                 u'device_owner': u'',
                 u'fixed_ips': [{
                     u'ip_address': u'192.168.123.3',
                     u'subnet_id': u'53d8a76a-3e1a-43e0-975e-83a4b464d18c'}],  # noqa
                 u'id': u'bbd92f5a-5a1d-4ec5-9272-8e4dd5f0c084',
                 u'mac_address': u'fa:16:3e:f4:81:a9',
                 u'name': u'',
                 u'network_id': u'c3a30111-dd52-405c-84b2-4d62068e2d35',
                 u'security_groups': [u'5124be1c-b2d5-47e6-ac62-411a0ea028c8'],  # noqa
                 u'status': u'DOWN',
                 u'tenant_id': u'c25992581e574b6485dbfdf39a3df46c',
             },
         },
         u'priority': u'INFO',
         u'publisher_id': u'network.akanda',
         u'timestamp': u'2013-07-25 14:02:55.244126'}
     return notifications._make_event_from_message(msg)
Exemplo n.º 7
0
 def test_rpc_router_deleted(self):
     msg = {
         u'oslo.message':
         u'{"_context_roles": ["anotherrole", "Member", "admin"], "_context_read_deleted": "no", "args": {"router_id": "f37f31e9-adc2-4712-a002-4ccf0be17a99"}, "_unique_id": "c87303336c7c4bb0b097b3e97bebf7ea", "_context_timestamp": "2013-07-25 13:51:50.791338", "_context_is_admin": false, "version": "1.0", "_context_project_id": "c25992581e574b6485dbfdf39a3df46c", "_context_tenant_id": "c25992581e574b6485dbfdf39a3df46c", "_context_user_id": "472511eedebd4322a26c5fb1f52711ee", "method": "router_deleted"}',
         u'oslo.version': u'2.0'
     }  # noqa
     e = notifications._make_event_from_message(msg)
     self.assertEqual(event.DELETE, e.crud)
     self.assert_(e.router_id)
Exemplo n.º 8
0
 def _test_notification(self, event_type):
     msg = {
         u'_context_is_admin': False,
         u'_context_project_id': u'c25992581e574b6485dbfdf39a3df46c',
         u'_context_read_deleted': u'no',
         u'_context_roles': [u'anotherrole', u'Member'],
         u'_context_timestamp': u'2013-07-25 14:02:55.073049',
         u'_context_user_id': u'472511eedebd4322a26c5fb1f52711ee',
         u'_unique_id': u'8825f8a6ccec4285a7ecfdad7bd53815',
         u'event_type': event_type,
         u'message_id': u'bb9bcf1d-1547-4867-b41e-f5298fa10869',
         u'payload': {
             u'port': {
                 u'admin_state_up':
                 True,
                 u'device_id':
                 u'',
                 u'device_owner':
                 u'',
                 u'fixed_ips': [{
                     u'ip_address':
                     u'192.168.123.3',
                     u'subnet_id':
                     u'53d8a76a-3e1a-43e0-975e-83a4b464d18c'
                 }],  # noqa
                 u'id':
                 u'bbd92f5a-5a1d-4ec5-9272-8e4dd5f0c084',
                 u'mac_address':
                 u'fa:16:3e:f4:81:a9',
                 u'name':
                 u'',
                 u'network_id':
                 u'c3a30111-dd52-405c-84b2-4d62068e2d35',
                 u'security_groups':
                 [u'5124be1c-b2d5-47e6-ac62-411a0ea028c8'],  # noqa
                 u'status':
                 u'DOWN',
                 u'tenant_id':
                 u'c25992581e574b6485dbfdf39a3df46c',
             },
         },
         u'priority': u'INFO',
         u'publisher_id': u'network.akanda',
         u'timestamp': u'2013-07-25 14:02:55.244126'
     }
     return notifications._make_event_from_message(msg)