1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-30 18:51:24 +00:00
dockerfiles/ndscheduler/data/jobs/shell_job.py
2020-05-22 14:17:38 +08:00

31 lines
918 B
Python

"""A job to run executable programs."""
from subprocess import call
from ndscheduler import job
class ShellJob(job.JobBase):
@classmethod
def meta_info(cls):
return {
'job_class_string': '%s.%s' % (cls.__module__, cls.__name__),
'notes': ('This will run an executable program. You can specify as many '
'arguments as you want. This job will pass these arguments to the '
'program in order.'),
'arguments': [
{'type': 'string', 'description': 'Executable path'}
],
'example_arguments': '["/usr/local/my_program", "--file", "/tmp/abc", "--mode", "safe"]'
}
def run(self, *args, **kwargs):
return {'returncode': call(args)}
if __name__ == "__main__":
# You can easily test this job here
job = ShellJob.create_test_instance()
job.run('ls', '-l')