@@ -907,7 +907,21 @@ class mc_synchro_policy( object ):
907907 else :
908908 if niovs > 0 :
909909 ret = False
910- logging .warning ('%s The destination tag is frozen - no iov can be altered.' % niovs )
910+ logging .warning ('The destination tag is frozen - no iov can be added.' )
911+ return ret , new_iovs
912+
913+ class runmc_synchro_policy ( object ):
914+ def __init__ (self , session1 , session2 , timeType , destTag ):
915+ self .lastFrozenSince = _get_last_frozen_since ( session2 , destTag )
916+
917+ def validate ( self , iovs ):
918+ new_iovs = {}
919+ niovs = len (iovs )
920+ ret = True
921+ if self .lastFrozenSince is not None :
922+ if niovs > 0 :
923+ ret = False
924+ logging .warning ('The destination tag is frozen - no iov can be added.' )
911925 return ret , new_iovs
912926
913927class offline_synchro_policy ( object ):
@@ -938,12 +952,24 @@ class no_synchro_policy( object ):
938952
939953_synchro_map = { 'hlt' : hlt_synchro_policy , 'express' : hlt_synchro_policy , 'prompt' : prompt_synchro_policy , 'pcl' :pcl_synchro_policy ,
940954 'mc' : mc_synchro_policy , 'offline' : offline_synchro_policy , 'any' :no_synchro_policy , 'validation' :no_synchro_policy ,
941- 'runmc' : offline_synchro_policy }
955+ 'runmc' : runmc_synchro_policy }
942956def _get_synchro_policy ( synchronization ):
943957 if synchronization not in _synchro_map .keys ():
944958 raise Exception ('Cannot handle synchronization %s' % synchronization )
945959 return _synchro_map [synchronization ]
946960
961+ def mc_validate ( session , tag ):
962+ IOV = session .get_dbtype (conddb .IOV )
963+ niovs = session .query (IOV ).filter (IOV .tag_name == tag ).count ()
964+ if niovs > 1 :
965+ logging .error ('Validation of tag content for synchronization "mc" failed: more than one IOV found.' )
966+ return False
967+ if niovs > 0 :
968+ r = int (session .query (IOV .since ).filter (IOV .tag_name == tag ).one ()[0 ])
969+ if r != 1 :
970+ logging .error ('Validation of tag content for synchronization "mc" failed: IOV since=%s (expected=1)' % r )
971+ return False
972+ return True
947973
948974def listTags_ (args ):
949975 connection = connect (args )
@@ -2175,6 +2201,10 @@ def edit(args):
21752201 if header [0 ] != new_header [0 ]:
21762202 action += 'Description updated'
21772203 if header [1 ] != new_header [1 ]:
2204+ # validate the synchro requested( based on the tag IOV content )
2205+ if new_header [1 ] == 'mc' :
2206+ if not mc_validate ( session , name ):
2207+ return
21782208 if len (action ): action += ', '
21792209 action += 'Synchronization changed'
21802210 if header [2 ] != new_header [2 ]:
0 commit comments