NAV Navbar
python cURL

Introduction

Tesuto is a hyper-scale network emulation platform.

With Tesuto, network operators can create a clone of their production networks in the cloud. The cloud instances run on the same software they have on physical devices for comprehensive testing, training and analysis.

Installation

Unless you want to modify this source code just install the package:

pip install git+https://gitlab.com/tesuto/public/tesuto-python@master#egg=tesuto_python

Install from source:

source is at: https://gitlab.com/tesuto/public/tesuto-python

python setup.py install

Authentication

from tesuto import tesuto

tesuto.config.set('api_token', '<YOUR TESUTO API TOKEN>')
# Or simply set TESUTO_API_TOKEN environment variable

#  cURL authorization is done by setting the following header:

curl "api_endpoint"
  -H "Authorization: Bearer <YOUR TESUTO API TOKEN>"

You need a valid token to access the Tesuto APIs. To retrieve the token login to cloud.tesuto.com and find them under "Tokens" pages

More information about Tokens can be found in knowledge base article

Logging

Enable logging:

import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)

# Only supported in python

The library can be configured to emit logging that will give you better insight into what it's doing. The info logging level is usually most appropriate for production use, but debug is also available for more verbosity.

Licenses

Vendor EULAs

Before using a third party vendor's software in Tesuto cloud, you have to review and accept their end user license agreements. This article has more information on Vendor EULAs.

Vendor images

To emulate vendor devices in Tesuto cloud, you have to provide proof that you are authorized to use third party vendor software. Some vendors have given Tesuto authorization to allow our customers access their evaluation software (You still have to agree and follow the guidelines in their EULAs) for other vendors, The quickest and automated way to satisfy licensing requirements, this is to upload the software image that have obtained from Vendors website back to Tesuto cloud.

For more information please check this knowledge base article

if you have any questions please contact support@tesuto.com

Emulations

Emulation

Emulation is a collection of devices, their configuration and how they are connected (topology) Think of emulations as independent snapshots of your network.

This knowledge base article has more information about emulations.

Get all emulations

Sample Request:

from tesuto import tesuto

emulations = tesuto.apis.Emulation.list().data
for emulation in emulations:
    # Print all the attributes of the emulation
    tesuto.console.output(emulation)
    # Access a single attribute
    print('Emulation Name: {}'.format(emulation.name))

curl -X GET https://api.tesuto.com/v1/emulations \
    --header "Authorization: Bearer $TESUTO_API_TOKEN"

Sample Response:

{
    "access": null,
    "devices": null,
    "id": 421207872952860673,
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "Test Emulation",
    "region": "us-east",
    "region_id": 396921887629967361,
    "slug": "testemulation",
    "status": null,
    "topologies": null,
    "type": "emulation",
    "validators": null
}
Emulation Name: Test Emulation
{
    "data": [
        {
            "id": "408259520833912833",
            "is_managed": true,
            "is_persistent": true,
            "is_ztp": true,
            "name": "DevEmulation1",
            "region": "us-west",
            "region_id": "396938492473180164",
            "slug": "devemulation1",
            "status": "interactive",
            "type": "emulation"
        },
        {
            "id": "408558697579675649",
            "is_managed": true,
            "is_persistent": true,
            "is_ztp": true,
            "name": "Test2",
            "region": "us-west",
            "region_id": "396938492473180164",
            "slug": "test",
            "status": 'stopped',
            "type": "emulation"
        }
    ],
    "type": "array"
}

This endpoint retrieves all emulations in your account.

Key attributes of each emulation are:

Attribute Description
id Unique ID of the emulation
is_managed Is Tesuto allowed to deploy its auth keys to emulated devices for configuration management
is_ztp Should Tesuto bootstrap emulated devices and setup management network
name Human readable name of the emulation
slug Machine readable name generated from emulation name. This is used to generated part of FQDN to connect to emulated devices
status Status of the emulation
region Cloud region that will host the emulation

Get a single emulation

Sample Request:

from tesuto import tesuto

# Get emulation by ID
emulation_id = 421514767692595201
emulation = tesuto.apis.Emulation.get(emulation_id).data

# Print all attributes of the emulation
tesuto.console.output(emulation)

