-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathjob.py
42 lines (34 loc) · 1.43 KB
/
job.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''
To run the job:
$ pyats run job job.py --testbed-file <testbed_file.yaml>
Additional CLI Arguments:
--no-parallel-connect: disables parallel device connection
--crc-threshold: max crc interface error before it's called to be a failure
Example:
$ pyats run job job.py --testbed-file ../devnet_sandbox.yaml --crc-threshold 100 --no-parallel-connect
'''
import os
import argparse
# command line argument parser
# see https://pubhub.devnetcloud.com/media/pyats/docs/easypy/jobfile.html#custom-arguments
parser = argparse.ArgumentParser()
parser.add_argument('--no-parallel-connect',
dest = 'p_connect',
action='store_false',
default = True,
help = 'disable connecting to devices in parallel')
parser.add_argument('--crc-threshold',
dest = 'crc_threshold',
default = 0,
type = int,
help = 'threshold at which interface CRC will be considered'
'fail')
def main(runtime):
# parse command line arguments
# only parse arguments we know
args, _ = parser.parse_known_args()
# Find the location of the script in relation to the job file
testscript = os.path.join(os.path.dirname(__file__), 'script.py')
# run script, pass arguments to script as parameters
runtime.tasks.run(testscript=testscript,
**vars(args))