def cleanup_bridges(): ovsdb = create() bridges = ovsdb.list_bridge_info().execute(timeout=5) with ovsdb.transaction() as t: t.timeout = 5 for bridge in bridges: if bridge in TEST_BRIDGES: t.add(ovsdb.del_br(bridge['name']))
def teardown(self): ovsdb = create() bridges = ovsdb.list_bridge_info().execute() with ovsdb.transaction() as t: for bridge in bridges: if bridge in TEST_BRIDGES: t.add(ovsdb.del_br(bridge['name'])) if not self.ovs_init_state_is_up: cmd.exec_sync([OVS_CTL, 'stop'])
def teardown(self): ovsdb = create() bridges = ovsdb.list_bridge_info().execute() with ovsdb.transaction() as t: for bridge in bridges: if bridge in TEST_BRIDGES: t.add(ovsdb.del_br(bridge['name'])) if not self.ovs_init_state_is_up: execCmd([OVS_CTL, 'stop'])
def _assert_acquired_ifaces_post_switch_setup(self, _ovs_info, nets2add, expected_ifaces): ovsdb = driver.create(driver.Drivers.VSCTL) with mock.patch('vdsm.network.ovs.driver.vsctl.Transaction.commit', return_value=None), \ mock.patch('vdsm.network.ovs.switch.link.get_link', return_value={'address': '01:23:45:67:89:ab'}): setup = switch.NetsAdditionSetup(ovsdb, _ovs_info) with setup.add(nets2add): pass self.assertEqual(setup.acquired_ifaces, expected_ifaces)
def test_execute_a_transaction(self): ovsdb = create() cmd_add_br = ovsdb.add_br(TEST_BRIDGE) cmd_list_bridge_info = ovsdb.list_bridge_info() t = ovsdb.transaction() t.add(cmd_add_br) t.add(cmd_list_bridge_info) t.commit() self.assertEqual(1, len(cmd_list_bridge_info.result)) bridge_name = cmd_list_bridge_info.result[0]['name'] self.assertIn(TEST_BRIDGE, bridge_name) cmd_del_br = ovsdb.del_br(TEST_BRIDGE) with ovsdb.transaction() as trans: trans.add(cmd_del_br) trans.add(cmd_list_bridge_info) self.assertEqual([], cmd_list_bridge_info.result)
def setUp(self): self.ovs_service = OvsService() self.ovs_service.setup() self.ovsdb = create()
def setUp(self): self.ovsdb = create()
def test_instantiate_vsctl_implementation(self): self.assertIsNotNone(create(OvsDrivers.VSCTL))
def setUp(self): self.ovs_service = OvsService() self.ovs_service.setup() self.ovsdb = create() self.ovsdb.add_br(TEST_BRIDGE).execute()
def test_execute_a_single_command(self): ovsdb = create() out = ovsdb.list_bridge_info().execute() # No bridges defined self.assertEqual([], out)
def setUp(self): self.ovsdb = create() self.ovsdb.add_br(TEST_BRIDGE).execute()
def test_instantiate_vsctl_implementation(self): self.assertIsNotNone(create('vsctl'))