export EMULATION_ID=421514767692595201
curl -X GET "https://api.tesuto.com/v1/emulations/$EMULATION_ID" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "access": {
        "data": [],
        "type": "array"
    },
    "devices": {
        "data": [
            {
                "can_snapshot": false,
                "config_id": "421514768028041217",
                "id": "421514767816622083",
                "interfaces": [
                    "Ethernet[1-9]"
                ],
                "is_enabled": true,
                "model_id": "302946505334882305",
                "model_name": "cEOS",
                "name": "ceos",
                "slug": "ceos",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "302946505188638721",
                "vendor_name": "Arista",
                "version_id": "335144213556854785",
                "version_name": "4.21.0F"
            },
            {
                "can_snapshot": false,
                "config_id": "421514768305160195",
                "id": "421514768123232259",
                "interfaces": [
                    "ge-0/0/[0-9]"
                ],
                "is_enabled": true,
                "model_id": "302946507183751169",
                "model_name": "MX",
                "name": "vmx",
                "slug": "vmx",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "302946507091476481",
                "vendor_name": "Juniper",
                "version_id": "370003634542706691",
                "version_name": "18.2R1.9"
            },
            {
                "can_snapshot": false,
                "config_id": null,
                "id": "421514768397238273",
                "interfaces": [
                    "gigabit[1-26]"
                ],
                "is_enabled": true,
                "model_id": "346275319127900161",
                "model_name": "CSR1000v",
                "name": "csr",
                "slug": "csr",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "346274673784750081",
                "vendor_name": "Cisco",
                "version_id": "396321735668989955",
                "version_name": "16.8.1"
            }
        ],
        "type": "array"
    },
    "id": 421514767692595201,
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "emulation1",
    "region": "us-west",
    "region_id": 396938492473180164,
    "slug": "emulation1",
    "status": null,
    "topologies": {
        "data": [
            {
                "device": "ceos",
                "device_id": 421514767816622083,
                "id": "421514769478746113",
                "interface": "Ethernet5",
                "neighbor": "vmx",
                "neighbor_id": 421514768123232259,
                "neighbor_interface": "ge-0/0/6",
                "type": "emulation_topology"
            },
            {
                "device": "vmx",
                "device_id": 421514768123232259,
                "id": "421514769793744897",
                "interface": "ge-0/0/2",
                "neighbor": "csr",
                "neighbor_id": 421514768397238273,
                "neighbor_interface": "gigabit3",
                "type": "emulation_topology"
            },
            {
                "device": "csr",
                "device_id": 421514768397238273,
                "id": "421514770092752897",
                "interface": "gigabit5",
                "neighbor": "ceos",
                "neighbor_id": 421514767816622083,
                "neighbor_interface": "Ethernet7",
                "type": "emulation_topology"
            }
        ],
        "type": "array"
    },
    "type": "emulation",
    "validators": {
        "data": [],
        "type": "array"
    }
}
{
    "access": {
        "data": [],
        "type": "array"
    },
    "devices": {
        "data": [
            {
                "can_snapshot": false,
                "config_id": "421514768028041217",
                "id": "421514767816622083",
                "interfaces": [
                    "Ethernet[1-9]"
                ],
                "is_enabled": true,
                "model_id": "302946505334882305",
                "model_name": "cEOS",
                "name": "ceos",
                "slug": "ceos",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "302946505188638721",
                "vendor_name": "Arista",
                "version_id": "335144213556854785",
                "version_name": "4.21.0F"
            },
            {
                "can_snapshot": false,
                "config_id": "421514768305160195",
                "id": "421514768123232259",
                "interfaces": [
                    "ge-0/0/[0-9]"
                ],
                "is_enabled": true,
                "model_id": "302946507183751169",
                "model_name": "MX",
                "name": "vmx",
                "slug": "vmx",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "302946507091476481",
                "vendor_name": "Juniper",
                "version_id": "370003634542706691",
                "version_name": "18.2R1.9"
            },
            {
                "can_snapshot": false,
                "config_id": null,
                "id": "421514768397238273",
                "interfaces": [
                    "gigabit[1-26]"
                ],
                "is_enabled": true,
                "model_id": "346275319127900161",
                "model_name": "CSR1000v",
                "name": "csr",
                "slug": "csr",
                "snapshot_id": null,
                "status": null,
                "type": "emulation_device",
                "vendor_id": "346274673784750081",
                "vendor_name": "Cisco",
                "version_id": "396321735668989955",
                "version_name": "16.8.1"
            }
        ],
        "type": "array"
    },
    "id": "421514767692595201",
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "emulation1",
    "region": "us-west",
    "region_id": "396938492473180164",
    "slug": "emulation1",
    "status": null,
    "topologies": {
        "data": [
            {
                "device": "ceos",
                "device_id": 421514767816622083,
                "id": "421514769478746113",
                "interface": "Ethernet5",
                "neighbor": "vmx",
                "neighbor_id": 421514768123232259,
                "neighbor_interface": "ge-0/0/6",
                "type": "emulation_topology"
            },
            {
                "device": "vmx",
                "device_id": 421514768123232259,
                "id": "421514769793744897",
                "interface": "ge-0/0/2",
                "neighbor": "csr",
                "neighbor_id": 421514768397238273,
                "neighbor_interface": "gigabit3",
                "type": "emulation_topology"
            },
            {
                "device": "csr",
                "device_id": 421514768397238273,
                "id": "421514770092752897",
                "interface": "gigabit5",
                "neighbor": "ceos",
                "neighbor_id": 421514767816622083,
                "neighbor_interface": "Ethernet7",
                "type": "emulation_topology"
            }
        ],
        "type": "array"
    },
    "type": "emulation",
    "validators": {
        "data": [],
        "type": "array"
    }
}

