-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpyats_ios_example_job.py
62 lines (46 loc) · 1.72 KB
/
pyats_ios_example_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/env python
'''pyats_ios_example_job.py
This is an easypy job example intended to run the pyATS IOS example testscript.
Arguments:
This script requires one script argument (testbed_file) and two optional
script argument (ios1 and ios2) to be passed in when run under easypy for
demonstration purposes.
testbed_file: the path to testbed yaml file
ios1: the device name defined in the testbed yaml file, if modified
ios2: the device name defined in the testbed yaml file, if modified
Examples:
# to run under easypy
bash$ easypy pyats_ios_example_job.py -testbed_file pyats_ios_example.yaml
References:
For the complete and up-to-date user guide on pyATS, visit:
https://developer.cisco.com/site/pyats/docs/
'''
#
# optional author information
#
__author__ = 'Wei Chen <[email protected]>'
__copyright__ = 'Copyright 2017, Cisco Systems'
__email__ = '[email protected]'
__date__= 'Nov 15, 2017'
#
# import statements
#
import os
import logging
import argparse
from ats.easypy import run
# easypy allows argument propagations
# any unrecognized is left behind to allow custom parsers to handle
parser = argparse.ArgumentParser()
parser.add_argument('--ios1', dest = 'ios1_name', type = str, default = 'ios1')
parser.add_argument('--ios2', dest = 'ios2_name', type = str, default = 'ios2')
def main():
# parse args
args, unknown = parser.parse_known_args()
# configure your log outputs level
#logging.getLogger('ats.connections').setLevel('DEBUG')
# Find the location of the script in relation to the job file
test_path = os.path.dirname(os.path.abspath(__file__))
testscript = os.path.join(test_path, 'pyats_ios_example.py')
# run it
run(testscript, **vars(args))