Index: /trunk/Monitoring/Broker/README
===================================================================
--- /trunk/Monitoring/Broker/README	(revision 865)
+++ /trunk/Monitoring/Broker/README	(revision 866)
@@ -45,6 +45,7 @@
 		- cd /opt/rabbitmq-server-3.0.2/sbin
 		- ./rabbitmq-server -detached
-	- to stop the daemon, use this
+	- to stop the daemon, use one of those
 		- kill -TERM $(pidof epmd)
+		- rabbitmqctl stop
 - operation
 	- to print RabbitMQ status, use
Index: /trunk/Monitoring/CNClient/README
===================================================================
--- /trunk/Monitoring/CNClient/README	(revision 865)
+++ /trunk/Monitoring/CNClient/README	(revision 866)
@@ -1,39 +1,39 @@
-- This program uses rabbitmq-c library (v0.3.0)
+- this program uses rabbitmq-c library (v0.3.0)
 	- https://github.com/alanxz/rabbitmq-c
-- Compilation (static)
-	- Library installation
-		- using system package
-			- install using commands below
-				- aptitude install librabbitmq0
-				- aptitude install librabbitmq-dev
-			- note that it is likely that system packages versions are out of date (we need v0.3.0)
-			  so better use installation from source
-		- from source
-			- retrieve source
-				- wget https://github.com/alanxz/rabbitmq-c/archive/rabbitmq-c-v0.3.0.zip -O rabbitmq-c-v0.3.0.zip
-				- unzip rabbitmq-c-v0.3.0.zip
-				- cd rabbitmq-c-v0.3.0
-			- compilation using autoconf (automake v1.9+, and libtool v2.2+)
-				- autoreconf -i
-					- if error occurs at this step, check requirement below
-						- we require autotools v2.63 or better to build. I think RHEL5 ships with v2.59 which lacks the AC_PROC_CC_C99 macro.
-							- You can do one of two things;
-								- Install a newer version of autotools
-								- Build using cmake (v2.6 or better).
-				- ./configure --enable-static
-				- make
-				- make install
-			- compilation using cmake (CMake v2.6+)
-				- mkdir build && cd build
-				- cmake -DBUILD_STATIC_LIBS=True -DBUILD_SHARED_LIBS=True ..
-				- cmake --build .
-				- make
-					- you got error AAA below, it's normal
-						make[2]: *** Pas de rÃšgle pour fabriquer la cible Â« librabbitmq/librabbitmq.so.1.0.1 Â», nÃ©cessaire pour Â« examples/amqp_bind Â». ArrÃªt.
-						make[1]: *** [examples/CMakeFiles/amqp_bind.dir/all] Erreur 2
-						make: *** [all] Erreur 2
-				- make
-				  (because of the above error (AAA), you need to run make twice)
-				- make install
+- library installation
+	- using system package
+		- install using commands below
+			- aptitude install librabbitmq0
+			- aptitude install librabbitmq-dev
+		- note that it is likely that system packages versions are out of date (we need v0.3.0)
+		  so better use installation from source
+	- from source
+		- retrieve source
+			- wget https://github.com/alanxz/rabbitmq-c/archive/rabbitmq-c-v0.3.0.zip -O rabbitmq-c-v0.3.0.zip
+			- unzip rabbitmq-c-v0.3.0.zip
+			- cd rabbitmq-c-v0.3.0
+		- compilation using autoconf (automake v1.9+, and libtool v2.2+)
+			- autoreconf -i
+				- if error occurs at this step, check requirement below
+					- we require autotools v2.63 or better to build. I think RHEL5 ships with v2.59 which lacks the AC_PROC_CC_C99 macro.
+						- You can do one of two things;
+							- Install a newer version of autotools
+							- Build using cmake (v2.6 or better).
+			- ./configure --enable-static
+			- make
+			- make install
+		- compilation using cmake (CMake v2.6+)
+			- mkdir build && cd build
+			- cmake -DBUILD_STATIC_LIBS=True -DBUILD_SHARED_LIBS=True ..
+			- cmake --build .
+			- make
+				- you got error AAA below, it's normal
+					make[2]: *** Pas de rÃšgle pour fabriquer la cible Â« librabbitmq/librabbitmq.so.1.0.1 Â», nÃ©cessaire pour Â« examples/amqp_bind Â». ArrÃªt.
+					make[1]: *** [examples/CMakeFiles/amqp_bind.dir/all] Erreur 2
+					make: *** [all] Erreur 2
+			- make
+			  (because of the above error (AAA), you need to run make twice)
+			- make install
+- compilation (static)
 	- gcc -static -I/usr/local/include -L/usr/local/lib -Wall -o sendAMQPMsg send_AMQP_msg.c -lrabbitmq
 		- we get warning below during compilation