This call/function will retrieve more detailed information about a single emulation.

You will see some additional sections listed compared to what was returned in /emulations.

devices will list all the devices in this emulation.

topologies describes how devices in the emulation are linked together.

We will discuss these in more details under related API calls to create devices and topologies.

Accessing nested objects

Retrieve the emulation:

from tesuto import tesuto

# Get emulation by ID
emulation_id = 421514767692595201
emulation = tesuto.apis.Emulation.get(emulation_id).data

Access topology object:

# Only supported in python
print("Topology mapping")
for link in emulation['topologies']:
    # Accessing a single attribute
    print('{}:{} <=> {}:{}'.format(
        link['device'],
        link['interface'],
        link['neighbor'],
        link['neighbor_interface']
        ))
    # List all attributes of the topology object
    tesuto.console.output(link)

# Only supported in python

Sample Response:

Topology mapping
ceos:Ethernet5 <=> vmx:ge-0/0/6
vmx:ge-0/0/2 <=> csr:gigabit3
csr:gigabit5 <=> ceos:Ethernet7
# Only supported in python

Access host objects:

# Only supported in python

for device in emulation['devices']:
    # Print all device attributes
    tesuto.console.output(device)
    # Accessing a single attribute
    print(device['name'])

# Only supported in python

Sample Response:

{
    "can_snapshot": false,
    "config_id": "421514768028041217",
    "emulation_id": null,
    "id": 421514767816622083,
    "interfaces": [
        "Ethernet[1-9]"
    ],
    "is_enabled": true,
    "model_id": "302946505334882305",
    "model_name": "cEOS",
    "name": "ceos",
    "slug": "ceos",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 302946505188638721,
    "vendor_name": "Arista",
    "version_id": "335144213556854785",
    "version_name": "4.21.0F"
}
ceos
{
    "can_snapshot": false,
    "config_id": "421514768305160195",
    "emulation_id": null,
    "id": 421514768123232259,
    "interfaces": [
        "ge-0/0/[0-9]"
    ],
    "is_enabled": true,
    "model_id": "302946507183751169",
    "model_name": "MX",
    "name": "vmx",
    "slug": "vmx",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 302946507091476481,
    "vendor_name": "Juniper",
    "version_id": "370003634542706691",
    "version_name": "18.2R1.9"
}
vmx
{
    "can_snapshot": false,
    "config_id": null,
    "emulation_id": null,
    "id": 421514768397238273,
    "interfaces": [
        "gigabit[1-26]"
    ],
    "is_enabled": true,
    "model_id": "346275319127900161",
    "model_name": "CSR1000v",
    "name": "csr",
    "slug": "csr",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 346274673784750081,
    "vendor_name": "Cisco",
    "version_id": "396321735668989955",
    "version_name": "16.8.1"
}
csr
# Only supported in python

Check the python example. We will discuss Devices and Topologies objects later on in more details.

Create a new emulation

Sample Request:

from tesuto import tesuto

response = tesuto.apis.Emulation.post(data={'name': 'emulation1'})

# Check the status_code. A 200 indicates the call went though with no issues
print (response.status_code)
# Or in case of failure check response.message

# Check the details of newly created item
tesuto.console.output(response.data)

curl -X POST "https://api.tesuto.com/v1/emulations" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" \
    --header "Content-Type: application/json" \
    --data "{
        \"name\": \"Emulation1\"
    }" | python -m json.tool

Sample Response:

