CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Expose unicon connection API through Genie.

RFC2516 opened this issue · comments

Feature Request

I would like to not be restricted to using a testbed file in my PyATS usage. The reason for this is because my environment is ephemeral. The connection details change from environment to environment. I personally would prefer not to create an intermediary script, and I suspect others would too, that writes the testbed script after ingesting local environment details. In my opinion a yaml testbed file is ideal for human to programmatic interaction, however a yaml testbed file is not ideal for environmental discovery and programmatic interaction. Such as workflow again in my opinion should remain in the python script. I also acknowledge the Netbox Plugin but it is simply not practical for local development environment.

Current Examples:

$ python
>>> from unicon import Connection
>>> dev = Connection(hostname='R1', start=['ssh admin@clab-bgp-R1'], credentials={'default': {'username': 'admin', 'password': 'admin'}}, os='iosxe')
>>> (omitted output for brevity)
>>> 
>>> dev. # tab tab to expose auto-complete options
Display all 101 possibilities? (y or n)
dev.acquire(                    dev.connection_type             dev.guestshell(                 dev.log                         dev.parse_spawn_command(        dev.release(                    dev.state_machine_class(
dev.add_service(                dev.context                     dev.hostname                    dev.log_buffer                  dev.patch_service_attributes(   dev.reload(                     dev.subcommand_list(
dev.alias                       dev.copy(                       dev.init_config_commands        dev.log_file(                   dev.ping(                       dev.role                        dev.switchto(
(omitted output for brevity)
>>> # This object is missing methods from the other pyATS family of libraries such as "parsed" from Genie.

vs.

$ python
>>> from genie import testbed
>>>
>>> testbed. # tab tab to expose auto-complete options
testbed.Genie(  testbed.load(
>>>
>>> tb = testbed.load('testbed.yaml')
>>>
>>> device = tb.devices['R1']
>>> device.connect()
>>> (output omitted for brevity)
>>> device. # tab tab to expose auto-complete options
Display all 159 possibilities? (y or n)
device.CFG_TOPOLOGY_CLASS                device.custom                            device.init_state_machine(               device.obj_state                         device.roles
device.ENTRY_POINT_NAME                  device.custom_config_cli                 device.instantiate(                      device.origin                            device.rommon(
device.acquire(                          device.custom_unconfig_cli               device.instantiate_pool(                 device.os                                device.send(
device.add_feature(                      device.debug                             device.interfaces                        device.os_flavor                         device.sendline(
(output omitted for brevity)

Story

A Network Engineer is working on a proposed change to the infrastructure. They create a repository on their local, initialize git, use ansible for their configuration management, they also create a virtualization environment / orchestration tool definition yaml file, and now they need to write unit tests to prove their change is acceptable as well as providing the same test files that will move into production to allow for continuous testing of the new feature.

These inventory files, testbeds and etc. must survive being deployed into different environments.

Proposed experience of exposed unicon connection API

$ python
>>> from genie import testbed
>>>
>>> testbed. # tab tab to expose auto-complete options
testbed.Genie(  testbed.load( testbed.unicon(
>>>
>>> tb = testbed.unicon(hostname='R1', start=['ssh admin@clab-bgp-R1'], credentials={'default': {'username': 'admin', 'password': 'admin'}}, os='iosxe')
>>> r1 = tb.devices['R1']
>>> r1.connect()
>>> r1.parsed('show ip int bri')

Hi , I am looking at your ticket and reviewing it, Please let me know are you facing the issue still or not ?

Yes,

Less of an issue and more of a request for a new feature 😊

I did import the latest pyats[full] package and confirmed the feature is not there.

As we currently not supporting, we will add to backlog for support as per priority of customer need to resolve the issue you are facing in future. If you need further assistance, please let me know and I'll do my best to provide additional guidance.