Changeset 875
- Timestamp:
- 06/11/13 15:05:18 (11 years ago)
- Location:
- trunk/Monitoring
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/Watch/repo-state
r871 r875 1 1 #!/usr/bin/env python 2 3 # --- ncurses sample 14 5 #import curses6 #from curses import panel7 #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 = 018 # self.items = items19 # self.items.append(('exit','exit'))20 #21 # def navigate(self, n):22 # self.position += n23 # if self.position < 0:24 # self.position = 025 # elif self.position >= len(self.items):26 # self.position = len(self.items)-127 #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_REVERSE40 # else:41 # mode = curses.A_NORMAL42 #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 # break51 # 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 = stdscreen70 # 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 294 95 # Author: Nikolai Tschacher96 # Date: 02.06.201397 #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 build107 # a textbox.108 # """109 # self.L = L110 # # Element parameters. Change them here.111 # self.TEXTBOX_WIDTH = 50112 # self.TEXTBOX_HEIGHT = 6113 #114 # self.PAD_WIDTH = 400115 # self.PAD_HEIGHT = 10000116 #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 picked128 #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 screen134 # 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 the161 # horizontal middle of the pad. """162 # # Get the actual screensize.163 # maxy, maxx = self.stdscr.getmaxyx()164 #165 # windows = []166 # i = 1167 # 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_HEIGHT171 #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 windows177 #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 arguments182 # # to specify the part of the self.pad to be displayed and the location on183 # # the screen to be used for the display. The arguments are pminrow,184 # # pmincol, sminrow, smincol, smaxrow, smaxcol; the p arguments refer185 # # to the upper left corner of the self.pad region to be displayed and the186 # # s arguments define a clipping box on the screen within which the187 # # 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 = 0198 # last = 1199 # top_textbox = windows[0]200 #201 # while True:202 # # Highligth the selected one, the last selected textbox should203 # # 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 current208 # # 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_selected223 #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 += 1234 # elif c == ord('k'):235 # if current_selected <= 0:236 # current_selected = len(windows)-1 # wrap around.237 # else:238 # current_selected -= 1239 # elif c == ord('q'): # Quit without selecting.240 # break241 # # 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 3267 268 269 2 270 3 import sys … … 279 12 280 13 14 # init 15 16 # set pad height/width 17 padhlines = 4 18 padwcols = 30 19 20 # add margin 21 padhlines += 2 22 padwcols += 2 23 24 25 26 281 27 repo_io.init() # open DB connection 282 28 … … 285 31 simulations=repo_io.retrieve_simulations() 286 32 287 mylines = ["Line {0} ".format(id)*3 for id in range(1,11)]288 33 289 34 35 def 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 290 66 def main(stdscr): 291 hlines = begin_y = begin_x = 5 ; wcols = 10292 # calculate total content size293 padhlines = len(mylines)294 padwcols = 0295 for line in mylines:296 if len(line) > padwcols: padwcols = len(line)297 padhlines += 2 ; padwcols += 2 # allow border298 #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)307 67 308 mypadn.border(0) # first ... 309 mypads.border(0) # ... border 68 """ 69 window test 310 70 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 """ 316 75 317 mypadn.border(0) # second ... 318 mypads.border(0) # ... border 76 # create pad 77 global mypad 78 mypad=curses.newpad(padhlines, padwcols) 319 79 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) 336 85 337 86 338 87 339 88 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 341 120 342 121 … … 348 127 349 128 350 # --- urwid sample 1351 129 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() 130 curses.wrapper(main) 358 131 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 132 repo_io.free() # close DB connection -
trunk/Monitoring/Watch/watch
r871 r875 29 29 import smon.types 30 30 31 31 32 class Mail(): 32 33 … … 59 60 60 61 @classmethod 62 def cleanup(cls,message): 63 repo_io.cleanup() # truncate/delete everything 64 65 @classmethod 61 66 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) 63 82 64 83 @classmethod … … 68 87 #repo_io.delete_simulation(name) 69 88 70 simulation=smon.types.Simulation(name=message.simuid )89 simulation=smon.types.Simulation(name=message.simuid,status="running") 71 90 72 91 repo_io.create_simulation(simulation) … … 80 99 # used for debug 81 100 82 if "file" in message:101 if message.file is not None: 83 102 print "%s %s %s\n"%(message.code,message.jobid,message.file) 84 103 else: … … 107 126 class MessageActionsMapping(): 108 127 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 """ 109 141 mapping = { "0000":["log", "store_msg", "crea_sim"], 142 "0100":["log", "store_msg", "set_sim_status_to_complete"], 110 143 "1000":["log", "store_msg"], 144 "1100":["log", "store_msg"], 111 145 "2000":["log", "store_msg"], 112 146 "3000":["log", "store_msg"], 147 "8888":["cleanup"], 113 148 "9000":["log", "store_msg", "mail"], 114 149 "9999":["log", "store_msg", "set_sim_status_to_error", "mail"] } 150 """ 115 151 116 152 class Watcher(): … … 198 234 print "ERR009 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 199 235 200 #traceback.print_exc()201 #raise236 traceback.print_exc() 237 raise 202 238 203 239 … … 218 254 try: 219 255 # message code based action 220 #Actions.execActions(message)221 pass 256 Actions.execActions(message) 257 222 258 except Exception,e: 223 259 print "ERR019 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) … … 227 263 raise 228 264 265 266 # slow down consumer 267 #time.sleep(0.5) 229 268 230 269 … … 241 280 print 'You pressed Ctrl+C!' 242 281 Watcher.channel.stop_consuming() 282 Watcher.stop() 243 283 sys.exit(0) 244 284 … … 248 288 249 289 try: 290 291 Watcher.start() 292 250 293 Watcher.main() 251 294 295 Watcher.stop() 296 252 297 sys.exit(0) 253 298 254 299 except Exception, e: 255 300 256 #traceback.print_exc()301 traceback.print_exc() 257 302 258 303 sys.exit(1) -
trunk/Monitoring/libIGCM_mock/libIGCM_mock.sh
r871 r875 49 49 50 50 OPTIONS: 51 -c ask for confirmation 51 52 -h this help 52 53 -f set stack file 53 54 -l print scenarios list 54 55 -m set MODE 55 MODE may be "scenario", "stackfile" or " purge"56 MODE may be "scenario", "stackfile" or "cleanup" 56 57 default mode is "scenario" 57 58 -s set scenario file … … 84 85 } 85 86 87 send_cleanup_msg() 88 { 89 $send_msg_cmd -h localhost -p 5672 -b "$( echo {\"code\":\"8888\"} | base64 -w 0 )" 90 } 91 86 92 # check 87 93 … … 130 136 # check 131 137 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)" 133 139 exit 1 134 140 fi … … 222 228 223 229 if [ "$g__confirm" = "1" ]; then 224 read -p " Press enter for next message" bla230 read -p "<<< $l__JSON_msg_buf >>>> sent. Press enter for next message" bla 225 231 else 226 232 sleep $g__delay … … 234 240 done 3<$g__scenariofile 235 241 236 elif [ "$g__mode" = " purge" ]; then237 238 :242 elif [ "$g__mode" = "cleanup" ]; then 243 244 send_cleanup_msg 239 245 240 246 elif [ "$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.base642 simuid= simu-001 jobid=job-001 code=10003 simuid= simu-001 jobid=job-001 code=20004 simuid= simu-001 jobid=job-001 code=30005 simuid= simu-001 jobid=job-001 code=11006 simuid=simu-001 jobid=job-001 code=0100 1 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9000 5 simuid=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.base642 simuid= simu-001 jobid=job-001 code=10003 simuid= simu-001 jobid=job-001 code=20004 simuid= simu-001 jobid=job-001 code=30005 simuid= simu-001 jobid=job-001 code=11006 simuid= simu-001 jobid=job-001 code=01001 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000 5 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100 6 simuid=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 1 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=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.base642 simuid= simu-001 jobid=job-001 code=10003 simuid= simu-001 jobid=job-001 code=20004 simuid= simu-001 jobid=job-001 code=30005 simuid= simu-001 jobid=job-001 code=11006 simuid=simu-001 jobid=job-001 code=0100 1 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=9000 5 simuid=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 1 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000 5 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100 6 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0100 7 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 8 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 9 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 10 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000 11 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100 12 simuid=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.base642 simuid= simu-001 jobid=job-001 code=10003 simuid= simu-001 jobid=job-001 code=20004 simuid= simu-001 jobid=job-001 code=30005 simuid= simu-001 jobid=job-001 code=11006 simuid= simu-001 jobid=job-001 code=01001 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=0000 file=config.card.base64 2 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1000 3 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=2000 4 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=3000 5 simuid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE jobid=BIGBRO.clim.TEST.LMDZOR.p86denv.TGCC.CURIE.1 code=1100 6 simuid=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 26 26 raise Exception() 27 27 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) 29 32 30 33 create_tables() … … 40 43 _conn=None 41 44 45 def commit(): 46 """ 47 public method 48 49 not used for now 50 """ 51 _conn.commit() 52 53 def rollback(): 54 _conn.rollback() 55 42 56 def create_tables(): 43 57 44 _conn.execute("create table simulation (id INTEGER PRIMARY KEY, nameTEXT)")45 _conn.execute("create unique index i dx_simulationon 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)") 46 60 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 63 def cleanup(): 64 _conn.execute("delete from simulation") 65 _conn.execute("delete from message") 66 _conn.commit() 48 67 49 68 def populate_tables_with_sample(): 50 69 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() 55 77 56 78 def retrieve_simulations(): … … 58 80 c=_conn.cursor() 59 81 60 c.execute("select name,id from simulation")82 c.execute("select name,id,status from simulation") 61 83 62 84 rs=c.fetchone() 63 85 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])) 65 87 rs=c.fetchone() 66 88 … … 70 92 c=_conn.cursor() 71 93 72 c.execute("select name,id from simulation where name = ?",(name,))94 c.execute("select name,id,status from simulation where name = ?",(name,)) 73 95 74 96 rs=c.fetchone() … … 77 99 raise Exception() 78 100 79 return types.Simulation( id=rs[1])101 return types.Simulation(name=rs[0],id=rs[1],status=rs[2]) 80 102 81 103 def delete_simulation(simulation): 82 104 _conn.execute("delete from simulation where name = ?",(simulation.name,)) 83 105 106 _conn.commit() 107 84 108 def 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() 86 112 87 113 def update_simulation_status(simulation): 88 114 _conn.execute("update simulation set status=? where name = ?",(simulation.status,simulation.name)) 115 116 _conn.commit() 89 117 90 118 def retrieve_messages(simulation): … … 105 133 _conn.execute("delete from message where simulation_id = ?",(simulation.id,)) 106 134 135 _conn.commit() 136 107 137 def create_message(message): 108 138 _conn.execute("insert into message (simulation_id) values (?)",(message.simuid,)) 139 140 _conn.commit() 109 141 110 142 def retrieve_last_message(simulation): -
trunk/Monitoring/smon/repo_io.py
r871 r875 87 87 88 88 def test(): 89 """ 90 not used 91 """ 92 89 93 repo.create_message("test2", 2, "bla2") 90 94 commit() … … 95 99 repo.create_message("test3", 3, "bla3") 96 100 rollback() 101 102 def 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") 97 111 98 112 def commit(): -
trunk/Monitoring/smon/types.py
r866 r875 48 48 49 49 class Message(): 50 file=None 50 51 51 52 def __init__(self,JSON_KW):
Note: See TracChangeset
for help on using the changeset viewer.