200
{
    "access": null,
    "devices": null,
    "id": 421578010838401027,
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "Emulation1",
    "region": "default",
    "region_id": 396938376316649476,
    "slug": "emulation1",
    "status": null,
    "topologies": null,
    "type": "emulation",
    "validators": null
}
{
    "id": "421531597584891907",
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "Emulation10001",
    "region": "default",
    "region_id": "396938376316649476",
    "slug": "emulation10001",
    "status": null,
    "type": "emulation"
}

Before creating a new emulation you have to decide on few key attributes of an emulation:

Please refer to code examples on how to create a new emulation

Cloned emulations

You have the option to make new emulations an identical clone of a previously existing one.

This feature allows you to quickly create identical copies of your existing emulations. One of the use cases of cloning emulations is to make minor changes to existing ones while preserving the blueprint emulation. 

Note: Once the new emulation is created all future changes applied to it will not reflect back to original emulation that it was cloned from.

To create a cloned emulation add "cloned_emulation_id": <EMULATION ID> to your payload.

Update an emulation

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201
response = tesuto.apis.Emulation.put(emulation_id, data={'name': 'myemulation'})

# Status code of API response
print("status code:", response.status_code)

# To retrieve details of modified emulation
tesuto.console.output(response.data)

EMULATION_ID=421514767692595201
curl -X PUT "https://api.tesuto.com/v1/emulations/$EMULATION_ID" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" \
    --header "Content-Type: application/json" \
    --data "{
        \"name\": \"myemulation\"
    }" | python -m json.tool

Sample Response:

{
    "_endpoint": "emulations/421514767692595201",
    "data": "<<Emulation instance>>",
    "id": null,
    "message": null,
    "status_code": 200
}
{
    "access": null,
    "devices": null,
    "id": 421514767692595201,
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "myemulation",
    "region": "us-west",
    "region_id": 396938492473180164,
    "slug": "myemulation",
    "status": null,
    "topologies": null,
    "type": "emulation",
    "validators": null
}
{
    "id": "421514767692595201",
    "is_managed": true,
    "is_persistent": true,
    "is_ztp": true,
    "name": "myemulation",
    "region": "us-west",
    "region_id": "396938492473180164",
    "slug": "myemulation",
    "status": null,
    "type": "emulation"
}

You can update all emulation attributes before they are started. Once an emulation starts, the following fields become immutable:

If you need to change any of the above fields, we recommend cloning the emulation.

Delete an emulation

Sample Request:


from tesuto import tesuto

emulation_id = 423508715825397763
response = tesuto.apis.Emulation.delete(emulation_id)
tesuto.console.output(response)

export EMULATION_ID=421514767692595201
curl -X DELETE "https://api.tesuto.com/v1/emulations/$EMULATION_ID"  \
   --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "_endpoint": "emulations/423508715825397763",
    "data": "<<Emulation instance>>",
    "id": null,
    "message": null,
    "status_code": 200
}
{
    "deleted": true,
    "id": "421514767692595201"
}

You can update all emulation attributes before they are started. Once an emulation starts, the following fields become immutable:

Vendors

Since all devices are created by ID of their vendor, model and version, before talking about how to add devices to an emulation we will explain how to get a list of supported vendors, models and versions in Tesuto platform.

List all vendors

Sample Request:

from tesuto import tesuto

vendors = tesuto.apis.Vendor.list().data
for vendor in vendors:
    tesuto.console.output(vendor)
curl -X GET "https://api.tesuto.com/v1/vendors" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "eula_accepted": true,
    "eula_url": "https://www.arista.com/assets/data/pdf/software-agreement/EndUserLicenseAgreement.pdf",
    "id": 302946505188638721,
    "name": "Arista",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": "https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html",
    "id": 346274673784750081,
    "name": "Cisco",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": "https://cumulusnetworks.com/eula/latest/print/",
    "id": 317017797315559425,
    "name": "Cumulus",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": "https://support.juniper.net/support/eula/",
    "id": 302946507091476481,
    "name": "Juniper",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": "http://demo.mt.lv/help/license.html",
    "id": 417847854051360769,
    "name": "Mikrotik",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": "https://www.tesuto.com/tos/",
    "id": 309956908721995777,
    "name": "Tesuto",
    "type": "vendor"
}
{
    "eula_accepted": true,
    "eula_url": null,
    "id": 391874154449534977,
    "name": "VyOS",
    "type": "vendor"
}
{
    "data": [
        {
            "eula_accepted": true,
            "eula_url": "https://www.arista.com/assets/data/pdf/software-agreement/EndUserLicenseAgreement.pdf",
            "id": "302946505188638721",
            "name": "Arista",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": "https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html",
            "id": "346274673784750081",
            "name": "Cisco",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": "https://cumulusnetworks.com/eula/latest/print/",
            "id": "317017797315559425",
            "name": "Cumulus",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": "https://support.juniper.net/support/eula/",
            "id": "302946507091476481",
            "name": "Juniper",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": "http://demo.mt.lv/help/license.html",
            "id": "417847854051360769",
            "name": "Mikrotik",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": "https://www.tesuto.com/tos/",
            "id": "309956908721995777",
            "name": "Tesuto",
            "status": "enabled",
            "type": "vendor"
        },
        {
            "eula_accepted": true,
            "eula_url": null,
            "id": "391874154449534977",
            "name": "VyOS",
            "status": "enabled",
            "type": "vendor"
        }
    ],
    "type": "array"
}

