-
Notifications
You must be signed in to change notification settings - Fork 13
Improvements from user feedback #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
481c5af
cb41df3
b082cee
9ce9776
a207555
5dd625f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
test: | ||
mkdir -p .pyATS | ||
docker run -it --rm -v $(PWD):/tests ciscotestautomation/pyats bash /tests/run_tests.sh | ||
docker run -it -e PYATS_USERNAME -e PYATS_PASSWORD -e PYATS_AUTH_PASS --rm -v $(PWD):/tests ciscotestautomation/pyats bash /tests/run_tests.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import sys | ||
from IPython import embed | ||
import logging | ||
import unicon | ||
|
||
from genie.conf import Genie | ||
from ats.topology import loader | ||
from genie.abstract import Lookup | ||
from genie.libs import ops # noqa | ||
|
||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# local imports | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description="standalone parser") | ||
parser.add_argument('--testbed', default='./default_testbed.yaml', | ||
dest='testbed', type=loader.load) | ||
parser.add_argument('--device', dest='device_name') | ||
|
||
args, unknown = parser.parse_known_args() | ||
|
||
device_name = args.device_name | ||
|
||
# pyats testbed != genie testbed | ||
genie_testbed = Genie.init(args.testbed) | ||
|
||
# this gives us device_name as Device Object e.g dist1 | ||
vars()[device_name] = genie_testbed.devices[device_name] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the more appropriate way would be to do locals() but then again - device_name could have a dash, then it's an inappropriate variable name. i would suggest to not show this part. it will definitely confuse novice users |
||
# or we can also just use `device` | ||
device = vars()[device_name] | ||
|
||
# logger = logging.getLogger("UNICON") | ||
# unicon.logs.remove_stream_handler(logging) | ||
|
||
# connect to the device (quietly) | ||
import time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imports on top or on top of if name == 'main' is good practise imo |
||
print("pyATS and Genie are about to profile the device and create structured data for " | ||
"you to use") | ||
time.sleep(10) | ||
device.connect() | ||
|
||
|
||
# work with an abstracted device model | ||
abstract = Lookup.from_device(device) | ||
|
||
# interface info is always a good place to start.. | ||
interfaces = abstract.ops.interface.interface.Interface(device) | ||
interfaces.learn() | ||
|
||
print(""" | ||
|
||
Welcome to the device object tutorial, as you may have noticed, Genie was | ||
busy profiling all of the interfaces of your device. you can access them via | ||
|
||
interfaces.info | ||
|
||
you can interact with your device using either `device` or the device name | ||
you specified with --device | ||
|
||
You can start by exploring some of the common operations available for the | ||
device by typing | ||
|
||
dir(device) | ||
|
||
you can also explore the rest of the genie models at: | ||
|
||
https://pubhub.devnetcloud.com/media/pyats-packages/docs/genie/genie_libs/#/models | ||
|
||
Enjoy! | ||
|
||
""") | ||
|
||
|
||
embed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is intended for pyats v5.0+ -> all the imports should reflect
from pyats.topology instead... but this is a minor comment