Index: /trunk/Monitoring/CNClient/send_AMQP_msg.c
===================================================================
--- /trunk/Monitoring/CNClient/send_AMQP_msg.c	(revision 865)
+++ /trunk/Monitoring/CNClient/send_AMQP_msg.c	(revision 866)
@@ -259,12 +259,23 @@
         break;
       case 'e':
-        fprintf(stderr, "Usage: amqp_producer host port rate_limit message_count\n");
-
-        fprintf(stderr, "Example 1: ./sendAMQPMsg -h localhost -p 5672 -b 'eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg=='\n");
-
-        // obsolete (from now all sent data must be B64 encoded)
-        fprintf(stderr, "Example 2: ./sendAMQPMsg -h localhost -p 5672 -f /home/foobar/config.card -b '{\"jobid\":\"toto\"}'\n");
-
-        fprintf(stderr, "Example 3: ./sendAMQPMsg -h localhost -p 5672 -b 'am9iaWQ6dG90byBjb2RlOjAwMDAK' -f ../sample/config.card.base64\n");
+
+        fprintf(stderr, "Usage: amqp_producer host port\n");
+
+
+        // --- example without config card ---
+
+        // eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg => '{"jobid":"toto","code":"0000"}'
+        fprintf(stderr, "./sendAMQPMsg -h localhost -p 5672 -b 'eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg=='\n");
+
+
+        // --- example with config card ---
+
+        // eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg => '{"jobid":"toto","code":"0000","file":"<base64 encoded file here>"}'
+        fprintf(stderr, "./sendAMQPMsg -h localhost -p 5672 -b 'eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg==' -f /home/jripsl/snapshot/Monitoring/sample/config.card.base64\n");
+
+        // eyJzaW11aWQiOiJmb29iYXIiLCJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg== => '{"simuid":"foobar","jobid":"toto","code":"0000","file":"<base64 encoded file here>"}'
+        fprintf(stderr, "./sendAMQPMsg -h localhost -p 5672 -b 'eyJzaW11aWQiOiJmb29iYXIiLCJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg==' -f /home/jripsl/snapshot/Monitoring/sample/config.card.base64\n");
+
+
         exit(0);
       case 'f':
@@ -316,8 +327,9 @@
     }
 
-    body_final=malloc(strlen(body_tmp) + 6 + strlen(buf) + 1);
+    body_final=malloc(5 + strlen(body_tmp) + 6 + strlen(buf) + 1);
     //strcpy(body_final,"\0");
+    strcat(body_final,"body:");
     strcat(body_final,body_tmp);
-    strcat(body_final,",file=");
+    strcat(body_final,",file:");
     strcat(body_final,buf);
 
@@ -330,6 +342,10 @@
     // retrieve msg body from argument
 
-    body=body_tmp;
-
+    body_final=malloc(5 + strlen(body_tmp) + 1);
+
+    strcat(body_final,"body:");
+    strcat(body_final,body_tmp);
+
+    body=body_final;
   }
 
@@ -368,7 +384,8 @@
     free(buf);
 
+  free(body_final);
 
   //this is to prevent overwhelming rabbitMQ server (and to prevent triggering rabbitMQ defensive behaviours (e.g. connection blocking))