Here is some of the important fields in Vendor object:

Attribute Description
id Unique ID of the vendor. You need this ID to retrieve models available from this vendor
eula_accepted Boolean, Indicates if you have accepted the vendor's end user license agreement. Note: You will not be able to add devices from a vendor unless you have accepted the license agreements of that vendor and upload a valid license version for the software versions you are planning to use
name Name of the emulation

Get models of a vendor

Sample Request:

from tesuto import tesuto

vendor_id = 302946507091476481 # Juniper's vendor id
models = tesuto.apis.VendorModel.list(map_args=[vendor_id]).data
for model in models:
    tesuto.console.output(model)
export VENDOR_ID=302946507091476481
curl -X GET "https://api.tesuto.com/v1/vendors/$VENDOR_ID/models" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "id": 302946505334882305,
    "interface_template": "Ethernet[1-64]",
    "name": "cEOS",
    "type": "vendor_model"
}
{
    "id": 334652738673934337,
    "interface_template": "Ethernet[1-24]",
    "name": "vEOS",
    "type": "vendor_model"
}
{
    "data": [
        {
            "id": "302946507183751169",
            "interface_list": [
                "gigabitethernet-",
                "ge-",
                "xe-"
            ],
            "interface_template": "ge-0/0/[0-48]",
            "name": "MX",
            "type": "vendor_model"
        },
        {
            "id": "343449669140807681",
            "interface_list": null,
            "interface_template": null,
            "name": "NorthStar-Junos",
            "type": "vendor_model"
        },
        {
            "id": "302946507373740033",
            "interface_list": [
                "gigabitethernet-",
                "ge-",
                "xe-"
            ],
            "interface_template": "gigabitethernet-0/0/[0-18]",
            "name": "QFX",
            "type": "vendor_model"
        },
        {
            "id": "400400495119138819",
            "interface_list": [
                "gigabitethernet-",
                "ge-",
                "xe-"
            ],
            "interface_template": "ge-0/0/[0-48]",
            "name": "SRX",
            "type": "vendor_model"
        }
    ],
    "type": "array"
}

In the response you can see the ModelID which will be used to retrieve software versions available for that model. Make a note of interface_template. You are going to need this for creating your devices in emulations. For generic use cases we recommend that you create your virtual devices with the exact interface ranges as shown by interface_template.

Get versions of a model

Sample Request:

from tesuto import tesuto

vendor_id = 302946505188638721
model_id = 302946505334882305

versions = tesuto.apis.VendorModelVersion.list(map_args=[vendor_id, model_id]).data

for version in versions:
    tesuto.console.output(version)

