|
Revision 27, 1.2 KB
(checked in by daedalus, 4 years ago)
|
|
* Added 'authoritarian' mode, which allows you permit/deny each and every command
that will be issued to a remote device. Designed for testing new change scripts.
* Added a 'command_timeout' parameter to Command Provisioners, so you can override
the default command timeout of 300 seconds by setting an attribute in the config
file
* Added proper handling of the 'onfail: continue' idea. You can now specify that
if a change fails, and it is a pre-requisite for some other change, processing
will continue despite the failure.
* Added the onfail: retry feature. If a change fails, you can specify that it should
be retried. You can also set a max number of retries. The default is 3.
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/usr/bin/python |
|---|
| 2 | # |
|---|
| 3 | # Apply changes defined in a configuration file |
|---|
| 4 | |
|---|
| 5 | import sys |
|---|
| 6 | import traceback |
|---|
| 7 | |
|---|
| 8 | from options import ChangeOptions |
|---|
| 9 | from confloader import ConfigLoader, ChangeController |
|---|
| 10 | from twisted.internet import reactor |
|---|
| 11 | |
|---|
| 12 | import logging |
|---|
| 13 | log = logging.getLogger('modipy') |
|---|
| 14 | |
|---|
| 15 | optparser = ChangeOptions() |
|---|
| 16 | optparser.parseOptions() |
|---|
| 17 | |
|---|
| 18 | try: |
|---|
| 19 | cfgldr = ConfigLoader(optparser.options, optparser.args) |
|---|
| 20 | except Exception, e: |
|---|
| 21 | log.error("Cannot load configuration: %s", e) |
|---|
| 22 | traceback.print_exc(e) |
|---|
| 23 | |
|---|
| 24 | sys.exit(1) |
|---|
| 25 | pass |
|---|
| 26 | |
|---|
| 27 | log.debug("changes to apply: %s", cfgldr.changes) |
|---|
| 28 | log.debug("total devices: %s", cfgldr.devices) |
|---|
| 29 | |
|---|
| 30 | controller = ChangeController(cfgldr) |
|---|
| 31 | |
|---|
| 32 | def mystop(ignored): |
|---|
| 33 | log.debug("finished!") |
|---|
| 34 | reactor.stop() |
|---|
| 35 | pass |
|---|
| 36 | |
|---|
| 37 | def errstop(failure): |
|---|
| 38 | log.error("Changes not implemented ok!") |
|---|
| 39 | tlog.err(failure) |
|---|
| 40 | reactor.stop() |
|---|
| 41 | |
|---|
| 42 | def go(): |
|---|
| 43 | d = controller.do_changes() |
|---|
| 44 | d.addCallbacks(mystop, errstop) |
|---|
| 45 | |
|---|
| 46 | # Use callLater(0) syntax to trigger running of changes once |
|---|
| 47 | # the reactor has actually started, so it can be stopped cleanly. |
|---|
| 48 | |
|---|
| 49 | if getattr(optparser.options, 'loadonly', False): |
|---|
| 50 | log.info("Load only specified") |
|---|
| 51 | reactor.callLater(0, mystop, None) |
|---|
| 52 | else: |
|---|
| 53 | reactor.callLater(0, go) |
|---|
| 54 | pass |
|---|
| 55 | |
|---|
| 56 | reactor.run() |
|---|
| 57 | |
|---|
| 58 | |
|---|