ptovnetlab


Nameptovnetlab JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryGets run-state details from a list of Arista switches and builds a GNS3 virtual-lab to emulate them.
upload_time2025-01-18 17:21:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseModified BSD License ==================== *Copyright © 2024, H. L. Mencken Davidson* *All rights reserved.* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of dcnodatg nor the names of its contributors may be used to endorse or promote products, derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL H. L. MENCKEN DAVIDSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords arista eapi eos gns3 lab virtual ceos
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Preamble

I wrote this package (ptovnetlab) specifically to assist in *fast/low-effort* modeling of a production EVPN Layer-3 Leaf & Spine physical network of Arista switches in a pre-existing GNS3 server, using Arista cEOS docker images.  (Also, to teach myself how to write/publish Python packages, but *really* for modeling Arista switches.)  I'd like to scale it up to supporting addditional virtual-lab platforms and network-device vendors' equipment, but all things have to start *somewhere*.

- [Documentation](https://menckend.github.io/dcnodatg/)
- [Repository](https://github.com/menckend/dcnodatg)
- [(Latest) Package](https://pypi.org/project/ptovnetlab/)
- [(testing) Package](https://test.pypi.org/project/ptovnetlab/)

## What it does

- Grabs startup configuration, version info, and lldp neighbor information from a list of Arista switches
-   Retreived using Arista's "EAPI"
- Sanitizes the switch configs for use in a cEOS environment
  - Removes all AAA and username configuration
  - Reformats interface names to match the cEOS interface naming convention  Ethernet_n , not Ethernt_n/1
  - Comments out incompatible commands ("queue..."/etc. not supported on cEOS)
  - Configures the system mac-address of the production switch
    - Avoids mLAG incompatibility with older versions of cEOS
      - Docker container default mac address has U/L bit set to L instead of U, which prevents MLAG from working
- Builds a table of interconnections between the switches
  - Inferred from the "show lldp neighbor" and "show lldp local" output collected from the switches
- Creates a GNS3 project
  - Instantiates a cEOS container node in the project for each switch in the input list
  - Modeled devices mirror the following properties of the switches they are modeling:
    -  cEOS version (a pre-existing GNS3 docker template using the matching cEOS version must be present) 
    -  Ethernet interface count
    -  Startup configuration
       -  "startup-config" is passed directly to the Docker API, allowing ptovnetlab to run separately from the GNS3 server
  - Creates the connections between the GNS3/cEOS nodes, mirroring all inter-switch connections discovered in LLDP tables

## What you'll need

### Python

- The ptovnetlab project was written using Python 3.12.
- The host running the ptovnetlab packages will need to have Python and the packages listed in the dependencies section of pyproject.toml installed
- Once Python is installed, use pip to install ptovnetlab (which will install its dependencies as well):
  -  'pip install --user ptovnetlab'

### GNS3 server

- The ptovnetlab package was written against version 2.2.52 of GNS3 server.
- The GNS3 server must be pre-configured with cEOS docker templates
  - ptovnetlab will compare the EOS version string returned by the switches you're modeling to the names you've applied to the corresponding templates  on the GNS3 server
    - The GNS templates built on the docker images need to be named as "ceos:*n.n...*" for the matching to work
- A container management service (typically dockerd or containerd) must be listening on TCP port 2375 of the GNS3 server
  - ptovnetlab makes API calls directly to the GNS3 server's container management service to copy configuration files directly onto the containers' filesystems.

### Setting up GNS3 server

- Install GNS3 server
- 

### Arista Switches

All switches that you will be modeling will need to have:

- EAPI services accessible from the host running the ptovnetlab module
```
management api http-commands
   no shutdown
```

- And you will need to provide auth. credentials with sufficient privileges to invoke the following methods:
    - node.enable(("show version", "show lldp neighbors", "show lldp local-info"), format="json")
    - node.startup_config.splitlines()

### Instructions

### Prep

- Have Python and the ptovnetlab package installed on the host that will run ptovnetlab
- Have your login credentials for your production switches handy
- Make sure that your production switches can receive eAPI connections from your GNS3 server
- Optionally, create a file named "input-switch-list"
  -   - Populate 'input-switch-list' with the names of the switches that you want to model in gns3
      -   One switch name per line (no quotes or commas)

### Parameter/argument list

ptovnetlab uses the following arguments (passed as keyword pairs):

- filename *or* switchlist
  - No default value
  - If *both* arguments are provided, ptovnetlab will exit.
  - If *no* argument is provided, ptovnetlab will try use the input function to prompt for switch names
  - "filename" is (path and) name of the file containing the list of switches to process
    - One switch-name (FQDN or resolvable short-name) per line in the file
    - E.G.:  ./switch-list.txt
  - "switchlist" is a python list of switch-names
    - E.g.:  ["name1", "name2", "nameN"]
- servername
  - No default value
  - The name (FQDN or resolvable short-name) of the GNS3 server
  - If not provided, ptovnetlab will try to use the input function to prompt for a value
  - E.g.:  gns3server.whathwere.there
- username
  - No default value
  - The username ptovnetlab will provide to the switches when authenticating the eapi connections
  - If not provided, ptovnetlab will try to use the input function to prompt for a value
- passwd
  - No default value
  - The password ptovnetlab will provide to the switches when authenticating the eapi connections
  - If not provided, ptovnetlab will try to use the input function to prompt for a value
- prjname
  - No default value
  - The name to assign to the new project that ptovnetlab will create on the GNS3 server

### Execution

#### As a Python script

Installing ptovnetlab via pip will save you the effor of installing the additional dependencies list in pyproject.toml, but you can also just grab the contents of the ptovnetlab folder [directly from the git repository](https://github.com/menckend/ptovnetlab/tree/main/ptovnetlab) and store them on the host you'll run them from.

You'll also need to move the "dcnod-cli.py" file *up* one level in the directory structure from the ptovnetlab folder after copying the entire folder to your host.  This is to work around "goofiness" with regards to how Python treats namespaces when accessing Python code as a "script" vs accessing it "as a module."

To actually run the utility, you'll enter the following command:

```
python [path-to]dcnod-cli.py'
```

##### To run interactively

Enter:

```bash
python [path-to]dcnod-cli.py'
```

As ptovnetlab executes, you will be prompted to respond with values for all of the parameters/arguments. No quotes or delimiters should be required as you enter the values.

- The FQDNs of the switches you want to process
  - Type a switch-name and press Enter
  - Repeat until you've entered all the switches you want to model
  - Then press Enter again
- The name of the GNS3 project to create
  - Type a project name (adhere to whatever GNS3's project-naming semantics) and press enter
- The EOS username to use when querying the switches
  - Type the name and press enter
- The EOS password to use when querying the switches
  - The getpass function is used, obscuring the password on-screen as you type it
  - The password itself isn't written to any file
  - Type the password and press Enter
- The FQDN of the GNS3 server you'll be using

##### To run non-interactively

Enter:  

```python
python [path-to]dcnod-cli.py [arguments]
```

The arguments are keyword/value pairs, in the form of:

```python
keyword='value'
```

The arguments can be entered in any order, separate by a space.  Examples of each argument follow:

```text
username= 'mynameismud'
passwd= 'mypasswordisalsomud'
servername= 'gns3server.menckend.com'
switchlist= 'sw1.menckend.com sw2 sw3 sw4.menckend.com'
filename= './switchlist.txt'
prjname= 'ptovnetlab-project-dujour'
```

Remember that the switchlist and filename arguments are mutually exclusive, if you pass *both*, ptovnetlab will exit.

An example of a fully-argumented invocation would be:

```bash
python ./ptovnetlab.py username='fakeid' passwd='b@dp@ssw0rd' servername='gn3server.com' prjname='giveitanme' switchlist='switch1 switch2 switch3'
```

##### As a Python module

Install ptovnetlab with pip as described above and include an import statement ('import ptovnetlab') in your python module. E.g.

```python
from ptovnetlab import ptovnetlab

sn='gns3server.bibbity.bobbity.boo'
un='myuserid'
pw='weakpassword'
prjn='new-gns3-project-today'
sl=['switch1.internal', 'switch15.internal', 'switch1.menckend.com']

ptovnetlab.p_to_v(username=sn, passwd=pw, servername=sn, switchlist=sl, prjname=prjn)
```

> [!IMPORTANT]  
> The 'switchlist' parameter, when ptovnetlab is being accessed as a module is a dict structure, and the formatting in the example above is mandatory when specifying the switchlist data as a kwarg.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ptovnetlab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Mencken Davidson <mencken@gmail.com>",
    "keywords": "arista, eapi, eos, gns3, lab, virtual, ceos",
    "author": null,
    "author_email": "Mencken Davidson <mencken@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/08/33/1971ebfd95adfef5c0b018d9653fc74fe10cb8da0bdf2e8f21a260a0c9ea/ptovnetlab-0.0.3.tar.gz",
    "platform": null,
    "description": "# Preamble\n\nI wrote this package (ptovnetlab) specifically to assist in *fast/low-effort* modeling of a production EVPN Layer-3 Leaf & Spine physical network of Arista switches in a pre-existing GNS3 server, using Arista cEOS docker images.  (Also, to teach myself how to write/publish Python packages, but *really* for modeling Arista switches.)  I'd like to scale it up to supporting addditional virtual-lab platforms and network-device vendors' equipment, but all things have to start *somewhere*.\n\n- [Documentation](https://menckend.github.io/dcnodatg/)\n- [Repository](https://github.com/menckend/dcnodatg)\n- [(Latest) Package](https://pypi.org/project/ptovnetlab/)\n- [(testing) Package](https://test.pypi.org/project/ptovnetlab/)\n\n## What it does\n\n- Grabs startup configuration, version info, and lldp neighbor information from a list of Arista switches\n-   Retreived using Arista's \"EAPI\"\n- Sanitizes the switch configs for use in a cEOS environment\n  - Removes all AAA and username configuration\n  - Reformats interface names to match the cEOS interface naming convention  Ethernet_n , not Ethernt_n/1\n  - Comments out incompatible commands (\"queue...\"/etc. not supported on cEOS)\n  - Configures the system mac-address of the production switch\n    - Avoids mLAG incompatibility with older versions of cEOS\n      - Docker container default mac address has U/L bit set to L instead of U, which prevents MLAG from working\n- Builds a table of interconnections between the switches\n  - Inferred from the \"show lldp neighbor\" and \"show lldp local\" output collected from the switches\n- Creates a GNS3 project\n  - Instantiates a cEOS container node in the project for each switch in the input list\n  - Modeled devices mirror the following properties of the switches they are modeling:\n    -  cEOS version (a pre-existing GNS3 docker template using the matching cEOS version must be present) \n    -  Ethernet interface count\n    -  Startup configuration\n       -  \"startup-config\" is passed directly to the Docker API, allowing ptovnetlab to run separately from the GNS3 server\n  - Creates the connections between the GNS3/cEOS nodes, mirroring all inter-switch connections discovered in LLDP tables\n\n## What you'll need\n\n### Python\n\n- The ptovnetlab project was written using Python 3.12.\n- The host running the ptovnetlab packages will need to have Python and the packages listed in the dependencies section of pyproject.toml installed\n- Once Python is installed, use pip to install ptovnetlab (which will install its dependencies as well):\n  -  'pip install --user ptovnetlab'\n\n### GNS3 server\n\n- The ptovnetlab package was written against version 2.2.52 of GNS3 server.\n- The GNS3 server must be pre-configured with cEOS docker templates\n  - ptovnetlab will compare the EOS version string returned by the switches you're modeling to the names you've applied to the corresponding templates  on the GNS3 server\n    - The GNS templates built on the docker images need to be named as \"ceos:*n.n...*\" for the matching to work\n- A container management service (typically dockerd or containerd) must be listening on TCP port 2375 of the GNS3 server\n  - ptovnetlab makes API calls directly to the GNS3 server's container management service to copy configuration files directly onto the containers' filesystems.\n\n### Setting up GNS3 server\n\n- Install GNS3 server\n- \n\n### Arista Switches\n\nAll switches that you will be modeling will need to have:\n\n- EAPI services accessible from the host running the ptovnetlab module\n```\nmanagement api http-commands\n   no shutdown\n```\n\n- And you will need to provide auth. credentials with sufficient privileges to invoke the following methods:\n    - node.enable((\"show version\", \"show lldp neighbors\", \"show lldp local-info\"), format=\"json\")\n    - node.startup_config.splitlines()\n\n### Instructions\n\n### Prep\n\n- Have Python and the ptovnetlab package installed on the host that will run ptovnetlab\n- Have your login credentials for your production switches handy\n- Make sure that your production switches can receive eAPI connections from your GNS3 server\n- Optionally, create a file named \"input-switch-list\"\n  -   - Populate 'input-switch-list' with the names of the switches that you want to model in gns3\n      -   One switch name per line (no quotes or commas)\n\n### Parameter/argument list\n\nptovnetlab uses the following arguments (passed as keyword pairs):\n\n- filename *or* switchlist\n  - No default value\n  - If *both* arguments are provided, ptovnetlab will exit.\n  - If *no* argument is provided, ptovnetlab will try use the input function to prompt for switch names\n  - \"filename\" is (path and) name of the file containing the list of switches to process\n    - One switch-name (FQDN or resolvable short-name) per line in the file\n    - E.G.:  ./switch-list.txt\n  - \"switchlist\" is a python list of switch-names\n    - E.g.:  [\"name1\", \"name2\", \"nameN\"]\n- servername\n  - No default value\n  - The name (FQDN or resolvable short-name) of the GNS3 server\n  - If not provided, ptovnetlab will try to use the input function to prompt for a value\n  - E.g.:  gns3server.whathwere.there\n- username\n  - No default value\n  - The username ptovnetlab will provide to the switches when authenticating the eapi connections\n  - If not provided, ptovnetlab will try to use the input function to prompt for a value\n- passwd\n  - No default value\n  - The password ptovnetlab will provide to the switches when authenticating the eapi connections\n  - If not provided, ptovnetlab will try to use the input function to prompt for a value\n- prjname\n  - No default value\n  - The name to assign to the new project that ptovnetlab will create on the GNS3 server\n\n### Execution\n\n#### As a Python script\n\nInstalling ptovnetlab via pip will save you the effor of installing the additional dependencies list in pyproject.toml, but you can also just grab the contents of the ptovnetlab folder [directly from the git repository](https://github.com/menckend/ptovnetlab/tree/main/ptovnetlab) and store them on the host you'll run them from.\n\nYou'll also need to move the \"dcnod-cli.py\" file *up* one level in the directory structure from the ptovnetlab folder after copying the entire folder to your host.  This is to work around \"goofiness\" with regards to how Python treats namespaces when accessing Python code as a \"script\" vs accessing it \"as a module.\"\n\nTo actually run the utility, you'll enter the following command:\n\n```\npython [path-to]dcnod-cli.py'\n```\n\n##### To run interactively\n\nEnter:\n\n```bash\npython [path-to]dcnod-cli.py'\n```\n\nAs ptovnetlab executes, you will be prompted to respond with values for all of the parameters/arguments. No quotes or delimiters should be required as you enter the values.\n\n- The FQDNs of the switches you want to process\n  - Type a switch-name and press Enter\n  - Repeat until you've entered all the switches you want to model\n  - Then press Enter again\n- The name of the GNS3 project to create\n  - Type a project name (adhere to whatever GNS3's project-naming semantics) and press enter\n- The EOS username to use when querying the switches\n  - Type the name and press enter\n- The EOS password to use when querying the switches\n  - The getpass function is used, obscuring the password on-screen as you type it\n  - The password itself isn't written to any file\n  - Type the password and press Enter\n- The FQDN of the GNS3 server you'll be using\n\n##### To run non-interactively\n\nEnter:  \n\n```python\npython [path-to]dcnod-cli.py [arguments]\n```\n\nThe arguments are keyword/value pairs, in the form of:\n\n```python\nkeyword='value'\n```\n\nThe arguments can be entered in any order, separate by a space.  Examples of each argument follow:\n\n```text\nusername= 'mynameismud'\npasswd= 'mypasswordisalsomud'\nservername= 'gns3server.menckend.com'\nswitchlist= 'sw1.menckend.com sw2 sw3 sw4.menckend.com'\nfilename= './switchlist.txt'\nprjname= 'ptovnetlab-project-dujour'\n```\n\nRemember that the switchlist and filename arguments are mutually exclusive, if you pass *both*, ptovnetlab will exit.\n\nAn example of a fully-argumented invocation would be:\n\n```bash\npython ./ptovnetlab.py username='fakeid' passwd='b@dp@ssw0rd' servername='gn3server.com' prjname='giveitanme' switchlist='switch1 switch2 switch3'\n```\n\n##### As a Python module\n\nInstall ptovnetlab with pip as described above and include an import statement ('import ptovnetlab') in your python module. E.g.\n\n```python\nfrom ptovnetlab import ptovnetlab\n\nsn='gns3server.bibbity.bobbity.boo'\nun='myuserid'\npw='weakpassword'\nprjn='new-gns3-project-today'\nsl=['switch1.internal', 'switch15.internal', 'switch1.menckend.com']\n\nptovnetlab.p_to_v(username=sn, passwd=pw, servername=sn, switchlist=sl, prjname=prjn)\n```\n\n> [!IMPORTANT]  \n> The 'switchlist' parameter, when ptovnetlab is being accessed as a module is a dict structure, and the formatting in the example above is mandatory when specifying the switchlist data as a kwarg.\n",
    "bugtrack_url": null,
    "license": "Modified BSD License ====================  *Copyright \u00a9 2024, H. L. Mencken Davidson* *All rights reserved.*  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of dcnodatg nor the names of its contributors may be used to endorse or promote products, derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \u201cAS IS\u201d AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL H. L. MENCKEN DAVIDSON BE LIABLE FOR ANY DIRECT, INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "Gets run-state details from a list of Arista switches and builds a GNS3 virtual-lab to emulate them.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://menckend.github.io/dcnodatg",
        "Issues": "https://github.com/menckend/dcnodatg/issues",
        "Repository": "https://github.com/menckend/dcnodatg.git"
    },
    "split_keywords": [
        "arista",
        " eapi",
        " eos",
        " gns3",
        " lab",
        " virtual",
        " ceos"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbbcf9c4c1880b98e4da269ab320ea39dd84513f651e28bfa9d7ba0a7bc23795",
                "md5": "6ae5d6b8bb2b4b57dc8f6a01305322fe",
                "sha256": "db838fbb7ac765a3744539922356a8c086db22c19a1c927a1f35188db78044ad"
            },
            "downloads": -1,
            "filename": "ptovnetlab-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ae5d6b8bb2b4b57dc8f6a01305322fe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 28154,
            "upload_time": "2025-01-18T17:21:46",
            "upload_time_iso_8601": "2025-01-18T17:21:46.398683Z",
            "url": "https://files.pythonhosted.org/packages/db/bc/f9c4c1880b98e4da269ab320ea39dd84513f651e28bfa9d7ba0a7bc23795/ptovnetlab-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08331971ebfd95adfef5c0b018d9653fc74fe10cb8da0bdf2e8f21a260a0c9ea",
                "md5": "cb0229c4317616be1cb86e0207e470db",
                "sha256": "5d854005194c5d84c35b85e7641db885f695f53743a50841be25ee7ef3894ac1"
            },
            "downloads": -1,
            "filename": "ptovnetlab-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "cb0229c4317616be1cb86e0207e470db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 27048,
            "upload_time": "2025-01-18T17:21:48",
            "upload_time_iso_8601": "2025-01-18T17:21:48.577343Z",
            "url": "https://files.pythonhosted.org/packages/08/33/1971ebfd95adfef5c0b018d9653fc74fe10cb8da0bdf2e8f21a260a0c9ea/ptovnetlab-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-18 17:21:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "menckend",
    "github_project": "dcnodatg",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ptovnetlab"
}
        
Elapsed time: 0.47808s