export VENDOR_ID=302946505188638721
export MODEL_ID=302946505334882305
curl -X GET "https://api.tesuto.com/v1/vendors/$VENDOR_ID/models/$MODEL_ID/versions" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "can_snapshot": false,
    "file_hash": "md5:c8f36425c841091e4ba40b0e3a4fa4e6",
    "file_name": "cEOS-lab.tar.xz",
    "id": 335144213556854785,
    "licensed": false,
    "name": "4.21.0F",
    "type": "vendor_model_version"
}
{
more work on vendors
{
    "data": [
        {
            "can_snapshot": false,
            "file_hash": "md5:c8f36425c841091e4ba40b0e3a4fa4e6",
            "file_name": "cEOS-lab.tar.xz",
            "id": "335144213556854785",
            "licensed": false,
            "name": "4.21.0F",
            "requires": null,
            "status": "restricted",
            "type": "vendor_model_version"
        }
    ],
    "type": "array"
}

This API call will return software versions available for a given vendor and model. You need the ID when creating a device under an emulation.

Attribute Description
can_snapshot Specifies if you can create a live snapshot of this software version and save it for future deployment.
licensed Return true if your account is licensed to use this specific software version
file_name To activate licensing of this software, what is the file that you have to download from Vendor's website and upload it to Tesuto
file_hash MD5sum of vendor software image

Devices

This section describes how you can add devices to each emulation and edit/remove them.

Get all devices

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201

devices = tesuto.apis.EmulationDevice.list(map_args=[emulation_id]).data
for device in devices:
    tesuto.console.output(device)
export EMULATION_ID=421514767692595201
curl -X GET "https://api.tesuto.com/v1/emulations/$EMULATION_ID/devices" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "can_snapshot": false,
    "config_id": "421514768028041217",
    "emulation_id": null,
    "id": 421514767816622083,
    "interfaces": [
        "Ethernet[1-9]"
    ],
    "is_enabled": true,
    "model_id": "302946505334882305",
    "model_name": "cEOS",
    "name": "ceos",
    "slug": "ceos",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 302946505188638721,
    "vendor_name": "Arista",
    "version_id": "335144213556854785",
    "version_name": "4.21.0F"
}
{
    "can_snapshot": false,
    "config_id": "421514768305160195",
    "emulation_id": null,
    "id": 421514768123232259,
    "interfaces": [
        "ge-0/0/[0-9]"
    ],
    "is_enabled": true,
    "model_id": "302946507183751169",
    "model_name": "MX",
    "name": "vmx",
    "slug": "vmx",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 302946507091476481,
    "vendor_name": "Juniper",
    "version_id": "370003634542706691",
    "version_name": "18.2R1.9"
}
{
    "can_snapshot": false,
    "config_id": null,
    "emulation_id": null,
    "id": 421514768397238273,
    "interfaces": [
        "gigabit[1-26]"
    ],
    "is_enabled": true,
    "model_id": "346275319127900161",
    "model_name": "CSR1000v",
    "name": "csr",
    "slug": "csr",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 346274673784750081,
    "vendor_name": "Cisco",
    "version_id": "396321735668989955",
    "version_name": "16.8.1"
}
{
    "data": [
        {
            "can_snapshot": false,
            "config_id": "421514768028041217",
            "id": "421514767816622083",
            "interfaces": [
                "Ethernet[1-9]"
            ],
            "is_enabled": true,
            "model_id": "302946505334882305",
            "model_name": "cEOS",
            "name": "ceos",
            "slug": "ceos",
            "snapshot_id": null,
            "status": null,
            "type": "emulation_device",
            "vendor_id": "302946505188638721",
            "vendor_name": "Arista",
            "version_id": "335144213556854785",
            "version_name": "4.21.0F"
        },
        {
            "can_snapshot": false,
            "config_id": "421514768305160195",
            "id": "421514768123232259",
            "interfaces": [
                "ge-0/0/[0-9]"
            ],
            "is_enabled": true,
            "model_id": "302946507183751169",
            "model_name": "MX",
            "name": "vmx",
            "slug": "vmx",
            "snapshot_id": null,
            "status": null,
            "type": "emulation_device",
            "vendor_id": "302946507091476481",
            "vendor_name": "Juniper",
            "version_id": "370003634542706691",
            "version_name": "18.2R1.9"
        },
        {
            "can_snapshot": false,
            "config_id": null,
            "id": "421514768397238273",
            "interfaces": [
                "gigabit[1-26]"
            ],
            "is_enabled": true,
            "model_id": "346275319127900161",
            "model_name": "CSR1000v",
            "name": "csr",
            "slug": "csr",
            "snapshot_id": null,
            "status": null,
            "type": "emulation_device",
            "vendor_id": "346274673784750081",
            "vendor_name": "Cisco",
            "version_id": "396321735668989955",
            "version_name": "16.8.1"
        }
    ],
    "type": "array"
}

Here are the details of Devices object:

Attribute Description
id Unique ID of the device
name Hostname of the device
vendor_name Vendor of the device
model_name Model of the device
version_name Version of the device
vendor_id ID of the device vendor
model_id ID of the device model
version_id ID of the device version
model_id What is the model of the device
version_id What software version the device is running on
interfaces Interfaces of the device
is_enabled Set this to False if you don't want the device to launch automatically with the emulation
config_id If not null it indicates a config is present for this device

Get a single device

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201
device_id = 421514768397238273

