@@ -138,6 +138,8 @@ def migrate(node: Node, old_version: str, new_version: str) -> int:
138138 return migrate_3_12 (node )
139139 elif old_version == 'v3.12' and new_version == 'v3.13' :
140140 return migrate_3_13 (node )
141+ elif old_version == 'v3.14' and new_version == 'v3.15' :
142+ return migrate_3_15 (node )
141143 return 0
142144
143145def migrate_3_11 (node : Node ) -> int :
@@ -162,10 +164,15 @@ def migrate_3_11(node: Node) -> int:
162164
163165
164166def migrate_3_12 (node : Node ) -> int :
167+ filename = os .path .join (node .config_dir , 'services' , 'scheduler.yaml' )
168+ if os .path .exists (filename ):
169+ shutil .move (filename , os .path .join (node .config_dir , 'services' , 'core.yaml' ))
170+
165171 filename = os .path .join (node .config_dir , 'main.yaml' )
166172 if not os .path .exists (filename ):
167173 node .log .error ('main.yaml not found. Exiting.' )
168174 return - 2
175+
169176 with open (filename , mode = 'r' , encoding = 'utf-8' ) as infile :
170177 data = yaml .load (infile )
171178 if 'ovgme' in data .get ('opt_plugins' , []):
@@ -195,9 +202,6 @@ def migrate_3_12(node: Node) -> int:
195202 yaml .dump (data , outfile )
196203 node .log .info (" => node.yaml auto-migrated, please check" )
197204 return - 1
198- filename = os .path .join (node .config_dir , 'services' , 'scheduler.yaml' )
199- if os .path .exists (filename ):
200- shutil .move (filename , os .path .join (node .config_dir , 'services' , 'core.yaml' ))
201205 return 0
202206
203207
@@ -216,6 +220,33 @@ def migrate_3_13(node: Node) -> int:
216220 shutil .move (file , new_file )
217221 return 0
218222
223+
224+ def migrate_3_15 (node : Node ) -> int :
225+ file = Path (os .path .join (node .config_dir , 'nodes.yaml' ))
226+ nodes = yaml .load (file .read_text (encoding = 'utf-8' ))
227+ data = nodes [node .name ]
228+ dirty = False
229+ if isinstance (data .get ('DCS' , {}).get ('autoupdate' ), dict ):
230+ data ['DCS' ]['announce' ] = data ['DCS' ].pop ('autoupdate' )
231+ data ['DCS' ]['autoupdate' ] = True
232+ dirty = True
233+
234+ for name , extension in data ['extensions' ].items ():
235+ if name not in ['SRS' , 'LotAtc' ]:
236+ continue
237+ if isinstance (extension .get ('autoupdate' ), dict ):
238+ extension ['announce' ] = extension .pop ('autoupdate' )
239+ extension ['autoupdate' ] = True
240+ dirty = True
241+
242+ if dirty :
243+ with open (file , mode = 'w' , encoding = 'utf-8' ) as outfile :
244+ yaml .dump (nodes , outfile )
245+ node .log .info (" => node.yaml auto-migrated, please check" )
246+ return - 1
247+ return 0
248+
249+
219250def migrate_3 (node : str ):
220251 cfg = ConfigParser ()
221252 cfg .read ('config/default.ini' , encoding = 'utf-8' )
0 commit comments