Changeset 875


Ignore:
Timestamp:
06/11/13 15:05:18 (11 years ago)
Author:
jripsl
Message:

Repository I/O implementation (suite).

Location:
trunk/Monitoring
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Monitoring/Watch/repo-state

    r871 r875  
    11#!/usr/bin/env python 
    2  
    3 # --- ncurses sample 1 
    4  
    5 #import curses 
    6 #from curses import panel 
    7 # 
    8 #class Menu(object): 
    9 # 
    10 #       def __init__(self, items, stdscreen): 
    11 #               self.window = stdscreen.subwin(0,0) 
    12 #               self.window.keypad(1) 
    13 #               self.panel = panel.new_panel(self.window) 
    14 #               self.panel.hide() 
    15 #               panel.update_panels() 
    16 # 
    17 #               self.position = 0 
    18 #               self.items = items 
    19 #               self.items.append(('exit','exit')) 
    20 # 
    21 #       def navigate(self, n): 
    22 #               self.position += n 
    23 #               if self.position < 0: 
    24 #                       self.position = 0 
    25 #               elif self.position >= len(self.items): 
    26 #                       self.position = len(self.items)-1 
    27 # 
    28 #       def display(self): 
    29 #               self.panel.top() 
    30 #               self.panel.show() 
    31 #               self.window.clear() 
    32 # 
    33 # 
    34 #               while True: 
    35 #                       self.window.refresh() 
    36 #                       curses.doupdate() 
    37 #                       for index, item in enumerate(self.items): 
    38 #                               if index == self.position: 
    39 #                                       mode = curses.A_REVERSE 
    40 #                               else: 
    41 #                                       mode = curses.A_NORMAL 
    42 # 
    43 #                               msg = '%d. %s' % (index, item[0]) 
    44 #                               self.window.addstr(1+index, 1, msg, mode) 
    45 # 
    46 #                       key = self.window.getch() 
    47 # 
    48 #                       if key in [curses.KEY_ENTER, ord('\n')]: 
    49 #                               if self.position == len(self.items)-1: 
    50 #                                       break 
    51 #                               else: 
    52 #                                       self.items[self.position][1]() 
    53 # 
    54 #                       elif key == curses.KEY_UP: 
    55 #                               self.navigate(-1) 
    56 # 
    57 #                       elif key == curses.KEY_DOWN: 
    58 #                               self.navigate(1) 
    59 # 
    60 #               self.window.clear() 
    61 #               self.panel.hide() 
    62 #               panel.update_panels() 
    63 #               curses.doupdate() 
    64 # 
    65 # 
    66 #class MyApp(object): 
    67 # 
    68 #       def __init__(self, stdscreen): 
    69 #               self.screen = stdscreen 
    70 #               curses.curs_set(0) 
    71 # 
    72 #               submenu_items = [ 
    73 #                               ('beep', curses.beep), 
    74 #                               ('flash', curses.flash) 
    75 #                               ] 
    76 #               submenu = Menu(submenu_items, self.screen) 
    77 # 
    78 #               main_menu_items = [ 
    79 #                               ('beep', curses.beep), 
    80 #                               ('flash', curses.flash), 
    81 #                               ('submenu', submenu.display) 
    82 #                               ] 
    83 #               main_menu = Menu(main_menu_items, self.screen) 
    84 #               main_menu.display() 
    85  
    86 #if __name__ == '__main__': 
    87 #       curses.wrapper(MyApp) 
    88  
    89  
    90  
    91  
    92  
    93 # --- ncurses sample 2 
    94  
    95 # Author: Nikolai Tschacher 
    96 # Date: 02.06.2013 
    97 # 
    98 #class BoxSelector: 
    99 #    """ Originally designed for accman.py. 
    100 #        Display options build from a list of strings in a (unix) terminal. 
    101 #        The user can browser though the textboxes and select one with enter. 
    102 #    """ 
    103 #     
    104 #    def __init__(self, L): 
    105 #        """ Create a BoxSelector object.  
    106 #            L is a list of strings. Each string is used to build  
    107 #            a textbox. 
    108 #        """ 
    109 #        self.L = L 
    110 #        # Element parameters. Change them here. 
    111 #        self.TEXTBOX_WIDTH = 50 
    112 #        self.TEXTBOX_HEIGHT = 6 
    113 # 
    114 #        self.PAD_WIDTH = 400 
    115 #        self.PAD_HEIGHT = 10000 
    116 #         
    117 #    def pick(self): 
    118 #        """ Just run this when you want to spawn the selction process. """ 
    119 #        self._init_curses() 
    120 #        self._create_pad() 
    121 #         
    122 #        windows = self._make_textboxes() 
    123 #        picked = self._select_textbox(windows) 
    124 #         
    125 #        self._end_curses() 
    126 #         
    127 #        return picked 
    128 #         
    129 #    def _init_curses(self): 
    130 #        """ Inits the curses appliation """ 
    131 #        # initscr() returns a window object representing the entire screen. 
    132 #        self.stdscr = curses.initscr() 
    133 #        # turn off automatic echoing of keys to the screen 
    134 #        curses.noecho() 
    135 #        # Enable non-blocking mode. Keys are read directly, without hitting enter. 
    136 #        curses.cbreak() 
    137 #        # Disable the mouse cursor. 
    138 #        curses.curs_set(0) 
    139 #        self.stdscr.keypad(1) 
    140 #        # Enable colorous output. 
    141 #        curses.start_color() 
    142 #        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN) 
    143 #        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) 
    144 #        self.stdscr.bkgd(curses.color_pair(2)) 
    145 #        self.stdscr.refresh() 
    146 # 
    147 #    def _end_curses(self): 
    148 #        """ Terminates the curses application. """ 
    149 #        curses.nocbreak() 
    150 #        self.stdscr.keypad(0) 
    151 #        curses.echo() 
    152 #        curses.endwin() 
    153 #         
    154 #    def _create_pad(self): 
    155 #        """ Creates a big self.pad to place the textboxes in. """ 
    156 #        self.pad = curses.newpad(self.PAD_HEIGHT, self.PAD_WIDTH) 
    157 #        self.pad.box() 
    158 #         
    159 #    def _make_textboxes(self): 
    160 #        """ Build the textboxes in the pad center and put them in the  
    161 #            horizontal middle of the pad. """ 
    162 #        # Get the actual screensize. 
    163 #        maxy, maxx = self.stdscr.getmaxyx() 
    164 #         
    165 #        windows = [] 
    166 #        i = 1 
    167 #        for s in self.L: 
    168 #            windows.append(self.pad.derwin(self.TEXTBOX_HEIGHT, 
    169 #                    self.TEXTBOX_WIDTH, i, self.PAD_WIDTH//2-self.TEXTBOX_WIDTH//2)) 
    170 #            i += self.TEXTBOX_HEIGHT 
    171 #             
    172 #        for k in range(len(windows)): 
    173 #            windows[k].box() 
    174 #            windows[k].addstr(4, 4, '0x{0:X} - {1}'.format(k, self.L[k])) 
    175 #             
    176 #        return windows 
    177 # 
    178 #    def _center_view(self, window): 
    179 #        """ Centers and aligns the view according to the window argument given.  
    180 #            Returns the (y, x) coordinates of the centered window. """ 
    181 #        # The refresh() and noutrefresh() methods of a self.pad require 6 arguments 
    182 #        # to specify the part of the self.pad to be displayed and the location on 
    183 #        # the screen to be used for the display. The arguments are pminrow, 
    184 #        # pmincol, sminrow, smincol, smaxrow, smaxcol; the p arguments refer 
    185 #        # to the upper left corner of the self.pad region to be displayed and the 
    186 #        # s arguments define a clipping box on the screen within which the 
    187 #        # self.pad region is to be displayed. 
    188 #        cy, cx = window.getbegyx() 
    189 #        maxy, maxx = self.stdscr.getmaxyx() 
    190 #        self.pad.refresh(cy, cx, 1, maxx//2 - self.TEXTBOX_WIDTH//2, maxy-1, maxx-1) 
    191 #        return (cy, cx) 
    192 #         
    193 #    def _select_textbox(self, windows): 
    194 #        # See at the root textbox. 
    195 #        topy, topx = self._center_view(windows[0]) 
    196 #         
    197 #        current_selected = 0 
    198 #        last = 1 
    199 #        top_textbox = windows[0] 
    200 #         
    201 #        while True: 
    202 #            # Highligth the selected one, the last selected textbox should 
    203 #            # become normal again. 
    204 #            windows[current_selected].bkgd(curses.color_pair(1)) 
    205 #            windows[last].bkgd(curses.color_pair(2)) 
    206 #             
    207 #            # While the textbox can be displayed on the page with the current  
    208 #            # top_textbox, don't alter the view. When this becomes impossible,  
    209 #            # center the view to last displayable textbox on the previous view. 
    210 #            maxy, maxx = self.stdscr.getmaxyx() 
    211 #            cy, cx = windows[current_selected].getbegyx() 
    212 #             
    213 #            # The current window is to far down. Switch the top textbox. 
    214 #            if ((topy + maxy - self.TEXTBOX_HEIGHT) <= cy): 
    215 #                top_textbox = windows[current_selected] 
    216 #             
    217 #            # The current window is to far up. There is a better way though... 
    218 #            if topy >= cy + self.TEXTBOX_HEIGHT: 
    219 #                top_textbox = windows[current_selected] 
    220 #             
    221 #            if last != current_selected: 
    222 #                last = current_selected 
    223 #                 
    224 #            topy, topx = self._center_view(top_textbox) 
    225 #             
    226 #            c = self.stdscr.getch() 
    227 #             
    228 #            # Vim like KEY_UP/KEY_DOWN with j(DOWN) and k(UP). 
    229 #            if c == ord('j'): 
    230 #                if current_selected >= len(windows)-1: 
    231 #                    current_selected = 0 # wrap around. 
    232 #                else: 
    233 #                    current_selected += 1 
    234 #            elif c == ord('k'): 
    235 #                if current_selected <= 0: 
    236 #                    current_selected = len(windows)-1 # wrap around. 
    237 #                else: 
    238 #                    current_selected -= 1 
    239 #            elif c == ord('q'): # Quit without selecting. 
    240 #                break 
    241 #            # At hitting enter, return the index of the selected list element. 
    242 #            elif c == curses.KEY_ENTER or c == 10: 
    243 #                return int(current_selected) 
    244 # 
    245 # 
    246 #if __name__ == '__main__': 
    247 #    # As simple as that. 
    248 #    L = [ 
    249 #         'I wish I was a wizard', 
    250 #         'Sometimes it all just makes sense', 
    251 #         'This string is here because I need it', 
    252 #         'Being or not being!', 
    253 #         'Python is worse then PHP ;)', 
    254 #         'a -> b <=> if a then b' 
    255 #        ] 
    256 #         
    257 #    choice = BoxSelector(L).pick() 
    258 #    print('[+] Your choice was "{0}"'.format(L[choice])) 
    259  
    260  
    261  
    262  
    263  
    264  
    265  
    266 # --- ncurses sample 3 
    267  
    268  
    2692 
    2703import sys 
     
    27912 
    28013 
     14# init 
     15 
     16# set pad height/width 
     17padhlines = 4 
     18padwcols = 30 
     19 
     20# add margin 
     21padhlines += 2 
     22padwcols += 2 
     23 
     24 
     25 
     26 
    28127repo_io.init() # open DB connection 
    28228 
     
    28531simulations=repo_io.retrieve_simulations() 
    28632 
    287 mylines = ["Line {0} ".format(id)*3 for id in range(1,11)] 
    28833 
    28934 
     35def display_simulation_list(mydata): 
     36 
     37        hlines = begin_y = begin_x = 5 
     38 
     39        # stuff 
     40        mypad.scrollok(1) 
     41        mypad.idlok(1) 
     42 
     43        mypad.border(0) # clear border 
     44   
     45        y=padhlines-1 
     46 
     47        # write strings 
     48        for line in mydata: 
     49                mypad.addstr(y,1, line) 
     50                mypad.scroll(1) 
     51   
     52 
     53        mypad.border(0) # clear border 
     54 
     55 
     56 
     57        # refresh the pads 
     58        mypad.refresh(0,0, begin_y,begin_x, begin_y+hlines, begin_x+padwcols) 
     59 
     60         
     61        mypad.touchwin()  # pretend the all stuff has been changed 
     62 
     63 
     64# better way 
     65 
    29066def main(stdscr): 
    291   hlines = begin_y = begin_x = 5 ; wcols = 10 
    292   # calculate total content size 
    293   padhlines = len(mylines) 
    294   padwcols = 0 
    295   for line in mylines: 
    296     if len(line) > padwcols: padwcols = len(line) 
    297   padhlines += 2 ; padwcols += 2 # allow border 
    298   #stdscr.addstr("padhlines "+str(padhlines)+" padwcols "+str(padwcols)+"; ") 
    299   # both newpad and subpad are <class '_curses.curses window'>: 
    300   mypadn = curses.newpad(padhlines, padwcols) 
    301   mypads = stdscr.subpad(padhlines, padwcols, begin_y, begin_x+padwcols+4) 
    302   #stdscr.addstr(str(type(mypadn))+" "+str(type(mypads)) + "\n") 
    303   mypadn.scrollok(1) 
    304   mypadn.idlok(1) 
    305   mypads.scrollok(1) 
    306   mypads.idlok(1) 
    30767 
    308   mypadn.border(0) # first ... 
    309   mypads.border(0) # ... border 
     68        """ 
     69        window test 
    31070 
    311   for line in mylines: 
    312     mypadn.addstr(padhlines-1,1, line) 
    313     mypadn.scroll(1) 
    314     mypads.addstr(padhlines-1,1, line) 
    315     mypads.scroll(1) 
     71        begin_x = 20 ; begin_y = 7 
     72        height = 5 ; width = 40 
     73        win = curses.newwin(height, width, begin_y, begin_x) 
     74        """ 
    31675 
    317   mypadn.border(0) # second ... 
    318   mypads.border(0) # ... border 
     76        # create pad 
     77        global mypad 
     78        mypad=curses.newpad(padhlines, padwcols) 
    31979 
    320   # refresh parent first, to render the texts on top 
    321   #~ stdscr.refresh() 
    322  
    323   # refresh the pads next 
    324   mypadn.refresh(0,0, begin_y,begin_x, begin_y+hlines, begin_x+padwcols) 
    325   mypads.refresh() 
    326   mypads.touchwin() 
    327   mypadn.touchwin() 
    328   stdscr.touchwin() # no real effect here 
    329   #stdscr.refresh() # not here! overwrites newpad! 
    330   mypadn.getch() 
    331   # even THIS command erases newpad! 
    332   # (unless stdscr.refresh() previously): 
    333   stdscr.getch() 
    334  
    335 curses.wrapper(main) 
     80        # what to display 
     81        data = [s.name+" "+s.status for s in simulations] 
     82   
     83   
     84        display_simulation_list(data) 
    33685 
    33786 
    33887 
    33988 
    340 repo_io.free() # close DB connection 
     89 
     90 
     91        while True: 
     92                c = mypad.getch() # even THIS command erases newpad! 
     93                #stdscr.getch() 
     94 
     95                if c in (curses.KEY_ENTER,): 
     96                        # => doesn't work... 
     97 
     98                        break 
     99                elif c in (ord('q'),ord('Q')): 
     100                        # => works... 
     101 
     102                        break 
     103 
     104                elif c in (ord('r'),ord('R')): 
     105 
     106                        # debug 
     107                        #stdscr.addstr() 
     108 
     109                        mypad.erase() 
     110 
     111                        display_simulation_list(data) 
     112 
     113                        # pretend the all stuff has been changed 
     114                        # no real effect here 
     115                        #stdscr.touchwin() 
     116 
     117                        stdscr.refresh() # refresh parent first, to render the texts on top 
     118 
     119                         
    341120 
    342121 
     
    348127 
    349128 
    350 # --- urwid sample 1 
    351129 
    352 #import urwid 
    353 # 
    354 #txt = urwid.Text(u"Hello World") 
    355 #fill = urwid.Filler(txt, 'top') 
    356 #loop = urwid.MainLoop(fill) 
    357 #loop.run() 
     130curses.wrapper(main) 
    358131 
    359  
    360 # --- urwid sample 2 
    361  
    362 #import urwid 
    363 # 
    364 #def show_or_exit(key): 
    365 #    if key in ('q', 'Q'): 
    366 #        raise urwid.ExitMainLoop() 
    367 #    txt.set_text(repr(key)) 
    368 # 
    369 #txt = urwid.Text(u"Hello World") 
    370 #fill = urwid.Filler(txt, 'top') 
    371 #loop = urwid.MainLoop(fill, unhandled_input=show_or_exit) 
    372 #loop.run() 
    373  
     132repo_io.free() # close DB connection 
  • trunk/Monitoring/Watch/watch

    r871 r875  
    2929import smon.types 
    3030 
     31 
    3132class Mail(): 
    3233 
     
    5960 
    6061        @classmethod 
     62        def cleanup(cls,message): 
     63                repo_io.cleanup() # truncate/delete everything 
     64 
     65        @classmethod 
    6166        def set_sim_status_to_error(cls,message): 
    62                 repo_io.update_simulation_status() 
     67 
     68                s=repo_io.retrieve_simulation(message.simuid) 
     69 
     70                s.status="error" 
     71 
     72                repo_io.update_simulation_status(s) 
     73 
     74        @classmethod 
     75        def set_sim_status_to_complete(cls,message): 
     76 
     77                s=repo_io.retrieve_simulation(message.simuid) 
     78 
     79                s.status="complete" 
     80 
     81                repo_io.update_simulation_status(s) 
    6382 
    6483        @classmethod 
     
    6887                #repo_io.delete_simulation(name) 
    6988 
    70                 simulation=smon.types.Simulation(name=message.simuid) 
     89                simulation=smon.types.Simulation(name=message.simuid,status="running") 
    7190 
    7291                repo_io.create_simulation(simulation) 
     
    8099                # used for debug 
    81100 
    82                 if "file" in message: 
     101                if message.file is not None: 
    83102                        print "%s %s %s\n"%(message.code,message.jobid,message.file) 
    84103                else: 
     
    107126class MessageActionsMapping(): 
    108127 
     128        # debug 
     129        mapping = { "0000":["log", "print_stdout", "crea_sim"], 
     130                                "0100":["log", "print_stdout", "set_sim_status_to_complete"], 
     131                                "1000":["log", "print_stdout"], 
     132                                "1100":["log", "print_stdout"], 
     133                                "2000":["log", "print_stdout"], 
     134                                "3000":["log", "print_stdout"], 
     135                                "8888":["cleanup"], 
     136                                "9000":["log", "print_stdout"], 
     137                                "9999":["log", "print_stdout", "set_sim_status_to_error"] } 
     138 
     139        # prod 
     140        """ 
    109141        mapping = { "0000":["log", "store_msg", "crea_sim"], 
     142                                "0100":["log", "store_msg", "set_sim_status_to_complete"], 
    110143                                "1000":["log", "store_msg"], 
     144                                "1100":["log", "store_msg"], 
    111145                                "2000":["log", "store_msg"], 
    112146                                "3000":["log", "store_msg"], 
     147                                "8888":["cleanup"], 
    113148                                "9000":["log", "store_msg", "mail"], 
    114149                                "9999":["log", "store_msg", "set_sim_status_to_error", "mail"] } 
     150        """ 
    115151 
    116152class Watcher(): 
     
    198234                                print "ERR009 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 
    199235 
    200                                 #traceback.print_exc() 
    201                                 #raise 
     236                                traceback.print_exc() 
     237                                raise 
    202238 
    203239 
     
    218254                        try: 
    219255                                # message code based action 
    220                                 #Actions.execActions(message) 
    221                                 pass 
     256                                Actions.execActions(message) 
     257 
    222258                        except Exception,e: 
    223259                                print "ERR019 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 
     
    227263                                raise 
    228264 
     265 
     266                        # slow down consumer 
     267                        #time.sleep(0.5) 
    229268 
    230269 
     
    241280                print 'You pressed Ctrl+C!' 
    242281                Watcher.channel.stop_consuming() 
     282                Watcher.stop() 
    243283                sys.exit(0) 
    244284 
     
    248288 
    249289        try: 
     290 
     291                Watcher.start() 
     292 
    250293                Watcher.main() 
    251294 
     295                Watcher.stop() 
     296 
    252297                sys.exit(0) 
    253298 
    254299        except Exception, e: 
    255300 
    256                 #traceback.print_exc() 
     301                traceback.print_exc() 
    257302 
    258303                sys.exit(1) 
  • trunk/Monitoring/libIGCM_mock/libIGCM_mock.sh

    r871 r875  
    4949 
    5050OPTIONS: 
     51   -c              ask for confirmation 
    5152   -h              this help 
    5253   -f              set stack file 
    5354   -l              print scenarios list  
    5455   -m              set MODE 
    55                    MODE may be "scenario", "stackfile" or "purge" 
     56                   MODE may be "scenario", "stackfile" or "cleanup" 
    5657                   default mode is "scenario" 
    5758   -s              set scenario file 
     
    8485} 
    8586 
     87send_cleanup_msg() 
     88{ 
     89        $send_msg_cmd -h localhost -p 5672 -b "$( echo {\"code\":\"8888\"} | base64 -w 0 )" 
     90} 
     91 
    8692# check 
    8793 
     
    130136        # check 
    131137        if [ ! -f "$g__scenariofile" ]; then 
    132                 msg "LIBIGCM-MOCK-ERR003" "scenario file not found" 
     138                msg "LIBIGCM-MOCK-ERR003" "scenario file not found ($g__scenariofile)" 
    133139                exit 1 
    134140        fi 
     
    222228 
    223229                if [ "$g__confirm" = "1" ]; then 
    224                         read -p "Press enter for next message" bla 
     230                        read -p "<<< $l__JSON_msg_buf >>>> sent. Press enter for next message" bla 
    225231                else 
    226232                        sleep $g__delay 
     
    234240        done 3<$g__scenariofile 
    235241 
    236 elif [ "$g__mode" = "purge" ]; then 
    237  
    238         : 
     242elif [ "$g__mode" = "cleanup" ]; then 
     243 
     244        send_cleanup_msg 
    239245 
    240246elif [ "$g__mode" = "stackfile" ]; then 
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__fatal_error__stop_simu

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9000  
     5simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9999 
     6 
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__nonfatal_errors__stop_simu

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000  
     5simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100  
     6simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0100  
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_killed

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000  
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__simu_segfault

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9000  
     5simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9999 
     6 
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__start_second_simu_with_same_name

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000  
     5simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100  
     6simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0100  
     7simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     8simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     9simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 
     10simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000 
     11simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100 
     12simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0100 
  • trunk/Monitoring/libIGCM_mock/scenario/start_simu__stop_simu

    r871 r875  
    1 simuid=simu-001 jobid=job-001 code=0000 file=config.card.base64 
    2 simuid=simu-001 jobid=job-001 code=1000 
    3 simuid=simu-001 jobid=job-001 code=2000 
    4 simuid=simu-001 jobid=job-001 code=3000 
    5 simuid=simu-001 jobid=job-001 code=1100 
    6 simuid=simu-001 jobid=job-001 code=0100 
     1simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 
     2simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 
     3simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000  
     4simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000  
     5simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100  
     6simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0100  
  • trunk/Monitoring/smon/local_repo.py

    r871 r875  
    2626                raise Exception() 
    2727 
    28         _conn=sqlite3.connect(":memory:",timeout) 
     28        db_file="/home/jripsl/supervisor/local_db/local_repo.db" 
     29        #db_file=":memory:" 
     30 
     31        _conn=sqlite3.connect(db_file,timeout) 
    2932 
    3033        create_tables() 
     
    4043        _conn=None 
    4144 
     45def commit(): 
     46        """ 
     47        public method 
     48 
     49        not used for now 
     50        """ 
     51        _conn.commit() 
     52         
     53def rollback(): 
     54        _conn.rollback() 
     55 
    4256def create_tables(): 
    4357 
    44         _conn.execute("create table simulation (id INTEGER PRIMARY KEY, name TEXT)") 
    45         _conn.execute("create unique index idx_simulation on simulation (name)") 
     58        _conn.execute("create table if not exists simulation (id INTEGER PRIMARY KEY, name TEXT, status TEXT)") 
     59        _conn.execute("create unique index if not exists idx_simulation_1 on simulation (name)") 
    4660 
    47         _conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column 
     61        _conn.execute("create table if not exists message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column 
     62 
     63def cleanup(): 
     64        _conn.execute("delete from simulation") 
     65        _conn.execute("delete from message") 
     66        _conn.commit() 
    4867 
    4968def populate_tables_with_sample(): 
    5069 
    51         rows = [('SIMU-001',), 
    52                         ('SIMU-002',), 
    53                         ('SIMU-003',),] 
    54         _conn.executemany('INSERT INTO simulation (name) VALUES (?)', rows) 
     70        rows = [('SIMU-001','running'), 
     71                        ('SIMU-002','running'), 
     72                        ('SIMU-003','running'),] 
     73 
     74        _conn.executemany('INSERT INTO simulation (name,status) VALUES (?,?)', rows) 
     75 
     76        _conn.commit() 
    5577 
    5678def retrieve_simulations(): 
     
    5880        c=_conn.cursor() 
    5981 
    60         c.execute("select name,id from simulation") 
     82        c.execute("select name,id,status from simulation") 
    6183 
    6284        rs=c.fetchone() 
    6385        while rs is not None: 
    64                 li.append(types.Simulation(name=rs[0],id=rs[1])) 
     86                li.append(types.Simulation(name=rs[0],id=rs[1],status=rs[2])) 
    6587                rs=c.fetchone() 
    6688 
     
    7092        c=_conn.cursor() 
    7193 
    72         c.execute("select name,id from simulation where name = ?",(name,)) 
     94        c.execute("select name,id,status from simulation where name = ?",(name,)) 
    7395 
    7496        rs=c.fetchone() 
     
    7799                raise Exception() 
    78100 
    79         return types.Simulation(id=rs[1]) 
     101        return types.Simulation(name=rs[0],id=rs[1],status=rs[2]) 
    80102     
    81103def delete_simulation(simulation): 
    82104        _conn.execute("delete from simulation where name = ?",(simulation.name,)) 
    83105 
     106        _conn.commit() 
     107 
    84108def create_simulation(simulation): 
    85         _conn.execute("insert into simulation (name) values (?)",(simulation.name,)) 
     109        _conn.execute("insert into simulation (name,status) values (?,?)",(simulation.name,simulation.status)) 
     110 
     111        _conn.commit() 
    86112     
    87113def update_simulation_status(simulation): 
    88114        _conn.execute("update simulation set status=? where name = ?",(simulation.status,simulation.name)) 
     115 
     116        _conn.commit() 
    89117 
    90118def retrieve_messages(simulation): 
     
    105133        _conn.execute("delete from message where simulation_id = ?",(simulation.id,)) 
    106134 
     135        _conn.commit() 
     136 
    107137def create_message(message): 
    108138        _conn.execute("insert into message (simulation_id) values (?)",(message.simuid,)) 
     139 
     140        _conn.commit() 
    109141 
    110142def retrieve_last_message(simulation): 
  • trunk/Monitoring/smon/repo_io.py

    r871 r875  
    8787 
    8888def test(): 
     89        """ 
     90        not used 
     91        """ 
     92 
    8993        repo.create_message("test2", 2, "bla2") 
    9094        commit() 
     
    9599        repo.create_message("test3", 3, "bla3") 
    96100        rollback() 
     101 
     102def cleanup(): 
     103        if mode==CSTE_MODE_LOCAL_REPO: 
     104                repo.cleanup() 
     105        elif mode==CSTE_MODE_REMOTE_REPO: 
     106                raise Exception("ERR707") 
     107        elif mode==CSTE_MODE_REMOTE_REPO_STUB: 
     108                pass 
     109        else: 
     110                raise Exception("ERR007 - incorrect mode") 
    97111 
    98112def commit(): 
  • trunk/Monitoring/smon/types.py

    r866 r875  
    4848 
    4949class Message(): 
     50        file=None 
    5051 
    5152        def __init__(self,JSON_KW): 
Note: See TracChangeset for help on using the changeset viewer.