CiscoTestAutomation / genielibs

genie.libs contains libraries for configuring, retrieving and testing topologies
Apache License 2.0
109 stars 55 forks source link

Genie CLI makes config changes to line console and line default on IOSXR #8

Closed pwoconnor closed 5 years ago

pwoconnor commented 5 years ago

Everytime Genie connects to a IOSXR device it makes configuration changes the line console and line default. Is there a way to turn that feature off?

RP/0/RSP0/CPU0:LAB-9010#
[2019-04-19 22:07:20,843] +++ initializing handle +++
[2019-04-19 22:07:20,844] +++ LAB-9010: executing command 'terminal length 0' +++
terminal length 0
Fri Apr 19 22:07:21.002 CDT
RP/0/RSP0/CPU0:LAB-9010#
[2019-04-19 22:07:21,093] +++ LAB-9010: executing command 'terminal width 0' +++
terminal width 0
Fri Apr 19 22:07:21.236 CDT
RP/0/RSP0/CPU0:LAB-9010#
[2019-04-19 22:07:21,312] +++ LAB-9010: config +++
configure terminal
Fri Apr 19 22:07:21.458 CDT
RP/0/RSP0/CPU0:LAB-9010(config)#no logging console
RP/0/RSP0/CPU0:LAB-9010(config)#line console
RP/0/RSP0/CPU0:LAB-9010(config-line)#exec-timeout 0 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#absolute-timeout 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#session-timeout 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#line default
RP/0/RSP0/CPU0:LAB-9010(config-line)#exec-timeout 0 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#absolute-timeout 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#session-timeout 0
RP/0/RSP0/CPU0:LAB-9010(config-line)#commit

Fri Apr 19 22:07:23.373 CDT
RP/0/RSP0/CPU0:LAB-9010(config-line)#end
RP/0/RSP0/CPU0:LAB-9010#
jeaubin commented 5 years ago

Yes you can deactivate them

https://pubhub.devnetcloud.com/media/pyats-packages/docs/unicon/user_guide/connection.html

device.connect(init_exec_commands=[], init_config_commands=[])

These will remove all initial command send when connecting.

pwoconnor commented 5 years ago

Thanks jeaubin, but that is for creating pyats connections. My question is specifically about GenieCLI which works off of a yaml file with connection parameters. Now I would assume that I need what you linked, but I am not sure where they would go in the testbed yaml file.

jeaubin commented 5 years ago

I see;

I'll need to do some test on my side first to make sure it works as expected. I'll be back in the office on Tuesday.

jeaubin commented 5 years ago

We will release a new version of Unicon to allows this. The planned released is for next Tuesday.

Thanks for reporting it!

pwoconnor commented 5 years ago

Any news on the release for Unicon to alleviate this issue?

karmoham commented 5 years ago

Hi Patrick,

We released unicon version 19.4.0 so please upgrade the package and let us know if it solves your issues.

pip install --upgrade unicon

Thanks, Karim

pwoconnor commented 5 years ago

New update does the same thing I reported, when running genie learn, When the session is connected. The program goes straight into config mode and commits various timeout values for line console and line default.

karmoham commented 5 years ago

@jeaubin to comment

jeaubin commented 5 years ago

Hi @pwoconnor , Sorry for the delay, I've done the enhancement, however, there has been some issue with the release. We are currently in Business trip; I'll publish it once we come back, early next week.

pwoconnor commented 5 years ago

Ok thanks for the update!

pwoconnor commented 5 years ago

Hi @jeaubin Do you still plan on releasing this week?

jeaubin commented 5 years ago

Hi @pwoconnor , it is now released as a beta package!

Sorry for the delay, Here how to get the latest version

pip install unicon --upgrade --pre

(--pre for beta packages)

And here how to set it up in your yaml files

devices:
  nx-osv-1:
      type: 'router'
      os: 'nxos'
      alias: 'uut'
      tacacs:
          login_prompt: "login:"
          password_prompt: "Password:"
          username: "admin"
      passwords:
          tacacs: admin
          enable: admin
          line: admin
      connections:
          defaults:
            class: 'unicon.Unicon'
          cli:
              protocol: telnet
              init_exec_commands: []
              init_config_commands: []
              ip: "1.1.1.1"
              port: 17036
pwoconnor commented 5 years ago

Awesome, Thanks @jeaubin !!! That has resolved my issue. I truly appreciate it!.

theotherswan commented 5 years ago

So at this, can we run pip install --upgrade unicon, or

we still have to use the beta package and run pip install unicon --upgrade --pre

Thank you so much pwoconnor for bring this issue up.

jeaubin commented 5 years ago

@theotherswan - Unicon has been released with this enhancement. You can just do

pip install --upgrade unicon

theotherswan commented 5 years ago

Thank you jeaubin. So with the upgrade we still need to build our testbed file as follow:

devices: nx-osv-1: type: 'router' os: 'nxos' alias: 'uut' tacacs: login_prompt: "login:" password_prompt: "Password:" username: "admin" passwords: tacacs: admin enable: admin line: admin connections: defaults: class: 'unicon.Unicon' cli: protocol: telnet init_exec_commands: [] init_config_commands: [] ip: "1.1.1.1" port: 17036

in order to prevent Genie CLI from changing the device's config, correct? Thank you.

jeaubin commented 5 years ago

Yes thats correct.

theotherswan commented 5 years ago

Hi jeaubin, I have about 500 Cisco devices. I can export them from Cisco Prime 3.3 to obtain the following CSV format inventory:

Device FQDN | IP | Device Type device_a.domain | 1.1.1.1 | Cisco Nexus 7700 10-slot device_b.domain | 2.2.2.2 | Cisco Catalyst 6509

Do you have a sample python code to convert this inventory list into a YAML testbed file below?

devices: nx-osv-1: type: 'router' os: 'nxos' alias: 'uut' tacacs: login_prompt: "login:" password_prompt: "Password:" username: "admin" passwords: tacacs: admin enable: admin line: admin connections: defaults: class: 'unicon.Unicon' cli: protocol: ssh init_exec_commands: [] init_config_commands: [] ip: "1.1.1.1" port: 22

I think I would have to convert above Device Type to something Genie CLI would understand (i.e. nxos, ios, etc.). Do you have a link to the official Device Type for all Cisco devices? Thank you so much.