Rev | Line | |
---|
[840] | 1 | #!/usr/bin/python -u |
---|
| 2 | # -*- coding: ISO-8859-1 -*- |
---|
| 3 | |
---|
| 4 | ################################## |
---|
| 5 | # @program smon |
---|
| 6 | # @description simulation monitor |
---|
| 7 | # @copyright Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. |
---|
| 8 | # All Rights Reservedâ |
---|
| 9 | # @svn_file $Id: failover 2545 2013-02-01 09:58:10Z jripsl $ |
---|
| 10 | # @version $Rev: 2545 $ |
---|
| 11 | # @lastrevision $Date: 2013-02-01 10:58:10 +0100 (Fri, 01 Feb 2013) $ |
---|
| 12 | # @license CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE) |
---|
| 13 | ################################## |
---|
| 14 | |
---|
| 15 | from smon import dao |
---|
| 16 | |
---|
[842] | 17 | CSTE_SIMULATION_STATUS_OK="2.2" |
---|
| 18 | |
---|
[840] | 19 | class Failover(): |
---|
[842] | 20 | running=true |
---|
[841] | 21 | |
---|
| 22 | @classmethod |
---|
| 23 | def controlLoop(cls): |
---|
| 24 | |
---|
[842] | 25 | while cls.running is True: |
---|
| 26 | |
---|
| 27 | simulation=dao.get_simulation() |
---|
| 28 | |
---|
| 29 | if simulation.status |
---|
| 30 | |
---|
| 31 | sleep 20 |
---|
| 32 | |
---|
[840] | 33 | def main(): |
---|
| 34 | |
---|
| 35 | # parse args |
---|
| 36 | parser = argparse.ArgumentParser(prog='failover') |
---|
| 37 | parser.add_argument('-v', dest='verbose',required=False,action='store_true') |
---|
| 38 | args = parser.parse_args() |
---|
| 39 | |
---|
| 40 | # check |
---|
| 41 | if not os.path.exists(SMON.smon_home): |
---|
| 42 | sys.exit(1) |
---|
| 43 | |
---|
[841] | 44 | SMON.init_singleton() |
---|
[840] | 45 | |
---|
[841] | 46 | Failover.controlLoop() |
---|
[840] | 47 | |
---|
[841] | 48 | SMON.free_singleton() |
---|
[840] | 49 | |
---|
| 50 | |
---|
| 51 | if __name__ == '__main__': |
---|
| 52 | try: |
---|
| 53 | main() |
---|
| 54 | |
---|
| 55 | sys.exit(0) |
---|
| 56 | |
---|
| 57 | except Exception, e: |
---|
| 58 | |
---|
| 59 | #traceback.print_exc() |
---|
| 60 | |
---|
| 61 | sys.exit(1) |
---|
Note: See
TracBrowser
for help on using the repository browser.