Coder Social home page Coder Social logo

virlutils's Introduction

virlutils

Build Status Coverage Status PyPI version

A collection of utilities for interacting with Cisco Modeling Labs (CML) v2.0+.

virl up / cml up

virl (or cml) is a devops style cli which supports the most common VIRL/CML operations. Adding new ones is easy...

Usage: cml [OPTIONS] COMMAND [ARGS]...

Options:
  --debug / --no-debug  Print any debugging output.
  --help                Show this message and exit.

Commands:
  clear        clear the current lab ID
  cockpit      opens the Cockpit UI
  command      send a command or config to a node (requires pyATS)
  console      console for node
  definitions  manage image and node definitions
  down         stop a lab
  extract      extract configurations from all nodes in a lab
  generate     generate inv file for various tools
  id           get the current lab title and ID
  license      work with product licensing
  ls           lists running labs and optionally those in the cache
  nodes        get node list for the current lab
  pull         pull topology.yaml from repo
  rm           remove a lab
  save         save lab to a local yaml file
  search       list topologies available via github
  ssh          ssh to a node
  start        start a node
  stop         stop a node
  telnet       telnet to a node
  tmux         console to all nodes using tmux
  ui           opens the Workbench for the current lab
  up           start a lab
  use          use lab launched elsewhere
  version      version information
  wipe         wipe a lab or nodes within a lab

Prerequisites

  • Python 3.8+ (tested with Python 3.8, 3.9, 3.10, 3.11 and 3.12)

Installation

1.Clone this repo

git clone https://github.com/CiscoDevNet/virlutils
cd virlutils

2.Either (2a) use pip, or (2b) use setup.py

2a. Use pip

pip install cmlutils

Or

pip install virlutils

2b. Use setup.py

python3 -m venv venv
source venv/bin/activate
python setup.py install

Configuration

There really isn't much to configure, just set your CML credentials. There are a few different ways to accomplish this, pick whichever one works best for you. The options listed below are in the preferred order.

.virlrc in working directory

Add a .virlrc to the working directory, this will always be checked first and is useful when you want to override one or more parameters for a particular project directory.

The contents would look something like this.

VIRL_HOST=specialvirlserver.foo.com

environment variables

You can also add them as environment variables. This is useful if you want to override the global VIRL settings.

export VIRL_HOST=192.0.2.100
export VIRL_USERNAME=admin
export VIRL_PASSWORD=admin123

.virlrc in your home directory

Configure VIRL credentials globally by putting them in ~/.virlrc the formatting

VIRL_USERNAME=netadmins
VIRL_PASSWORD=cancodetoo!

Other configuration options

In addition to basic credentials, the following configuration options are supported using any of the methods mentioned previously

  • VIRL_TELNET_COMMAND - allows the user to customize the telnet command that is called. This command will be passed the host/ip information from the running simulation

    Example:

    export VIRL_TELNET_COMMAND="mytelnet {host}"
  • VIRL_SSH_COMMAND - allows the user to customize the ssh command that is called. This command will be passed the host/ip as well as the username from the running simulation

    Example:

    export VIRL_SSH_COMMAND="myssh {username}@{host}"
  • CML_VERIFY_CERT - The path to a PEM-encoded certificate file to use to verify the CML controller VM's SSL certificate. If you do not wish to verify the certificate, set this to "False"

    Example:

    export CML_VERIFY_CERT=/etc/certs/ca_bundle.pem
  • CML_CONSOLE_COMMAND - allows the user to customize the SSH command that is called.

    This command will be passed the CML controller VM IP, the console path of the node, and the CML controller username (note: you may have to force a TTY allocation in your SSH command)

    Example:

    export CML_CONSOLE_COMMAND="myssh {user}@{host} {console}"
  • CML_PLUGIN_PATH - A delimiter-separated list of directories in which to find cmlutils plugins. See the plugin documentation for more details. By default, the plugins directory in the current .virl directory will be searched.

    Example:

    export CML_PLUGIN_PATH="~/cmlutils/plugins:/opt/cmlutils/plugins"

Why so many choices??!?

Understanding the precedence allows you to do some pretty cool things.

Assume the following directory structure...

.
├── dev
│   ├── .virlrc
│   └── topology.yaml
├── prod
│   ├── .virlrc
│   └── topology.yaml
└── test
    ├── .virlrc
    └── topology.yaml

This allows three major benefits.

  1. you can easily use different credentials/servers for various environments
  2. you can customize your lab .yaml files to include different tags, different node configurations, etc.
  3. you have a badass workflow.
$ cml ls
Labs on Server
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
|        |                                |                         |                 |         |         |              |
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛
$ cd ../test
$ cml ls
Labs on Server
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
│ 7c2cf3 │ Small Branch Test              │                         │ STARTED         │       9 │       8 │           23 │
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛
$ cd ../prod
$ cml ls
Running Simulations
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
│ 7c2cf3 │ Small Branch Prod              │                         │ STARTED         │       9 │       8 │           23 │
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛

Usage / Workflows

Basic Workflow

