def apply(self): """ Apply all changes to this table. Note that the only way to abort changes is to call TableState.reset(); otherwise the changes remain queued up and happen the next time TableState.apply() is called. """ ops = [] for table in self.tables_v4.values() + self.tables_v6.values(): ops.extend(table.ops) table.ops = [] if ops: log.debug("Apply batched changes to tables") futils.multi_call(ops) else: log.debug("No table changes required")
def test_multi_call(self): # Test multiple command calls; this just stores the command values. ops = [ ["ls"], ["ls", "calico"] ] expected = "set -e\n" for op in ops: cmd = " ".join(op) + "\n" expected += "echo Executing : " + cmd + cmd with mock.patch('calico.felix.futils.check_call', side_effect=self.stub_store_calls): result = futils.multi_call(ops) self.assertEqual(expected, self.data)