-  usleep( 200 000 ); // O.2 second
+  //usleep( 200000 ); // O.2 second
 
 
Index: /trunk/Monitoring/Watch/repo-state
===================================================================
--- /trunk/Monitoring/Watch/repo-state	(revision 866)
+++ /trunk/Monitoring/Watch/repo-state	(revision 866)
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+
+import curses
+from curses import panel
+
+class Menu(object):
+
+	def __init__(self, items, stdscreen):
+		self.window = stdscreen.subwin(0,0)
+		self.window.keypad(1)
+		self.panel = panel.new_panel(self.window)
+		self.panel.hide()
+		panel.update_panels()
+
+		self.position = 0
+		self.items = items
+		self.items.append(('exit','exit'))
+
+	def navigate(self, n):
+		self.position += n
+		if self.position < 0:
+			self.position = 0
+		elif self.position >= len(self.items):
+			self.position = len(self.items)-1
+
+	def display(self):
+		self.panel.top()
+		self.panel.show()
+		self.window.clear()
+
+
+		while True:
+			self.window.refresh()
+			curses.doupdate()
+			for index, item in enumerate(self.items):
+				if index == self.position:
+					mode = curses.A_REVERSE
+				else:
+					mode = curses.A_NORMAL
+
+				msg = '%d. %s' % (index, item[0])
+				self.window.addstr(1+index, 1, msg, mode)
+
+			key = self.window.getch()
+
+			if key in [curses.KEY_ENTER, ord('\n')]:
+				if self.position == len(self.items)-1:
+					break
+				else:
+					self.items[self.position][1]()
+
+			elif key == curses.KEY_UP:
+				self.navigate(-1)
+
+			elif key == curses.KEY_DOWN:
+				self.navigate(1)
+
+		self.window.clear()
+		self.panel.hide()
+		panel.update_panels()
+		curses.doupdate()
+
+
+class MyApp(object):
+
+	def __init__(self, stdscreen):
+		self.screen = stdscreen
+		curses.curs_set(0)
+
+		submenu_items = [
+				('beep', curses.beep),
+				('flash', curses.flash)
+				]
+		submenu = Menu(submenu_items, self.screen)
+
+		main_menu_items = [
+				('beep', curses.beep),
+				('flash', curses.flash),
+				('submenu', submenu.display)
+				]
+		main_menu = Menu(main_menu_items, self.screen)
+		main_menu.display()
+
+if __name__ == '__main__':
+	curses.wrapper(MyApp)
Index: /trunk/Monitoring/Watch/watch
===================================================================
--- /trunk/Monitoring/Watch/watch	(revision 865)
+++ /trunk/Monitoring/Watch/watch	(revision 866)
@@ -26,6 +26,6 @@
 sys.path.append("/home/jripsl/snapshot/Monitoring")
 
