[node-patches] Change in ovirt-node[master]: Allow nested transactions

rbarry at redhat.com rbarry at redhat.com
Wed Oct 2 18:51:14 UTC 2013


Ryan Barry has posted comments on this change.

Change subject: Allow nested transactions
......................................................................


Patch Set 2:

from ovirt.node.utils import Transaction
from ovirt.node.utils.console import TransactionProgress

class StepA(Transaction.Element):
    title = "Step A"
    def commit(self):
        print "Stepped A"
class StepB(Transaction.Element):
    title = "Step B"
    def commit(self):
        print "Stepped B"
class StepC(Transaction.Element):
    title = "Step C"
    def commit(self):
        print "Stepped C"
class StepD(Transaction.Element):
    title = "Step D"
    def commit(self):
        print "Stepped D"

tx = Transaction("Outer", [StepA(), StepB()])
txa = Transaction("SubTX", [StepC(), StepD()])
tx.append(txa)

TransactionProgress(tx, is_dry=False).run()

tx = Transaction("Outer", [StepA(), StepB()])
txa = Transaction("SubTX", [StepC(), StepD()])
tx += txa

TransactionProgress(tx, is_dry=False).run()
$ python test.py 
Outer
-----
Checking pre-conditions ...
(1/3) Step A
(2/3) Step B
(3/3) SubTX

All changes were applied successfully.
Outer
-----
Checking pre-conditions ...
(1/4) Step A
(2/4) Step B
(3/4) Step C
(4/4) Step D

All changes were applied successfully.

Since we can trivially implement both cases through use of extend() and append(), is there something else we need?

-- 
To view, visit http://gerrit.ovirt.org/19493
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia74e1dff22827f0b5fb47ba57eaa72c304998474
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at fedoraproject.org>
Gerrit-Reviewer: Ryan Barry <rbarry at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No



More information about the node-patches mailing list