Merge "Extend transaction with multiple commands"
This commit is contained in:
commit
bbb3ce9f02
@ -44,7 +44,17 @@ class Transaction(object):
|
||||
|
||||
@abc.abstractmethod
|
||||
def add(self, command):
|
||||
"""Append an OVSDB operation to the transaction"""
|
||||
"""Append an OVSDB operation to the transaction
|
||||
|
||||
Operation is returned back as a convenience.
|
||||
"""
|
||||
|
||||
def extend(self, commands):
|
||||
"""Add multiple OVSDB operations to the transaction
|
||||
|
||||
List of operations is returned back as a convenience.
|
||||
"""
|
||||
return [self.add(command) for command in commands]
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
@ -75,8 +75,8 @@ class TestOvsdbIdl(base.FunctionalTestCase):
|
||||
def _test_add_port(self):
|
||||
pname = utils.get_rand_device_name()
|
||||
with self.api.transaction(check_error=True) as txn:
|
||||
txn.add(self.api.add_br(self.brname))
|
||||
txn.add(self.api.add_port(self.brname, pname))
|
||||
txn.extend([self.api.add_br(self.brname),
|
||||
self.api.add_port(self.brname, pname)])
|
||||
return pname
|
||||
|
||||
def test_add_port(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user