def test_get_all_table_assignments(self): self.service_manager.allocate_scratch_tables( EnforcementController.APP_NAME, 1) self.service_manager.allocate_scratch_tables( EnforcementStatsController.APP_NAME, 2) result = self.service_manager.get_all_table_assignments() expected = OrderedDict([ ('ingress', Tables(main_table=1, scratch_tables=[])), ('arpd', Tables(main_table=2, scratch_tables=[])), ('access_control', Tables(main_table=3, scratch_tables=[])), ('enforcement', Tables(main_table=4, scratch_tables=[21])), ('enforcement_stats', Tables(main_table=4, scratch_tables=[22, 23])), ('dpi', Tables(main_table=5, scratch_tables=[])), ('meter', Tables(main_table=6, scratch_tables=[])), ('meter_stats', Tables(main_table=6, scratch_tables=[])), ('subscriber', Tables(main_table=6, scratch_tables=[])), ('egress', Tables(main_table=20, scratch_tables=[])), ]) self.assertEqual(len(result), len(expected)) for result_key, expected_key in zip(result, expected): self.assertEqual(result_key, expected_key) self.assertEqual(result[result_key].main_table, expected[expected_key].main_table) self.assertEqual(result[result_key].scratch_tables, expected[expected_key].scratch_tables)
def test_get_all_table_assignments(self): self.service_manager.allocate_scratch_tables( EnforcementController.APP_NAME, 1) self.service_manager.allocate_scratch_tables( EnforcementStatsController.APP_NAME, 2) result = self.service_manager.get_all_table_assignments() print(result) expected = OrderedDict([ ('mme', Tables(main_table=0, scratch_tables=[], type=ControllerType.SPECIAL)), ('ingress', Tables(main_table=1, scratch_tables=[], type=ControllerType.SPECIAL)), ('arpd', Tables(main_table=2, scratch_tables=[], type=ControllerType.PHYSICAL)), ('access_control', Tables(main_table=3, scratch_tables=[], type=ControllerType.PHYSICAL)), ('middle', Tables(main_table=10, scratch_tables=[], type=None)), ('enforcement', Tables(main_table=11, scratch_tables=[21], type=ControllerType.LOGICAL)), ('enforcement_stats', Tables(main_table=12, scratch_tables=[22, 23], type=ControllerType.LOGICAL)), ('dpi', Tables(main_table=13, scratch_tables=[], type=ControllerType.LOGICAL)), ('ipfix', Tables(main_table=14, scratch_tables=[], type=ControllerType.LOGICAL)), ('egress', Tables(main_table=20, scratch_tables=[], type=ControllerType.SPECIAL)), ]) self.assertEqual(len(result), len(expected)) for result_key, expected_key in zip(result, expected): self.assertEqual(result_key, expected_key) self.assertEqual(result[result_key].main_table, expected[expected_key].main_table) self.assertEqual(result[result_key].scratch_tables, expected[expected_key].scratch_tables)
def _display_flows(client, apps=None): pipelined_config = load_service_config('pipelined') bridge_name = pipelined_config['bridge_name'] response = client.GetAllTableAssignments(Void()) table_assignments = { table_assignment.app_name: Tables( main_table=table_assignment.main_table, type=None, scratch_tables=table_assignment.scratch_tables, ) for table_assignment in response.table_assignments } try: flows = BridgeTools.get_annotated_flows_for_bridge( bridge_name, table_assignments, apps, ) except subprocess.CalledProcessError as e: if e.returncode == errno.EPERM: print("Need to run as root to dump flows") return for flow in flows: print(flow)