diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .gitingore | 0 | ||||
-rw-r--r-- | execs/ubuntu-build-essential.yaml | 1 | ||||
-rwxr-xr-x | post.py | 51 |
4 files changed, 53 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fee9217 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.conf diff --git a/.gitingore b/.gitingore deleted file mode 100644 index e69de29..0000000 --- a/.gitingore +++ /dev/null diff --git a/execs/ubuntu-build-essential.yaml b/execs/ubuntu-build-essential.yaml index b7f3a9b..a30acf7 100644 --- a/execs/ubuntu-build-essential.yaml +++ b/execs/ubuntu-build-essential.yaml @@ -38,3 +38,4 @@ install: - sudo - bison - flex + - libpcap-dev @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 + +import sys +import yaml +#import xmlrpclib +import xmlrpc.client +import configparser + +configfile = "post.conf" + +def get_cfg_value(configfile, category, what, strict = 'yes'): + ret = None + parser = configparser.SafeConfigParser() + + parser.read(configfile) + try: + ret = parser.get(category, what) + except: + print('No option %s= found in config file. Fix your config file' % what) + if strict == 'yes': + exit(1); + + return ret + +def submit_yaml_job(job_yaml_str, user, token, host): + server = xmlrpc.client.ServerProxy("https://%s:%s@%s/RPC2" % (user, token, + host)) + try: + job_id = server.scheduler.submit_job(job_yaml_str) + #print "Job submitted successfuly" + except: + raise + + +def main(): + if len(sys.argv) < 1: + print ("""usage: submit_job.py JOB_YAML""") + exit(1) + + with open(sys.argv[1], 'r') as stream: + job_yaml = stream.read() + + user = get_cfg_value(configfile, 'auth', 'user') + token = get_cfg_value(configfile, 'auth', 'token') + host = get_cfg_value(configfile, 'auth', 'host') + for count in range(0, 2): + submit_yaml_job(job_yaml, user, token, host) + + +if __name__ == "__main__": + main() |