@@ -75,11 +75,12 @@ class Runtime(abc.ABC):
75
75
TEMPLATES = ['config/runtime' , '/etc/kernelci/runtime' ]
76
76
77
77
# pylint: disable=unused-argument
78
- def __init__ (self , config , user = None , token = None , custom_template_dir = None ):
78
+ def __init__ (self , config , user = None , token = None , custom_template_dir = None , context = None ):
79
79
"""A Runtime object can be used to run jobs in a runtime environment
80
80
81
81
*config* is a kernelci.config.runtime.Runtime object
82
82
*custom_template_dir* is an optional custom directory for Jinja2 templates
83
+ *context* is an optional context object for passing program context
83
84
"""
84
85
self ._config = config
85
86
self ._templates = self .TEMPLATES .copy ()
@@ -225,21 +226,23 @@ def wait(self, job_object):
225
226
"""Wait for a job to complete and get the exit status code"""
226
227
227
228
228
- def get_runtime (config , user = None , token = None , custom_template_dir = None ):
229
+ def get_runtime (config , user = None , token = None , custom_template_dir = None , context = None ):
229
230
"""Get the Runtime object for a given runtime config.
230
231
231
232
*config* is a kernelci.config.runtime.Runtime object
232
233
*user* is the name of the user to connect to the runtime
233
234
*token* is the associated token to connect to the runtime
234
235
*custom_template_dir* is an optional custom directory for Jinja2 templates
236
+ *context* is an optional context object for passing program context
235
237
"""
236
238
module_name = '.' .join (['kernelci' , 'runtime' , config .lab_type ])
237
239
runtime_module = importlib .import_module (module_name )
238
240
return runtime_module .get_runtime (config , user = user , token = token ,
239
- custom_template_dir = custom_template_dir )
241
+ custom_template_dir = custom_template_dir ,
242
+ context = context )
240
243
241
244
242
- def get_all_runtimes (runtime_configs , opts , custom_template_dir = None ):
245
+ def get_all_runtimes (runtime_configs , opts , custom_template_dir = None , context = None ):
243
246
"""Get all the Runtime objects based on the runtime configs and options
244
247
245
248
This will iterate over all the runtimes configs and yield a (name, runtime)
@@ -249,6 +252,7 @@ def get_all_runtimes(runtime_configs, opts, custom_template_dir=None):
249
252
*runtime_configs* is the 'runtimes' config loaded from YAML
250
253
*opts* is an Options object loaded from the CLI args and settings file
251
254
*custom_template_dir* is an optional custom directory for Jinja2 templates
255
+ *context* is an optional context object for passing program context
252
256
"""
253
257
for config_name , config in runtime_configs .items ():
254
258
section = ('runtime' , config_name )
@@ -257,7 +261,8 @@ def get_all_runtimes(runtime_configs, opts, custom_template_dir=None):
257
261
for opt in ('user' , 'runtime_token' )
258
262
)
259
263
runtime = get_runtime (config , user = user , token = token ,
260
- custom_template_dir = custom_template_dir )
264
+ custom_template_dir = custom_template_dir ,
265
+ context = context )
261
266
yield config_name , runtime
262
267
263
268
0 commit comments