@@ -125,8 +125,24 @@ async def interoperability_production_start(
125
125
)
126
126
iris = ctx .request_context .lifespan_context ["iris" ]
127
127
raise_on_error (
128
- iris , iris .classMethodString ("Ens.Director" , "StartProduction" , name )
128
+ iris ,
129
+ iris .classMethodString (
130
+ "Ens.Director" , "StartProduction" , * ([name ] if name else [])
131
+ ),
129
132
)
133
+ refname = IRISReference (iris )
134
+ name and refname .setValue (name )
135
+ refstatus = IRISReference (iris )
136
+ status = iris .classMethodString (
137
+ "Ens.Director" , "GetProductionStatus" , refname , refstatus
138
+ )
139
+ if not name :
140
+ name = refname .getValue ()
141
+ if (
142
+ status != "1"
143
+ or ProductionStatus (int (refstatus .getValue ())) != ProductionStatus .Running
144
+ ):
145
+ raise ValueError (f"Production { name } not started." )
130
146
return "Started production"
131
147
132
148
@server .tool (description = "Stop an Interoperability Production" )
@@ -139,7 +155,9 @@ async def interoperability_production_stop(
139
155
iris = ctx .request_context .lifespan_context ["iris" ]
140
156
raise_on_error (
141
157
iris ,
142
- iris .classMethodString ("Ens.Director" , "StopProduction" , timeout , force ),
158
+ iris .classMethodString (
159
+ "Ens.Director" , "StopProduction" , timeout or 10 , force
160
+ ),
143
161
)
144
162
return "Stopped production"
145
163
@@ -212,3 +230,16 @@ async def interoperability_production_logs(
212
230
for row in cur .fetchall ():
213
231
logs .append (f"{ row [0 ]} { row [1 ]} { row [2 ]} { row [3 ]} " )
214
232
return "\n " .join (logs )
233
+
234
+ @server .tool (description = "Get Interoperability Production queues" )
235
+ async def interoperability_production_queues (
236
+ ctx : Context ,
237
+ ) -> str :
238
+ queues = []
239
+ db = ctx .request_context .lifespan_context ["db" ]
240
+ with db .cursor () as cur :
241
+ sql = "select * from Ens.Queue_Enumerate()"
242
+ cur .execute (sql )
243
+ rows = cur .fetchall ()
244
+ queues = [", " .join ([f"{ cell } " for cell in row ]) for row in rows ]
245
+ return "\n " .join (queues )
0 commit comments