in the absence of better documentation, here's a sample workflow

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml ls
Labs on Server
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
│ 02f6c6 │ CCIE Enterprise Infrastructure │                         │ DEFINED_ON_CORE │      54 │      67 │          216 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 332eab │ Branch Test                    │                         │ DEFINED_ON_CORE │       6 │       5 │           15 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 7c2cf3 │ Small Branch                   │                         │ STOPPED         │       9 │       8 │           23 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ e5afaf │ Dynamic Split Tunnel           │                         │ STOPPED         │      10 │       9 │           36 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 66defd │ Lab at Tue 14:45 PM            │                         │ STOPPED         │       2 │       1 │            6 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ bc518e │ Lab at Wed 21:39 PM            │                         │ STOPPED         │       9 │       1 │           26 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 0e1bb2 │ DFN                            │ German Research Network │ DEFINED_ON_CORE │      51 │      80 │          211 │
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml id
Small Branch (ID: 7c2cf3)

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml up
Lab Small Branch (ID: 7c2cf3) is already set as the current lab
Starting lab Small Branch (ID: 7c2cf3)


[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml ls
Labs on Server
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
│ 02f6c6 │ CCIE Enterprise Infrastructure │                         │ DEFINED_ON_CORE │      54 │      67 │          216 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 332eab │ Branch Test                    │                         │ DEFINED_ON_CORE │       6 │       5 │           15 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 7c2cf3 │ Small Branch                   │                         │ STARTED         │       9 │       8 │           23 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ e5afaf │ Dynamic Split Tunnel           │                         │ STOPPED         │      10 │       9 │           36 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 66defd │ Lab at Tue 14:45 PM            │                         │ STOPPED         │       2 │       1 │            6 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ bc518e │ Lab at Wed 21:39 PM            │                         │ STOPPED         │       9 │       1 │           26 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 0e1bb2 │ DFN                            │ German Research Network │ DEFINED_ON_CORE │      51 │      80 │          211 │
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛


[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml nodes
Here is a list of nodes in this lab
╒══════╤════════════════╤════════════════════╤═════════╤══════════╤══════════════════╕
│ ID   │ Label          │ Type               │ State   │ Wiped?   │ L3 Address(es)   │
╞══════╪════════════════╪════════════════════╪═════════╪══════════╪══════════════════╡
│ n0   │ branch-rtr     │ csr1000v           │ BOOTED  │ False    │ 192.168.10.219   │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n1   │ Internet       │ external_connector │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n2   │ branch-sw      │ iosvl2             │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n3   │ client-desktop │ desktop            │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n4   │ WAN Link 1     │ wan_emulator       │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n5   │ rtr-2          │ iosv               │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n8   │ ext-conn-1     │ external_connector │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n6   │ trex-0         │ trex               │ BOOTED  │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n7   │ VLAN 10        │ external_connector │ BOOTED  │ False    │                  │
╘══════╧════════════════╧════════════════════╧═════════╧══════════╧══════════════════╛


[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml console branch-rtr
[email protected]'s password:
Connecting to console for
Connected to terminalserver.
Escape character is '^]'.

branch-rtr#
branch-rtr#
branch-rtr#
branch-rtr#


[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml down
Shutting down lab Small Branch (ID: 7c2cf3).....
SUCCESS

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml ls
Labs on Server
╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕
│ ID     │ Title                          │ Description             │ Status          │   Nodes │   Links │   Interfaces │
╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡
│ 02f6c6 │ CCIE Enterprise Infrastructure │                         │ DEFINED_ON_CORE │      54 │      67 │          216 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 332eab │ Branch Test                    │                         │ DEFINED_ON_CORE │       6 │       5 │           15 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 7c2cf3 │ Small Branch                   │                         │ STOPPED         │       9 │       8 │           23 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ e5afaf │ Dynamic Split Tunnel           │                         │ STOPPED         │      10 │       9 │           36 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 66defd │ Lab at Tue 14:45 PM            │                         │ STOPPED         │       2 │       1 │            6 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ bc518e │ Lab at Wed 21:39 PM            │                         │ STOPPED         │       9 │       1 │           26 │
├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤
│ 0e1bb2 │ DFN                            │ German Research Network │ DEFINED_ON_CORE │      51 │      80 │          211 │
╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml use --lab-name "Small Branch"

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml nodes
Here is a list of nodes in this lab
╒══════╤════════════════╤════════════════════╤═════════╤══════════╤══════════════════╕
│ ID   │ Label          │ Type               │ State   │ Wiped?   │ L3 Address(es)   │
╞══════╪════════════════╪════════════════════╪═════════╪══════════╪══════════════════╡
│ n0   │ branch-rtr     │ csr1000v           │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n1   │ Internet       │ external_connector │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n2   │ branch-sw      │ iosvl2             │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n3   │ client-desktop │ desktop            │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n4   │ WAN Link 1     │ wan_emulator       │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n5   │ rtr-2          │ iosv               │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n8   │ ext-conn-1     │ external_connector │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n6   │ trex-0         │ trex               │ STOPPED │ False    │                  │
├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤
│ n7   │ VLAN 10        │ external_connector │ STOPPED │ False    │                  │
╘══════╧════════════════╧════════════════════╧═════════╧══════════╧══════════════════╛

Console to All Nodes with tmux

If you are a tmux user you can console to all nodes with the following command:

❯ cml tmux --help
Usage: cml tmux [OPTIONS]

  console to all nodes using tmux

Options:
  --group [panes|windows]  'panes': group all nodes in one window, 'windows':
                           one node per window  [default: panes]
  --help                   Show this message and exit.

❯ cml nodes
Here is a list of nodes in this lab
╒══════════════════════════════════════╤════════════════════╤════════════════════╤════════════════╤═════════╤══════════╤══════════════════╕
│ ID                                   │ Label              │ Type               │ Compute Node   │ State   │ Wiped?   │ L3 Address(es)   │
╞══════════════════════════════════════╪════════════════════╪════════════════════╪════════════════╪═════════╪══════════╪══════════════════╡
│ 5fdb38b6-7ff7-4792-b685-5eeaa41d8865 │ c8v-2              │ cat8000v           │ cml-01         │ BOOTED  │ False    │                  │
├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────┼──────────┼──────────────────┤
│ 7bdedc4a-a196-4ad0-b1f3-888cf77eee8b │ c8v-1              │ cat8000v           │ cml-01         │ BOOTED  │ False    │                  │
├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────┼──────────┼──────────────────┤
│ ab3ee63d-109d-424e-a2c0-7581a61b1d1d │ unmanaged-switch-0 │ unmanaged_switch   │ cml-01         │ BOOTED  │ False    │                  │
├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────┼──────────┼──────────────────┤
│ 9a068ec0-0565-44a0-bf16-8e4690108ac9 │ ext-conn-0         │ external_connector │ cml-01         │ BOOTED  │ False    │                  │
╘══════════════════════════════════════╧════════════════════╧════════════════════╧════════════════╧═════════╧══════════╧══════════════════╛

This will create a new tmux session with title "lab name + first 4 lab id chars" (e.g. PPK-c93a). By default, the nodes will be grouped into one window (cml tmux --group panes),

printf '\033]2;%s\033\\' 'c8v-2'
❯  ssh -t admin@cml-01 open /PPK/c8v-2/0
admin@cml-01's password:
Connecting to console for c8v-2
Connected to CML terminalserver.
Escape character is '^]'.

c8v2#
─────────────────────────────────────────────────────────────────────────
❯  printf '\033]2;%s\033\\' 'c8v-1'
❯  ssh -t admin@cml-01 open /PPK/c8v-1/0
admin@cml-01's password:
Connecting to console for c8v-1
Connected to CML terminalserver.
Escape character is '^]'.

c8v1#
 PPK-c93a >> 1 > ssh >                                     < 20:20

Note: the command printf '\033]2;%s\033\\' 'c8v-2' is used to set the pane's title see: tmux man

if you prefer having one connection per window, use: cml tmux --group windows.

❯  ssh -t admin@cml-01 open /PPK/c8v-2/0
admin@cml-01's password:
Connecting to console for c8v-2
Connected to CML terminalserver.
Escape character is '^]'.

c8v2#














 PPK-c93a >> 1 > c8v-2 >> 2 > c8v-1 >                      < 20:32

Inventory Generation

virlutils will generate inventories for various management systems

pyATS Testbed Generation

quickly turn your simulations into a testbed file that can be used for pyATS/Genie

cml generate pyats

Command and Config Execution

Using the same pyATS framework, virlutils can execute CLI EXEC-level (e.g., "show") commands as well as configuration commands on nodes within a lab. These nodes do not have to be externally reachable or have any IP connectivity. This is a great way to test operational aspects of a completely isolated topology. Before using the command command you must install pyATS. You can install pyATS by running pip install pyats.

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒ cml command "branch-rtr" "show version"
Cisco IOS XE Software, Version 16.11.01b
Cisco IOS Software [Gibraltar], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.11.1b, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
...
[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒ cml command --config "branch-rtr" "snmp-server community notpublic"

Ansible Inventory Generation

quickly turn your simulations into an inventory file that can be used to run your playbooks against. Both INI and YAML(default) formats are supported by the tool.

Usage: cml generate ansible [OPTIONS]

  generate ansible inventory

Options:
  -o, --output TEXT   output File name
  --style [ini|yaml]  output format (default is yaml)
  --help              Show this message and exit.

The ansible group membership can be controlled by adding the "ansible_group" tag to nodes in your CML labs. Multiple "ansible_group" tags can be assigned to a single node, and that node will be placed into each Ansible inventory group.

nodes:
  - id: n0
    label: branch-rtr
    node_definition: csr1000v
    tags:
      - ansible_group=mygroup

would result in the following inventory entry

all:
  children:
    mygroup:
      hosts:
        branch-router:
          ansible_host: 192.0.2.1

NOTE: if the ansible_group tag is not specified for a node, that node will not be included during inventory generation. Additionally, CML needs to know each node's management IP address before it will be placed into the inventory file

Cisco Network Services Orchestrator

You can add/update Network Services Orchestrator with your VIRL simulation.

Usage

Usage: cml generate nso [OPTIONS]

  generate nso inventory

Options:
  -o, --output TEXT           just dump the payload to file without sending
  --syncfrom / --no-syncfrom  Perform sync-from after updating devices
  --help                      Show this message and exit.

output

Updating NSO....
Enter NSO IP/Hostname: localhost
Enter NSO username: admin
Enter NSO password:
Successfully added CML devices to NSO

NOTE: NSO environment is also attempted to be determined using the following environment variables

  • NSO_HOST
  • NSO_USERNAME
  • NSO_PASSWORD

NSO Configuration Example

export NSO_HOST=localhost
export NSO_USERNAME=admin
export NSO_PASSWORD=admin

Tab Completions

[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils
⇒  cml l<tab>
license  ls

You can activate VIRL autocompletions by executing the following command

eval "$(_VIRL_COMPLETE=bash_source virl)"

To do the same for the cml command, do the following

eval "$(_CML_COMPLETE=bash_source cml)"

zsh users may need to run the following prior

autoload bashcompinit
bashcompinit

And then the following to properly enable completions for zsh

eval "$(_VIRL_COMPLETE=zsh_source virl)"
eval "$(_CML_COMPLETE=zsh_source cml)"

Local Development

If you have an idea for a feature you would like to see, we gladly accept pull requests. To get started developing, simply run the following..

git clone https://github.com/CiscoDevNet/virlutils
cd virlutils
python setup.py develop

Linting

We use flake 8 to lint our code. Please keep the repository clean by running:

flake8

Testing

We have some testing implemented, but would love to have better coverage. If you add a feature, or just feel like writing tests please update the appropriate files in the tests folder.

To run the tests in the tests folder, you can simply run make test from the project root.

virlutils's People

Contributors

akira6592 avatar chapeter avatar dependabot[bot] avatar eckelcu avatar eti-tme-tim avatar hpreston avatar individuwill avatar jclarke-csco avatar jkojak825 avatar jonstacks avatar kecorbin avatar runsi avatar sgherdao avatar tmikuska avatar tombry avatar ttafsir avatar vleijon avatar xorrkaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virlutils's Issues

Travis tests are failing

Describe the bug
Our travis tests are currently failing, even at commits that had passed previously. This is likely an issue with not having dependencies locked down well enough.

virl console without specifying node needs to be handled

KECORBIN-M-90Y9:pyats-ios-sample kecorbin$ virl console
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/virl", line 11, in <module>
    load_entry_point('virlutils==0.3', 'console_scripts', 'virl')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virl/cli/console/commands.py", line 31, in console
    node = node[0]
IndexError: tuple index out of range

Support for ncs 5.1.0

When running NSO 5.1.0 -- virlutils fails to work, probably due to NED naming differences between versions from installed default packages.

Possibly include a version check -- based on installed ncs version to generate different NED names.

Better error handling

There are a few areas that could still use better error handling, most of them should be solved by #2 . Opening this issue for tracking

`virl console --display` is useless

Describe the bug
Need to actually add some console info to virl console --display

To Reproduce
Steps to reproduce the behavior:

    Here is a list of all the running consoles
    
╒═══════════╕
│ Node      │
╞═══════════╡
│ ios1      │
├───────────┤
│ ~mgmt-lxc │
├───────────┤
│ ios2      │
╘═══════════╛

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Catch ConnectionError when VIRL server is unavailable

The following error is thrown when VIRL server can not be reached.

requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.10.20.160', port=19399): Max retries exceeded with url: /simengine/rest/list (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f46524d3e50>: Failed to establish a new connection: [Errno 113] No route to host',))

Generation of Ansible Inventory takes a long time

Describe the bug
Running virl generate ansible can take a very long time to complete.

To Reproduce
Steps to reproduce the behavior:

  1. Run virl generate ansible
  2. Time how long it takes

Expected behavior
Would expect it to finish in <1min

Add UI components

Linking to UWM topology view would be a nice to have, and should be fairly easy to implement. Additionally a local swagger UI could be implemented for experimenting with the API(currently VIRL swagger docs don't have "try it now"

Output of virl up --provision is misleading

Is your feature request related to a problem? Please describe.
virl up --provision provides the following message to users:

Waiting 10 minutes for nodes to come online....

This is a bit misleading, as it will likely finish sooner (10 minutes is the default timeout)

Describe the solution you'd like

Make it better
Describe alternatives you've considered

Waiting up to 10 minutes for nodes to come online

Additional context
Add any other context or screenshots about the feature request here.

Windows: Python 3 + git-bash Unicode error

On Windows in a git-bash terminal commands like virl ls and virl nodes that display data in tables will result in a UnicodeEncodeError if running in Python3 (3.6.2 tested). See below.

(venv)
hapresto@HAPRESTO-TCCVH MINGW64 ~/code/virlutils (master)
$ virl ls
Running Simulations
Traceback (most recent call last):
  File "C:\Users\hapresto\code\virlutils\venv\Scripts\virl-script.py", line 11, in <module>
    load_entry_point('virlutils==0.4', 'console_scripts', 'virl')()
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\virlutils-0.4-py3.6.egg\virl\cli\ls\commands.py", line 26, in ls
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\virlutils-0.4-py3.6.egg\virl\cli\views\sims\sim_views.py", line 22, in sim_list_table
  File "C:\Users\hapresto\code\virlutils\venv\lib\site-packages\click-6.7-py3.6.egg\click\utils.py", line 259, in echo
    file.write(message)
  File "C:\Users\hapresto\code\virlutils\venv\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-79: character maps to <undefined>
(venv)
hapresto@HAPRESTO-TCCVH MINGW64 ~/code/virlutils (master)
$ python -V
Python 3.6.2
(venv)
hapresto@HAPRESTO-TCCVH MINGW64 ~/code/virlutils (master)
$ pip freeze
certifi==2018.1.18
chardet==3.0.4
click==6.7
docopt==0.6.2
idna==2.6
jinja2==2.10
lxml==4.2.1
markupsafe==1.0
python-dateutil==2.7.1
pyyaml==3.12
requests==2.18.4
six==1.11.0
tabulate==0.8.2
urllib3==1.22
virlutils==0.4

This problem seems to be isolated to just the git-bash terminal itself as it works find in a native windows cmd prompt. It also works using git-bash if started with a terminal management program like ConEmu.

The problem seems to be the same as noted in this StackOverflow post: https://stackoverflow.com/questions/45660817/python-print-unicode-string-via-git-bash-gets-unicodeencodeerror

Workarounds include:

  • Use native cmd terminal
  • Use Consol Emulator
  • Use Python 2.7

Seems to be an issue not with virlutils but within Click or some other library.

http://click.pocoo.org/5/python3/

pyats 'os' attribute for lxc device

Is your feature request related to a problem? Please describe.
lxc devices contained in a pyats testbed yaml file which was created using 'virl generate pyats' don't have 'os' attribute defined.

When I want to create a genie testbed using the generated pyats testbed, an AttributeError arises

from pyats.topology import loader
from genie.conf import Genie
testbed = loader.load('default_testbed.yaml')
genie_testbed = Genie.init(testbed=testbed)
Traceback (most recent call last):
  File "pyatstest.py", line 7, in <module>
    genie_testbed = Genie.init(testbed=testbed)
  File "src/genie/conf/main.py", line 90, in genie.conf.main.Genie.init
  File "src/genie/conf/utils/converter.py", line 60, in genie.conf.utils.converter.Converter.convert_tb
  File "src/genie/conf/utils/converter.py", line 131, in genie.conf.utils.converter.Converter.convert_device
  File "src/pyats/topology/device.py", line 439, in pyats.topology.device.Device.__getattr__
AttributeError: 'Device' object has no attribute 'os'

Describe the solution you'd like

Maybe set os attribute to 'tests' for lxc devices ...

need error handling on `virl pull`

Example

This workflow should provide an error back to the user

[root@localhost test2]# virl pull foo
Pulling from foo
Saved topology as topology.virl
You have new mail in /var/spool/mail/root
[root@localhost test2]# cat topology.virl 
400: Invalid request

'NoneType' object has no attribute 'endswith'

I got this error when virl up any topology

(venv) Mac:virlutils nseung$ virl up virlfiles/2-ios-router
Creating default environment from topology.virl
Exception raised while running your command
Please open an issue and provide this info:
'NoneType' object has no attribute 'endswith'

`virl uwm` and `virl viz` do not work on windows

Describe the bug
These commands rely on the presence of a launcher executable such as open on MacOS
which does not exist on Windows (or linux??)

something like:

start filename_or_URL

should be equivalent on Windows (https://www.dwheeler.com/essays/open-files-urls.html)

To Reproduce
Steps to reproduce the behavior:

From windows attempt virl uwm

Expected behavior

A browser session to the appropriate UWM page

Screenshots

Desktop (please complete the following information):

  • OS: Windows
  • Browser likely doesnt matter

Additional context
Add any other context about the problem here.

Add ability to re-templitze topology when using virl save

Is your feature request related to a problem? Please describe.
An option to "re-templatize" topology.virl file when doing virl save to re-inject:
{{ gateway }}
{{ flat1_gateway }}
{{ dns_server }}

Describe the solution you'd like
virl save --templatize (though I'm not sure why this wouldn't be the default)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

virl up virlfiles/2-ios-router is not working

(py3-venv) SHANMMUR-M-D1J9:NSO_U shanmmur$ virl up virlfiles/2-ios-router
Pulling from virlfiles/2-ios-router
Saved topology as topology.virl
Creating default environment from topology.virl
Exception raised while running your command
Please open an issue and provide this info:
HTTPConnectionPool(host='10.194.141.30', port=19399): Max retries exceeded with url: /openstack/rest/networks (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1022844e0>: Failed to establish a new connection: [Errno 60] Operation timed out'))

Add the ability to add images to VIRL server via CLI

Is your feature request related to a problem? Please describe.

Assuming that you have a qcow or other image, be able to upload it to the VIRL server, and register appropriate subtypes

Describe the solution you'd like

Extra credit would be to detect what subtypes are required for a given simulation, and load them dynamically if not already present.

Check parent directory(s) for virl environment

I regularly find myself working in a subdirectory of a project where virlutils was used to standup the infrastructure. It would be very handy to run commands like virl nodes and virl telnet from within subdirectories of a project, to avoid having to navigate back up to the root of the project where the .virl\ directory exists.

Propose enhancing virlutils to search "up the directory tree" looking for a .virl\ folder if one is not found at the current path.

Add colors to reachability annotations in `virl nodes`

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
REACHABLE == green
UNREACHABLE == red

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

"virl generate" while simulation starting causes error

If you issue a virl generate while the simulation is still starting an error is raised that isn't helpful.

  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/bin/virl", line 11, in <module>
    load_entry_point('virlutils==0.5', 'console_scripts', 'virl')()
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/virl/cli/generate/ansible/commands.py", line 48, in ansible
    interfaces=interfaces)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/virl/generators/ansible_inventory.py", line 177, in ansible_inventory_generator
    inventory_yaml = render_yaml_inventory(virl_data, roster, interfaces)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/virl/generators/ansible_inventory.py", line 146, in render_yaml_inventory
    inventory=generate_inventory_dict(virl_xml, roster=roster, interfaces=interfaces)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/virl/generators/ansible_inventory.py", line 111, in generate_inventory_dict
    group_map = create_group_map(virl_xml)
  File "/Users/hapresto/coding/netdevops_demos/ansible_02/v2_4/lib/python3.6/site-packages/virl/generators/ansible_inventory.py", line 36, in create_group_map
    root = etree.fromstring(virl_xmlstr)
  File "src/lxml/etree.pyx", line 3213, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1126, in lxml.etree._BaseParser._parseDoc
  File "src/lxml/parser.pxi", line 600, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 710, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 639, in lxml.etree._raiseParseError
  File "<string>", line 1
lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1

Generation of NSO inventory fails if NSO ENV_VARS not set

Describe the bug
If you try to virl generate nso and haven't set environment variables for NSO_HOST NSO_USERNAME and NSO_PASSWORD you get an unhelpful error.

$ virl generate nso
Updating NSO....
Exception raised while running your command
Please open an issue and provide this info:
local variable 'input' referenced before assignment

To Reproduce
Steps to reproduce the behavior:
Attempt the behavior

Expected behavior
Should provide an error that indicates the needed exports.

Desktop (please complete the following information):

  • Mac
  • virlutils 0.8.4
  • NSO 4.7

virl up in version 0.8.9 raises 'path not found' exception

Describe the bug
Running virl up -f topology.virl produces the following error:
Exception raised while running your command
Please open an issue and provide this info:
[WinError 3] The system cannot find the path specified: ''

To Reproduce
Steps to reproduce the behavior:

  1. Create new python virtual environment. python -m venv venv or virtualenv venv
  2. Activate virtual environment. source venv/bin/activate
  3. Install latest version of virlutils (0.8.9). pip install virlutils
  4. Run virl up -f topology.virl Ensure there's are valid .virlrc and topology.virl files in the local directory.

Expected behavior
Output should be: Creating default environment from topology.virl.

Desktop:

  • OS: [Win10, Ubuntu16.04]
  • Python_Version: [3.7.2, 2.7.16]
  • virlutils_Version: [0.8.9]

Additional context
Issue was reproduced with both Python 2 and Python 3 on each Windows 10 and Ubuntu 16.04. No issues with virlutils version 0.8.8.

IndexError: list index out of range when no DNS server is configured

Occurs when no DNS server is configured on VIRL.

Full traceback

[root@localhost foo]# virl up
Creating default environment from topology.virl
Traceback (most recent call last):
  File "/usr/bin/virl", line 11, in <module>
    load_entry_point('virlutils==0.5', 'console_scripts', 'virl')()
  File "/usr/lib/python2.7/site-packages/click-6.7-py2.7.egg/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click-6.7-py2.7.egg/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click-6.7-py2.7.egg/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click-6.7-py2.7.egg/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "build/bdist.linux-x86_64/egg/virl/cli/up/commands.py", line 33, in up
    
  File "build/bdist.linux-x86_64/egg/virl/api/api.py", line 161, in get_dns_server_for_network
IndexError: list index out of range

Deprecate Python 3.3 support and build tests

Describe the bug
TravisCI builds of Python 3.3 are failing because flake8 lint checking and setuptools fail to run due to
Python version 3.4 or later requirement.

Proposed Fix
Deprecated Python 3.3 support as its upstream support was deprecated on 2017-09-19

Screenshots

$ make lint
flake8
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.3.6/bin/flake8", line 7, in <module>
    from flake8.main.cli import main
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/flake8/main/cli.py", line 2, in <module>
    from flake8.main import application
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/flake8/main/application.py", line 17, in <module>
    from flake8.plugins import manager as plugin_manager
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/flake8/plugins/manager.py", line 5, in <module>
    import pkg_resources
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/pkg_resources/__init__.py", line 90, in <module>
    raise RuntimeError("Python 3.4 or later is required")
RuntimeError: Python 3.4 or later is required
make: *** [lint] Error 1
The command "make lint" exited with 2.
0.28s$ make coverage
coverage run --source=virl setup.py test
Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    from setuptools import setup, find_packages  # noqa: H301
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/setuptools/__init__.py", line 16, in <module>
    import setuptools.version
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/home/travis/virtualenv/python3.3.6/lib/python3.3/site-packages/pkg_resources/__init__.py", line 90, in <module>
    raise RuntimeError("Python 3.4 or later is required")
RuntimeError: Python 3.4 or later is required
Coverage.py warning: No data was collected. (no-data-collected)
make: *** [coverage] Error 1
The command "make coverage" exited with 2.

Support for VIRL Flavors

Is your feature request related to a problem? Please describe.
No. Requesting this feature to help provide scriptable configuration of VIRL in sandboxes.

Describe the solution you'd like
Support for VIRL Flavors. This support should include the ability to:

  • Create a Flavor
  • List Flavors (Summary and Detail)
  • Modify Flavors
  • Remove Flavors

Note: The VIRL management web portal (I don't think) permits modification of flavors so the Modify/Update feature may not be possible.

Describe alternatives you've considered
-NA-

Additional context

Add ability to generate topology.virl via cli

Is your feature request related to a problem? Please describe.
In certain scenarios, it is desirable to quickly generate a virl file manually.

Describe the solution you'd like

Support some sort of markup like

Describe alternatives you've considered

Some sort of virl markup e.g.

server-1: linux
server-2: linux
R1: csr
branch: csr
internet: ext
sw1: iol

server-1 <-> sw1
server-2 <-> sw1
sw1 <-> branch
R1 <-> branch
branch <-> internet

if during virl up no topology.virl file is present, it would look for topology.vml and automatically generate the XML

Additional context
Add any other context or screenshots about the feature request here.

Unable to connect using alternative credentials

Cannot connect to Virl server unless using guest account with guest password.
exporting VIRL_USERNAME and VIRL_PASSWORD to bash env does not work.
Issue lies within api.py

from line 39
@Property
def passwd(self):
return self._user

I believe that this should be

@Property
def passwd(self):
return self._passwd

This change rectifies the issue.

Need to account for options which may not be configured on the VIRL server

Localization allows for tags in VIRL XML to be replaced with configuration from the VIRL server, need to handle cases where those options may not be configured on the server.

https://github.com/kecorbin/virlutils/blob/master/virl/cli/up/commands.py#L39

Specifically, DNS servers are often not configured for the shared networks.
https://github.com/kecorbin/virlutils/blob/master/virl/api/api.py#L186
can lead to the following error message

Exception raised while running your command
Please open an issue and provide this info:
list index out of range

virl ls can only see the simulation it creates but not all other simulation

Describe the bug
From the readme, It shows that virl ls can show all the simulation under the same account (def: guest/guest)
However, from what I observe, virl ls can only see the simulation it brings up.

Is it expected?

To Reproduce
Steps to reproduce the behavior:
create two directories
put different topology in the directories.
enter "virl up" in directory 1
enter "virl ls" (expected to see one simulation)
enter "virl up" in directory 2
enter "virl ls" (expected to see two simulations. However, it only shows 1)

Expected behavior
Should "virl ls" show all simulation under "VIRL_USERNAME" ??
Or should we have a "global-status" option to see the simulation globally?

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: iOS,Win,CentOS

Additional context
Add any other context about the problem here.

SSH to all nodes at once

Is your feature request related to a problem? Please describe.
I am looking for a command that allows me to SSH or Telnet to all of my alive nodes at once, opening multiple windows or in case of tab support apps one window with tabs.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Omit some interface types that genie doesnt understand

Describe the bug

For XR devices, virlutils generates the following pyats Interfaces in the topology session

    CtrlEth:
        link: core2-Dummy/CtrlEth
        type: ethernet
      DevEth:
        link: core2-Dummy/DevEth
        type: ethernet

Genie doesnt know what to do with these

To Reproduce
Steps to reproduce the behavior:

virl generate pyats on topolgy that has XR nodes

Expected behavior

these should be ommitted

Screenshots

Traceback (most recent call last):
  File "/Users/kecorbin/VirtualEnvs/pyats/lib/python3.6/site-packages/genie/libs/conf/interface/iosxr/interface.py", line 86, in __new__
    factory_cls = cls._name_to_class_map[d_parsed.type]
KeyError: 'CtrlEth'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pyats-intro.py", line 31, in <module>
    genie_testbed = Genie.init(args.testbed)
  File "src/genie/conf/main.py", line 90, in genie.conf.main.Genie.init
  File "src/genie/conf/utils/converter.py", line 60, in genie.conf.utils.converter.Converter.convert_tb
  File "src/genie/conf/utils/converter.py", line 164, in genie.conf.utils.converter.Converter.convert_device
  File "src/genie/conf/utils/converter.py", line 212, in genie.conf.utils.converter.Converter.convert_interface
  File "src/ats/datastructures/factory.py", line 56, in ats.datastructures.factory.MetaClassFactory.__call__
  File "src/genie/conf/base/interface.py", line 79, in genie.conf.base.interface.BaseInterface.__new__
  File "/Users/kecorbin/VirtualEnvs/pyats/lib/python3.6/site-packages/genie/libs/conf/interface/__init__.py", line 563, in __new__
    self = factory_cls.__new__(factory_cls, *args, **kwargs)
  File "/Users/kecorbin/VirtualEnvs/pyats/lib/python3.6/site-packages/genie/libs/conf/interface/iosxr/interface.py", line 88, in __new__
    raise UnknownInterfaceTypeError
genie.conf.base.exceptions.UnknownInterfaceTypeError: Unknown interface type```
**Desktop (please complete the following information):**
 - OS: [e.g. iOS]
 - Browser [e.g. chrome, safari]
 - Version [e.g. 22]

Additional context
Add any other context about the problem here.

virl save corrupts certificate configuration

Describe the bug
CSR1000v node which contains configuration like this:

crypto pki trustpoint TP-self-signed-2977369288
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-2977369288
 revocation-check none
 rsakeypair TP-self-signed-2977369288
!
!
crypto pki certificate chain TP-self-signed-2977369288
 certificate self-signed 01
  30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030
  31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
  69666963 6174652D 32393737 33363932 3838301E 170D3138 31303037 30363437
  32345A17 0D323030 31303130 30303030 305A3031 312F302D 06035504 03132649
  4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D32 39373733
  36393238 38308201 22300D06 092A8648 86F70D01 01010500 0382010F 00308201
  0A028201 01008C1A C2795E3A 8AB679A4 CA2045F9 C0E44087 5ABF657B 645D9BC5
  2897EB07 0A0D8338 6EC47227 307EFA80 543CF04A F15E3888 7C87366D 01A20814
  4A6ECDCF CBF2130C E9BB2978 61DB6686 7C9E483C 712C1AD1 AC7DCB0B E57840C6
  26D06341 6407F2F6 0DD7F078 244DE324 A0F867B7 936D93E6 D40AD01E 0CC77F95
  AE1BE3FD 8871DBAF BD717536 A0D76A14 82E84131 D2377003 4E275503 98E2344A
  D5392D3E 5E35ED89 3FD20040 BD4C3092 9F58B082 159DFDC6 452689BC F0DD87B6
  A7DE8B06 3BA50452 E7AD3721 C7836AB0 90D0CA44 B5A57047 5BD3AB9F C8D9B81A
  E7BB2D6E 84051505 C2B5768D 08B298FB 9EE8F966 0539BC2E D542D214 57C3BDCD
  11E50754 38A10203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF
  301F0603 551D2304 18301680 14030399 C83F7BE2 A0DF66BE 5FB77506 89FB0EC3
  2D301D06 03551D0E 04160414 030399C8 3F7BE2A0 DF66BE5F B7750689 FB0EC32D
  300D0609 2A864886 F70D0101 05050003 82010100 25AB57B4 6D78F95B 2F9AEE26
  6E3936DE E56DC3FE C5704BBB 64B7A392 23CBC93E A2CAAB38 FCB0997D 0FE9019B
  1EF6ACFB 00179B86 74AFAC2F EC5BF7A5 C96FCC21 54E368C3 E74ED986 AB3FADD5
  2CF62ABA B5053A55 9EFBDAB6 C65AD596 4AF94C96 15745D17 0D8C8C13 FE7311BA
  F9F51CA0 8DBEA168 F86D33A0 8C12DA0E 518EA874 7CBA509D B404EE67 E96AA50E
  A2A82DC5 5D8FC59C 60DFEFFF B4F6FE5A E07C5C1D 804BB90B 6D08B091 5425322B
  A54172F9 56A35662 7AA79BFE 61D8695D CB7F4BA5 C92327AA 3630FA27 D1855328
  674965B0 F2898FF3 2F35407B C7BC7914 82A3986D 3624E057 E7F1009C 07862E67
  A5DCDE07 BCFD264E BAC93598 DB0B37B5 4E7670E6
        quit
!

When I save the configuration using virl save, related part of the configuration looks like:

...
  A5DCDE07 BCFD264E BAC93598 DB0B37B5 4E7670E6
        quit

which looks fine. But when you look at the structure of the file, you will see

<SPACE><SPACE><TAB>quit

During the boot of the node, you can see the following error message on the console:

*Oct  7 08:34:57.552: %CVAC-3-XML_ERROR: Error while parsing XML from file cdrom0:/ovf-env.xml: error 'XML_ERROR_FRAMING', element '', attribute '', explanation 'Bad Character in Attribute Value '  quit''. File will be saved to bootflash:/ovf-env.xml.bak
*

The booting process then exits with empty configuration.

When I save configuration in VM Maestro it looks like:

crypto pki trustpoint TP-self-signed-2977369288
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-2977369288
 revocation-check none
 rsakeypair TP-self-signed-2977369288
!
!
crypto pki certificate chain TP-self-signed-2977369288
 certificate self-signed 01 nvram:IOS-Self-Sig#1.cer
!

As a workaround I have to run ' sed -i.bak $'s/\tquit/quit/g' topology.virl ` each time when configuration is saved using virl save

Virl Up Fails on Centos 7 See Details Below.

Just setup Virl PE as well as Virl Utils on my Linux host I used for dev. When I attempt to setup a simulation using Virl Utils drawing from the github/virlfiles repo for my base topology I get the below error. Does anyone have any insight into this issue and how to test and verify Virl VM reachability?

[admin@localhost Virl_Util]$ virl up -f topology.virl
Creating default environment from topology.virl
Exception raised while running your command
Please open an issue and provide this info:
expected str, bytes or os.PathLike object, not NoneType

when pulling a topology a list index error is raised

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. create a new virtual environment python2.7
  2. virl search
  3. virl up virlfiles/2-ios-router

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS Mojave 10.14.5

Additional context
Add any other context about the problem here.
(venv) 22:07:33> virl up virlfiles/2-ios-router
Pulling from virlfiles/2-ios-router
Saved topology as topology.virl
Creating default environment from topology.virl
Exception raised while running your command
Please open an issue and provide this info:
list index out of range

Pass hostname to console/telnet/ssh option

Is your feature request related to a problem? Please describe.
Request to pass "node name" into the VIRL_CONSOLE_COMMAND, VIRL_TELNET, VIRL_SSH so that when I open many telnet terminals to different devices, it can have the hostname show up on each windows.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.