Skip to main content

IxNetwork REST API Python Client

Project description

The IxNetwork Python Client

pypi python license downloads

Install the package

pip install --upgrade ixnetwork-restpy

Start scripting

"""This script demonstrates how to get started with ixnetwork_restpy scripting.

The script demonstrates the following:
    - connect to an IxNetwork test platform and authenticate
    - add a new session
    - clear any existing configuration
    - create 1 tx port and 2 rx ports
    - create traffic from the tx port to the rx ports
    - start traffic
    - print statistics
    - stop traffic
"""
from ixnetwork_restpy.testplatform.testplatform import TestPlatform
from ixnetwork_restpy.assistants.ports.portmapassistant import PortMapAssistant
from ixnetwork_restpy.assistants.statistics.statviewassistant import StatViewAssistant


# connect to a test tool platform
test_platform = TestPlatform('127.0.0.1')
test_platform.Authenticate('admin', 'admin')
sessions = test_platform.Sessions.add()
ixnetwork = sessions.Ixnetwork
ixnetwork.NewConfig()

# create one tx port and two rx port resources
port_map = PortMapAssistant(ixnetwork)
port_map.Map('10.36.74.26', 2, 13, Name='Tx')
port_map.Map('10.36.74.26', 2, 14, Name='Rx1')
port_map.Map('10.36.74.26', 2, 15, Name='Rx2')

# create a TrafficItem resource
# TrafficItem acts a a high level container for ConfigElement resources
# ConfigElement is a high level container for individual HighLevelStream resources
traffic_item = ixnetwork.Traffic.TrafficItem.add(Name='Traffic Test', TrafficType='raw')
traffic_item.EndpointSet.add(
    Sources=ixnetwork.Vport.find(Name='^Tx').Protocols.find(), 
    Destinations=ixnetwork.Vport.find(Name='^Rx').Protocols.find())

# using the traffic ConfigElement resource
# update the frame rate
# update the transmission control
traffic_config = traffic_item.ConfigElement.find()
traffic_config.FrameRate.update(Type='percentLineRate', Rate='100')
traffic_config.TransmissionControl.update(Type='continuous')

# adjust Ethernet stack fields
destination_mac = traffic_config.Stack.find(StackTypeId='ethernet').Field.find(FieldTypeId='ethernet.header.destinationAddress')
destination_mac.update(ValueType='valueList', ValueList=['00:00:fa:ce:fa:ce', '00:00:de:ad:be:ef'], TrackingEnabled=True)

# push ConfigElement settings down to HighLevelStream resources
traffic_item.Generate()

# connect ports to hardware test ports
# apply traffic to hardware
# start traffic
port_map.Connect(ForceOwnership=True)
ixnetwork.Traffic.Apply()
ixnetwork.Traffic.StartStatelessTrafficBlocking()

# print statistics
print(StatViewAssistant(ixnetwork, 'Port Statistics'))
print(StatViewAssistant(ixnetwork, 'Traffic Item Statistics'))
print(StatViewAssistant(ixnetwork, 'Flow Statistics'))

# stop traffic
ixnetwork.Traffic.StopStatelessTrafficBlocking()

Documentation

Documentation is available using the following methods:

  • Online web based documentation

  • Documentation available in the online doc browser is also inlined in each class, property and method and can be viewed using the python help command

    from ixnetwork_restpy.testplatform.testplatform import TestPlatform
    
    help(TestPlatform)
    

Additional Samples

Visit the OpenIxia ixnetwork-restpy sample site maintained by solution architects for in depth end-to-end samples that demonstrate the following:

  • building a configuration
    • from scratch
    • from an existing IxNetwork configuration
  • running the configuration
    • connecting ports to hardware
    • starting protocols
    • starting traffic
  • getting statistics
    • port stats
    • traffic stats

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ixnetwork_restpy-1.0.47.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ixnetwork_restpy-1.0.47-py2.py3-none-any.whl (10.6 MB view details)

Uploaded Python 2Python 3

File details

Details for the file ixnetwork_restpy-1.0.47.tar.gz.

File metadata

  • Download URL: ixnetwork_restpy-1.0.47.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for ixnetwork_restpy-1.0.47.tar.gz
Algorithm Hash digest
SHA256 7c68a6c7c353ba1ab510d2b8bad050b4c057436544fd2361b89416a26cda24f4
MD5 22752cf9363bc8951968d69a1be6963a
BLAKE2b-256 21a6f850d6d26d240751365f9c1af2705cdd226c782dbfee7d99925e2ee5be0a

See more details on using hashes here.

File details

Details for the file ixnetwork_restpy-1.0.47-py2.py3-none-any.whl.

File metadata

  • Download URL: ixnetwork_restpy-1.0.47-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.6 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for ixnetwork_restpy-1.0.47-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d36e5ed8def0b8f0b6a314e90dcdbcfa91df0bd2e01d986a9d4eb82d567acd39
MD5 88d18d337255a57f4e0bc4d9058a07db
BLAKE2b-256 2cd0b7f11843ca99363eceaf806a3f2c2e55141b80594f7454c05fc4244b5734

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page