-import smon.repo_io
-
+import smon.repo_io as repo_io
+import smon.types
 
 """
@@ -66,16 +66,20 @@
 
 	@classmethod
-	def store_msg(cls):
-		repo_io.store_messages(name)
-
-	@classmethod
-	def set_sim_status_to_error(cls):
+	def store_msg(cls,message):
+		repo_io.create_message(message)
+
+	@classmethod
+	def set_sim_status_to_error(cls,message):
 		repo_io.update_simulation_status()
 
 	@classmethod
-	def crea_sim(cls):
+	def crea_sim(cls,message):
+
 		#repo_io.retrieve_simulation(name)
 		#repo_io.delete_simulation(name)
-		repo_io.create_simulation()
+
+		simulation=smon.types.Simulation(name=message.simuid)
+
+		repo_io.create_simulation(simulation)
 
 	@classmethod
@@ -88,17 +92,17 @@
 
 		if "file" in message:
-			print "%s %s %s\n"%(message["code"],message["jobid"],message["file"])
+			print "%s %s %s\n"%(message.code,message.jobid,message.file)
 		else:
-			print "%s %s\n"%(message["code"],message["jobid"])
+			print "%s %s\n"%(message.code,message.jobid)
 
 	@classmethod
 	def log(cls,message):
 		with open("/home/jripsl/supervisor/log/supervisor.log", "a") as log_file:
-			log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message["code"],message["jobid"]))
+			log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message.code,message.jobid))
 
 	@classmethod
 	def execActions(cls,message):
 
-		message_code=message["code"]
+		message_code=message.code
 
 		for action in MessageActionsMapping.mapping[message_code]:
@@ -155,21 +159,66 @@
 
 		def callback(ch, method, properties, raw_msg):
-			#
-			#return
-
-			base64_decoded_msg=base64.b64decode(raw_msg)
+
+			# msg fmt: body:base64,file:base64 (no JSON here !!!)
+
+
+
+
+			# first deserialization (no JSON here !!!)
+
+			fields=raw_msg.split(",")
+
+			l__tmp_dic={}
+
+			for field in fields:
+
+				# debug
+				print " [x] Received %s" % field
+
+				splitted_field=field.split(":")
+
+				key=splitted_field[0]
+				val=splitted_field[1]
+
+				l__tmp_dic[key]=val
+
+
+			# debug
+			print " [x] Received %s (encoded)" % l__tmp_dic["body"]
+
+			
+			# base64 decode body
+			base64_decoded_msg=base64.b64decode(l__tmp_dic["body"])
+
 
 			# debug
 			#print " [x] Received %s" % raw_msg
+			print " [x] Received %s (uudecoded)" % base64_decoded_msg 
 			#print " [x] Received %s (uudecoded)" % base64_decoded_msg 
+
 
 			message=None
 			try:
-				message=json.loads(base64_decoded_msg)
+				# body deserialization 
+				JSON_msg=json.loads(base64_decoded_msg)
+				message=smon.types.Message(JSON_msg)      # all JSON object members will be available in smon.types.Message object
+
+				if "file" in l__tmp_dic:
+
+					# base64 decode file
+					base64_decoded_file=base64.b64decode(l__tmp_dic["file"])
+
+					# add into msg
+					message.file=base64_decoded_file
 
 				# message code based action
-				Watcher.execActions(message)
+				Actions.execActions(message)
+
 			except Exception,e:
 				print "Exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg)
+
+				#traceback.print_exc()
+
+				raise
 
 		self.channel.basic_consume(callback, queue='myqueue', no_ack=True)
@@ -198,5 +247,5 @@
 	except Exception, e:
 
-		traceback.print_exc()
+		#traceback.print_exc()
 
 		sys.exit(1)
Index: /trunk/Monitoring/doc/README
===================================================================
--- /trunk/Monitoring/doc/README	(revision 865)
+++ /trunk/Monitoring/doc/README	(revision 866)
@@ -6,7 +6,17 @@
 	- Supervisor installation
 		- Python installation
-			- TODO: add python install instructions here
+			- yum install python26
+			- yum install python26-devel
+			- yum install sqlite
+			- yum install sqlite-devel
+			- yum install python-sqlite
 		- Virtualenv installation
-			- TODO: add virtual env install instructions here
+			- cd /opt/src/
+			- wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.1.tar.gz
+			- tar xzvf virtualenv-1.6.1.tar.gz
+			- rm virtualenv-1.6.1.tar.gz
+			- cd /opt/src/virtualenv-1.6.1
+			- /usr/bin/python26 virtualenv.py --distribute --unzip-setuptools /opt/python2.6_ve
+			- source /opt/python2.6_ve/bin/activate
 		- Python PYPI libraries installation
 			- procedure (as root)
@@ -17,25 +27,30 @@
 				- pip install <package name>
 			- packages list
-				- packages below are needed by SMON
-					- pip install pika # RabbitMQ client library
-				- packages below are needed by Prodiguer library
-					-
-						- pip install psycopg2
-							- doesn't work (Error: pg_config executable not found)
-								- solution is
-									- yum install python-psycopg2.x86_64
-									- yum install libpqxx-devel
-									- yum install python-devel
-									- pip install psycopg2
-										- works
-						- pip install Sqlalchemy
-						- pip install elixir
-						- pip install simplejson
-					- note: some Elixir/SQLAlchemy versions are not compatible.
-					  to be sure, you can use version below which are compatible
-						- Elixir-0.7.1-py2.6.egg-info
-						- SQLAlchemy-0.7.8-py2.6.egg-info
+				- pika     # RabbitMQ client library
+				- networkx # graph library
+				- #pip amqplib # not used for now
 		- Prodiguer library installation
-			- svn co svn+ssh://<login here>@forge.ipsl.jussieu.fr/ipsl/forge/projets/prodiguer/svn/sw/src/python/trunk/prodiguer_shared/src
-			- edit "watch" script and edit line below accordingly
-				- sys.path.append("/home/jripsl/snapshot/src") 
+			- dependencies (PYPI packages)
+				-
+					- pip install psycopg2
+						- doesn't work (Error: pg_config executable not found)
+							- solution is
+								- yum install python-psycopg2.x86_64
+								- yum install libpqxx-devel
+								- yum install python-devel
+								- pip install psycopg2
+									- works
+					- pip install Sqlalchemy
+					- pip install elixir
+					- pip install simplejson
+				- notes
+					- some Elixir/SQLAlchemy versions are not compatible.
+						- to be sure, you can use version below which are compatible
+							- Elixir-0.7.1-py2.6.egg-info
+							- SQLAlchemy-0.7.8-py2.6.egg-info
+						- to install specific version with pip, do
+							- pip install SQLAlchemy==0.7.8
+			- Prodiguer package
+				- svn co svn+ssh://<login here>@forge.ipsl.jussieu.fr/ipsl/forge/projets/prodiguer/svn/sw/src/python/trunk/prodiguer_shared/src
+				- edit "watch" script and edit line below accordingly
+					- sys.path.append("/home/jripsl/snapshot/src") 
Index: /trunk/Monitoring/script/libIGCM_mock.sh
===================================================================
--- /trunk/Monitoring/script/libIGCM_mock.sh	(revision 865)
+++ /trunk/Monitoring/script/libIGCM_mock.sh	(revision 866)
@@ -12,16 +12,166 @@
 ##################################
 
+# Notes
+#   - bash required version: 3+
+#   - "=" and " " are used as delimiter in scenario file (be sure note to use it in fields data)
+
+# init
+
 stack_file=$1
-send_msg="/home/jripsl/snapshot/Monitoring/CNClient/sendAMQPMsg"
+send_msg_cmd="/home/jripsl/snapshot/Monitoring/CNClient/sendAMQPMsg"
+scenario_dir=scenario
+g__mode="scenario"
+g__stackfile=
+g__scenario_file=
 
-if [ $# -lt 1 ]; then
-	echo "Usage $0 ../sample/stack_light"
+# func
+
+curdate ()
+{
+    date '+%F %T'
+}
+
+msg ()
+{
+    l__code="$1"
+    l__msg="$2"
+
+    echo "$(curdate) - $l__code - $l__msg"
+}
+
+usage ()
+{
+	cat >&1 << EOF
+
+USAGE: $(basename $0) [-m mode] [-s scenario] [-l] [-t file]
+
+OPTIONS:
+   -f              set stack file
+   -l              print scenarios list 
+   -m              set mode (if missing, "scenario" mode is used)
+   -s              set scenario
+
+EXAMPLES:
+
+   To parse a stack file and send corressponding messages, do:
+
+   $0 -m stackfile -f ../sample/stack_light
+
+   To list scenarios, do:
+
+   $0 -l
+
+   To run scenario <scenario>, do:
+
+   $0 -s <scenario>
+EOF
+	exit 2
+}
+
+list_scenarios ()
+{
+	echo ""
+	echo "Scenarios list:"
+	echo ""
+	ls -1 $scenario_dir
+	echo ""
+	exit 2
+}
+
+# check
+
+if [ $# -eq 0 ]; then
+	usage
+fi
+
+# parse args
+
+while getopts 'f:hlm:s:' OPTION
+do
+  case $OPTION in
+  f)    g__stackfile="$OPTARG"
+        ;;
+  h)    usage
+        ;;
+  l)    list_scenarios
+        ;;
+  m)    g__mode="$OPTARG"
+        ;;
+  s)    l__scenario_file="$OPTARG"
+
+		if [[ "$l__scenario_file" =~ "*/*" ]]; then
+			# full/relative path was given with the filename
+
+			g__scenario_file="$l__scenario_file"
+		else
+			# only the filename was given
+
+			g__scenario_file="$scenario_dir/$l__scenario_file"
+		fi
+
+		;;
+  ?)    exit 1 # we come here when a required option argument is missing (bash getopts mecanism)
+        ;;
+  esac
+done
+
+# mode switch
+if [ "$g__mode" = "scenario" ]; then
+
+	# check
+	if [ ! -f "$g__scenario_file" ]; then
+		msg "LIBIGCM-MOCK-ERR003" "scenario file not found"
+		exit 1
+	fi
+
+	N=0
+	while read LINE ; do
+
+		N=$((N+1))
+
+		l__JSON_msg_buf=
+
+		# process fields (split on " " delimiter)
+		for field in "$LINE"; do
+			arr=(${LINE//=/ }) # process key/value (split on "=" delimiter)
+			key=${arr[0]}
+			val=${arr[1]}
+
+			# base64 encoding
+
+			# append to JSON message buffer
+			l__JSON_msg_buf=$l__JSON_msg_buf
+
+		done
+
+		# message base64 encoding
+
+
+		#callname=$(echo $line | awk -F" " '{print $4}' )
+
+		# send AMQP message
+		#$send_msg_cmd localhost 5672 string "$callname"
+		echo
+
+	done < $g__scenario_file
+
+elif [ "$g__mode" = "stackfile" ]; then
+
+	# check
+	if [ ! -f $stack_file ]; then
+		msg "LIBIGCM-MOCK-ERR001" "file not found"
+		exit 1
+	fi
+
+	IFS=$'\n'
+	for line in $(cat $stack_file); do
+		#echo $line | awk -F" " '{print $4}'
+		callname=$(echo $line | awk -F" " '{print $4}' )
+		$send_msg_cmd localhost 5672 string "$callname"
+	done
+else
+	msg "LIBIGCM-MOCK-ERR002" "incorrect mode"
 	exit 1
 fi
 
-IFS=$'\n'
-for line in $(cat $stack_file); do
-	#echo $line | awk -F" " '{print $4}'
-	callname=$(echo $line | awk -F" " '{print $4}' )
-	$send_msg localhost 5672 string "$callname"
-done
+exit 0
Index: /trunk/Monitoring/script/scenario/start_simu__fatal_error__stop_simu
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__fatal_error__stop_simu	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__fatal_error__stop_simu	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/script/scenario/start_simu__nonfatal_errors__stop_simu
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__nonfatal_errors__stop_simu	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__nonfatal_errors__stop_simu	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/script/scenario/start_simu__simu_killed
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__simu_killed	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__simu_killed	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/script/scenario/start_simu__simu_segfault
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__simu_segfault	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__simu_segfault	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/script/scenario/start_simu__start_second_simu_with_same_name
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__start_second_simu_with_same_name	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__start_second_simu_with_same_name	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/script/scenario/start_simu__stop_simu
===================================================================
--- /trunk/Monitoring/script/scenario/start_simu__stop_simu	(revision 866)
+++ /trunk/Monitoring/script/scenario/start_simu__stop_simu	(revision 866)
@@ -0,0 +1,6 @@
+simuid=simu-001 jobid=job-001 code=0000 file=./sample/config.card.base64
+simuid=simu-001 jobid=job-001 code=1000
+simuid=simu-001 jobid=job-001 code=2000
+simuid=simu-001 jobid=job-001 code=3000
+simuid=simu-001 jobid=job-001 code=1100
+simuid=simu-001 jobid=job-001 code=0100
Index: /trunk/Monitoring/smon/local_repo.py
===================================================================
--- /trunk/Monitoring/smon/local_repo.py	(revision 865)
+++ /trunk/Monitoring/smon/local_repo.py	(revision 866)
@@ -40,5 +40,5 @@
 def create_tables():
 	_conn.execute("create table simulation (id INTEGER PRIMARY KEY, name TEXT)")
-	_conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id INT)")
+	_conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column
 
 def retrieve_simulation(name):
@@ -81,5 +81,5 @@
 
 def create_message(message):
-	_conn.execute("insert into message (simulation_id) values (?)",(message.simulation_id,))
+	_conn.execute("insert into message (simulation_id) values (?)",(message.simuid,))
 
 def retrieve_last_message(simulation):
Index: /trunk/Monitoring/smon/repo_io.py
===================================================================
--- /trunk/Monitoring/smon/repo_io.py	(revision 865)
+++ /trunk/Monitoring/smon/repo_io.py	(revision 866)
@@ -28,4 +28,241 @@
 
 
+
+
+
+# -- methods -- #
+
+def init():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.connect()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		_CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer"
+		prodiguer_shared.connect(_CONNECTION)
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR004 - incorrect mode")
+
+def free():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.close()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		#prodiguer_shared.close()
+		pass
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR009 - incorrect mode")
+
+def test():
+	repo.create_message("test2", 2, "bla2")
+	commit()
+
+	repo.update_simulation_status('1pctCO22', 'ERROR')
+	commit()
+
+	repo.create_message("test3", 3, "bla3")
+	rollback()
+
+def commit():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.commit()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		elixir.session.commit()
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR002 - incorrect mode")
+
+def rollback():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.rollback()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		elixir.session.rollback()
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR003 - incorrect mode")
+
+def retrieve_simulation(name):
+	simulation=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		simulation=repo.retrieve_simulation(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		s=repo.retrieve_simulation(name)
+
+		# process return values
+		simulation=smon.types.Simulation(exec_start_date=s.ExecutionStartDate,exec_end_date=s.ExecutionEndDate,status=s.ExecutionState) # ExecutionState example: EXECUTION_STATE_RUNNING, EXECUTION_STATE_SET..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR014 - incorrect mode")
+
+	return simulation
+
+def delete_simulation(name):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.delete_simulation(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.delete_simulation(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR015 - incorrect mode")
+
+def create_simulation(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.create_simulation(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.create_simulation(activity)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR016 - incorrect mode")
+
+def update_simulation_status(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.update_simulation_status(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.update_simulation_status(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR017 - incorrect mode")
+
+def retrieve_messages(simulation):
+	message=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		message=repo.retrieve_messages(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.retrieve_messages(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR018 - incorrect mode")
+
+	return message
+
+def delete_messages(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.delete_messages(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.delete_messages(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR019 - incorrect mode")
+
+def create_message(message):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.create_message(message)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.create_message()
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR020 - incorrect mode")
+
+def retrieve_last_message(simulation):
+	message=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		message=repo.retrieve_last_message(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.retrieve_last_message(simulation)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR021 - incorrect mode")
+
+	return message
+
+
+# --- higher level methods --- #
+
+def get_running_simulations():
+	running_simulation=[]
+
+	for s in retrieve_simulation():
+		if s.status=="running":
+			running_simulation.append(s)
+			
+	return running_simulation
+
+
+# --- module init --- #
+
 CSTE_MODE_LOCAL_REPO="local_repo"
 CSTE_MODE_REMOTE_REPO="remote_repo"
@@ -46,234 +283,5 @@
 
 
-
-
-# -- methods -- #
-
-def init():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.connect()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		_CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer"
-		prodiguer_shared.connect(_CONNECTION)
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR004 - incorrect mode")
-
-def free():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.close()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		#prodiguer_shared.close()
-		pass
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR009 - incorrect mode")
-
-def test():
-	repo.create_message("test2", 2, "bla2")
-	commit()
-
-	repo.update_simulation_status('1pctCO22', 'ERROR')
-	commit()
-
-	repo.create_message("test3", 3, "bla3")
-	rollback()
-
-def commit():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.commit()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		elixir.session.commit()
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR002 - incorrect mode")
-
-def rollback():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.rollback()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		elixir.session.rollback()
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR003 - incorrect mode")
-
-def retrieve_simulation(name):
-	simulation=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		simulation=repo.retrieve_simulation(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		s=repo.retrieve_simulation(name)
-
-		# process return values
-		simulation=smon.types.Simulation(exec_start_date=s.ExecutionStartDate,exec_end_date=s.ExecutionEndDate,status=s.ExecutionState) # ExecutionState example: EXECUTION_STATE_RUNNING, EXECUTION_STATE_SET..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR014 - incorrect mode")
-
-    return simulation
-
-def delete_simulation(name):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.delete_simulation(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.delete_simulation(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR015 - incorrect mode")
-
-def create_simulation(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.create_simulation(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.create_simulation(activity)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR016 - incorrect mode")
-
-def update_simulation_status(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.update_simulation_status(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.update_simulation_status(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR017 - incorrect mode")
-
-def retrieve_messages(simulation):
-	message=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		message=repo.retrieve_messages(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.retrieve_messages(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR018 - incorrect mode")
-
-	return message
-
-def delete_messages(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.delete_messages(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.delete_messages(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR019 - incorrect mode")
-
-def create_message(message):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.create_message(message)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.create_message()
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR020 - incorrect mode")
-
-def retrieve_last_message(simulation):
-	message=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		message=repo.retrieve_last_message(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.retrieve_last_message(simulation)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR021 - incorrect mode")
-
-	return message
-
-
-# --- higher level methods --- #
-
-def get_running_simulations():
-	running_simulation=[]
-
-	for s in retrieve_simulation():
-		if s.status=="running":
-			running_simulation.append(s)
-			
-	return running_simulation
+# note that by putting init() call here, it will only be called when first imported by the first import statement
+init()
+
Index: /trunk/Monitoring/smon/types.py
===================================================================
--- /trunk/Monitoring/smon/types.py	(revision 865)
+++ /trunk/Monitoring/smon/types.py	(revision 866)
@@ -2,12 +2,12 @@
 
 ##################################
-#  @program        smon
+#  @program		   smon
 #  @description    simulation monitor
-#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
-#                             All Rights Reservedâ
-#  @svn_file       $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
-#  @version        $Rev: 2599 $
+#  @copyright	   Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#							  All Rights Reservedâ
+#  @svn_file	   $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
+#  @version		   $Rev: 2599 $
 #  @lastrevision   $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $
-#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+#  @license		   CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
 ##################################
 
@@ -25,35 +25,45 @@
 		self.msg=msg
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class Tree():
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		pass
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class Simulation():
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		self.exec_start_date=kw.get("exec_start_date")
 		self.exec_end_date=kw.get("exec_end_date")
 		self.status=kw.get("status")
+		self.name=kw.get("name")
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
+class Message():
+
+	def __init__(self,JSON_KW):
+		for key in JSON_KW:
+			setattr(self, key, JSON_KW[key])
+
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class SimulationTree(Tree):
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		dg = nx.DiGraph()
 
 	def update(cls):
 		dg.add_edge('a','b')
-
-	def print(cls):
-		print dg.edges()
+	
+	def print__TODO(cls):
+		print dg.edges() 
 
 	def write(cls):
@@ -63,12 +73,12 @@
 		dg = pickle.load(open('/tmp/graph.txt'))
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class SimulationTrees():
 
-    def __init__(self,**kw):
-        self.sample=kw.get("sample",[])
+	def __init__(self,**kw):
+		self.sample=kw.get("sample",[])
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