device = tesuto.apis.EmulationDevice.get(device_id).data
tesuto.console.output(device)
export DEVICE_ID=421514768397238273
curl -X GET "https://api.tesuto.com/v1/emulations/$EMULATION_ID/devices/$DEVICE_ID" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "can_snapshot": false,
    "config_id": null,
    "emulation_id": null,
    "id": 421514768397238273,
    "interfaces": [
        "gigabit[1-26]"
    ],
    "is_enabled": true,
    "model_id": "346275319127900161",
    "model_name": "CSR1000v",
    "name": "csr",
    "slug": "csr",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 346274673784750081,
    "vendor_name": "Cisco",
    "version_id": "396321735668989955",
    "version_name": "16.8.1"
}
{
    "can_snapshot": false,
    "config_id": null,
    "id": "421514768397238273",
    "interfaces": [
        "gigabit[1-26]"
    ],
    "is_enabled": true,
    "model_id": "346275319127900161",
    "model_name": "CSR1000v",
    "name": "csr",
    "slug": "csr",
    "snapshot_id": null,
    "status": null,
    "type": "emulation_device",
    "vendor_id": "346274673784750081",
    "vendor_name": "Cisco",
    "version_id": "396321735668989955",
    "version_name": "16.8.1"
}

You can get details of a specific device with this API call. Emulation ID and Device ID are required.

Create a new device

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201
vendor_id = 346274673784750081  # Cisco
model_id = 399130602399432705   # Nexus
version_id = 399130602495770625 # 7.0.3.I7.4

response = tesuto.apis.EmulationDevice.post(
    data={
        'name': 'nexus',
        'vendor_id': vendor_id,
        'model_id': model_id,
        'version_id': version_id,
        'interfaces': ['ethernet1/[1-24]']
    },
    map_args=[emulation_id]
)

print("status code:", response.status_code)
tesuto.console.output(response.data)
export EMULATION_ID=421514767692595201
export VENDOR_ID=346274673784750081
export MODEL_ID=399130602399432705
export VERSION_ID=399130602495770625

curl -X POST "https://api.tesuto.com/v1/emulations/$EMULATION_ID/devices" \
--header "Authorization: Bearer $TESUTO_API_TOKEN" \
--header "content-type: application/json" \
--data "{
        \"name\"        : \"nexus2\",
        \"vendor_id\"   : $VENDOR_ID,
        \"model_id\"    : $MODEL_ID,
        \"version_id\"  : $VERSION_ID,
        \"interfaces\"  : [ \"ethernet1/[1-24]\" ]
}" | python -m json.tool

Sample Response:

status code: 200
{
    "can_snapshot": false,
    "config_id": null,
    "emulation_id": null,
    "id": 423606732791611393,
    "interfaces": [
        "ethernet1/[1-24]"
    ],
    "is_enabled": true,
    "model_id": "399130602399432705",
    "model_name": "NX-OSv",
    "name": "nexus22",
    "slug": "nexus22",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 346274673784750081,
    "vendor_name": "Cisco",
    "version_id": "399130602495770625",
    "version_name": "7.0.3.I7.4"
}
{
    "can_snapshot": false,
    "config_id": null,
    "id": "423603866388725763",
    "interfaces": [
        "ethernet1/[1-24]"
    ],
    "is_enabled": true,
    "model_id": "399130602399432705",
    "model_name": "NX-OSv",
    "name": "nexus2",
    "slug": "nexus2",
    "snapshot_id": null,
    "status": null,
    "type": "emulation_device",
    "vendor_id": "346274673784750081",
    "vendor_name": "Cisco",
    "version_id": "399130602495770625",
    "version_name": "7.0.3.I7.4"
}

Minimum fields required to create a new device are:

Update a device

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201
device_id = 423603866388725763

response = tesuto.apis.EmulationDevice.put(
    device_id,
    data={
        'name': 'nexus-3',
    },
    map_args=[emulation_id]
)

print("status code:", response.status_code)
tesuto.console.output(response.data)
export EMULATION_ID=421514767692595201
export DEVICE_ID=423603866388725763
curl -X PUT "https://api.tesuto.com/v1/emulations/$EMULATION_ID/devices/$DEVICE_ID" \
--header "Authorization: Bearer $TESUTO_API_TOKEN" \
--header "content-type: application/json" \
--data "{
        \"name\"        : \"nexus-2\"
}" | python -m json.tool

Sample Response:

status code: 200
{
    "can_snapshot": false,
    "config_id": null,
    "emulation_id": null,
    "id": 423603866388725763,
    "interfaces": [
        "ethernet1/[1-24]"
    ],
    "is_enabled": true,
    "model_id": "399130602399432705",
    "model_name": "NX-OSv",
    "name": "nexus-3",
    "slug": "nexus-3",
    "snapshot_id": null,
    "snapshot_name": null,
    "type": "emulation_device",
    "vendor_id": 346274673784750081,
    "vendor_name": "Cisco",
    "version_id": "399130602495770625",
    "version_name": "7.0.3.I7.4"
}
{
    "can_snapshot": false,
    "config_id": null,
    "id": "423603866388725763",
    "interfaces": [
        "ethernet1/[1-24]"
    ],
    "is_enabled": true,
    "model_id": "399130602399432705",
    "model_name": "NX-OSv",
    "name": "nexus-2",
    "slug": "nexus-2",
    "snapshot_id": null,
    "status": null,
    "type": "emulation_device",
    "vendor_id": "346274673784750081",
    "vendor_name": "Cisco",
    "version_id": "399130602495770625",
    "version_name": "7.0.3.I7.4"
}

Delete a device

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201
device_id = 423607088861609985

response = tesuto.apis.EmulationDevice.delete(
    device_id,
    map_args=[emulation_id]
)

print("status code:", response.status_code)
export EMULATION_ID=421514767692595201
export DEVICE_ID=423603866388725763
curl -X DELETE "https://api.tesuto.com/v1/emulations/$EMULATION_ID/devices/$DEVICE_ID" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

status code: 200
{
    "deleted": true,
    "id": 423603866388725763
}

Note: Deleting a device will remove all of the topology links associated with the device as well.

Topologies

List all topologies

Sample Request:

from tesuto import tesuto

emulation_id = 421514767692595201

response = tesuto.apis.EmulationTopology.list(
    map_args=[emulation_id]
)
tesuto.console.output(response.data)
export EMULATION_ID=421514767692595201 # Change this to an emulation ID In your account
curl -X GET "https://api.tesuto.com/v1/emulations/$EMULATION_ID/topologies" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" | python -m json.tool

Sample Response:

{
    "data": [
        {
            "device": "ceos",
            "device_id": null,
            "id": 421514769478746113,
            "interface": "Ethernet5",
            "neighbor": "vmx",
            "neighbor_interface": "ge-0/0/6",
            "type": "emulation_topology"
        },
        {
            "device": "vmx",
            "device_id": null,
            "id": 421514769793744897,
            "interface": "ge-0/0/2",
            "neighbor": "csr",
            "neighbor_interface": "gigabit3",
            "type": "emulation_topology"
        },
        {
            "device": "csr",
            "device_id": null,
            "id": 421514770092752897,
            "interface": "gigabit5",
            "neighbor": "ceos",
            "neighbor_interface": "Ethernet7",
            "type": "emulation_topology"
        },
        {
            "device": "vmx",
            "device_id": null,
            "id": 423026445900578819,
            "interface": "ge-0/0/0",
            "neighbor": "ceos",
            "neighbor_interface": "Ethernet1",
            "type": "emulation_topology"
        }
    ],
    "type": "array"
}
{
    "data": [
        {
            "device": "ceos",
            "id": "423026445900578819",
            "interface": "Ethernet1",
            "neighbor": "vmx",
            "neighbor_interface": "ge-0/0/0",
            "type": "emulation_topology"
        },
        {
            "device": "ceos",
            "interface": "Ethernet2",
            "type": "emulation_topology"
        }
    ]
}

Topology is a simple 4 tuple describing the edges of the graph. Links are bi-directional and the following fields form a topology:

Create a topology

Sample Request:



curl -X POST "https://api.tesuto.com/v1/emulations/$EMULATION_ID/topologies" \
    --header "Authorization: Bearer $TESUTO_API_TOKEN" \
     --header "Content-Type: application/json" \
     -d '{
        "data": [
            {
                "device": "rtr1",
                "interface": "Ethernet1",
                "neighbor": "rtr2",
                "neighbor_interface": "ge-0/0/0"
            }
        ]
    }'

Sample Response:


{
    "data": [
        {
            "device": "rtr1",
            "device_id": 423789406026924035,
            "id": "423792460519047169",
            "interface": "Ethernet4",
            "neighbor": "rtr2",
            "neighbor_id": 423789438394793987,
            "neighbor_interface": "ge-0/0/4",
            "type": "emulation_topology"
        }
    ],
    "type": "array"
}

Note: You only need the router hostname for creating new topologies not the device_ids.

Controlling emulations

Regions

Filtering