Beispiel #1
0
def ixia_api_server_session(ixia_api_serv_ip, ixia_api_serv_user,
                            ixia_api_serv_passwd, ixia_api_serv_port,
                            ixia_api_serv_session_id):
    """
    Ixia session manager fixture.

    Args:
        ixia_api_serv_ip (pytest fixture): ixia_api_serv_ip fixture
        ixia_api_serv_user (pytest fixture): ixia_api_serv_user fixture.
        ixia_api_serv_passwd (pytest fixture): ixia_api_serv_passwd fixture.
        ixia_api_serv_port (pytest fixture): ixia_api_serv_port fixture.
        ixia_api_serv_session_id (pytest fixture): ixia_api_serv_session_id 
            fixture.
  
    Returns:
        IxNetwork Session
    """

    if (ixia_api_serv_session_id.lower() != 'none'):
        session = SessionAssistant(IpAddress=ixia_api_serv_ip,
                                   UserName=ixia_api_serv_user,
                                   Password=ixia_api_serv_passwd,
                                   RestPort=ixia_api_serv_port,
                                   SessionId=ixia_api_serv_session_id)
    else:
        session = SessionAssistant(IpAddress=ixia_api_serv_ip,
                                   UserName=ixia_api_serv_user,
                                   Password=ixia_api_serv_passwd,
                                   RestPort=ixia_api_serv_port,
                                   LogLevel='all',
                                   LogFilename='restpy.log')
    ixNetwork = session.Ixnetwork
    ixNetwork.NewConfig()

    yield session
Beispiel #2
0
 def _connect(self):
     """Connect to an IxNetwork API Server.
     """
     if self._assistant is None:
         self._assistant = SessionAssistant(
             IpAddress=self._address,
             RestPort=self._port,
             UserName=self._username,
             Password=self._password,
             LogLevel=SessionAssistant.LOGLEVEL_INFO)
         self._ixnetwork = self._assistant.Ixnetwork
         self._vport = self._ixnetwork.Vport
         self._topology = self._ixnetwork.Topology
         self._traffic = self._ixnetwork.Traffic
         self._traffic_item = self._ixnetwork.Traffic.TrafficItem
    def connect(self):
        logger.info(f'Connecting to IxNetwork API via {self.rest_server_ip}:{self.port}')
        self.session = SessionAssistant(IpAddress=self.rest_server_ip, RestPort=self.port,
                                        UserName=self.username, Password=self.password,
                                        SessionName=None, SessionId=self.session_id, ApiKey=None,
                                        ClearConfig=self.clear_config, LogLevel=self.log_level,
                                        LogFilename=self.logfile)
        self.ixnetwork = self.session.Ixnetwork
        self.requests_session = self.ixnetwork._connection._session

        # Connect to chassis
        if self.chassis_ip is not None:
            chassisStatus = self.ixnetwork.AvailableHardware.Chassis.add(Hostname=self.chassis_ip,
                                                                         ChainTopology=self.chain_topology,
                                                                         MasterChassis=self.master_chassis,
                                                                         SequenceId=self.sequence_id,
                                                                         CableLength=self.cable_length)
            if chassisStatus.State != 'ready':
                raise Exception('Chassis not in ready state, found state {}'.format(chassisStatus.State))
   - Minimum IxNetwork 8.50
   - Python 2.7 and 3+
   - pip install requests
   - pip install ixnetwork_restpy (minimum version 1.0.51)

RestPy Doc:
    https://www.openixia.github.io/ixnetwork_restpy
"""

import os, sys, time, traceback

# Import the RestPy module
from ixnetwork_restpy import SessionAssistant, Files

try:
    session = SessionAssistant(IpAddress='192.168.70.3',
                               RestPort=None,
                               UserName='******',
                               Password='******',
                               SessionName=None,
                               SessionId=1,
                               ApiKey=None,
                               ClearConfig=False,
                               LogLevel='info')

    ixNetwork = session.Ixnetwork

except Exception as errMsg:
    print('\nError: %s' % traceback.format_exc())
    print('\nrestPy.Exception:', errMsg)
Beispiel #5
0
"""Demonstrates creating ospfv2 devices 

"""
from ixnetwork_restpy import SessionAssistant

session_assistant = SessionAssistant(UserName='******',
                                     Password='******',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO,
                                     ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork

ipv41 = ixnetwork \
    .Topology.add(Vports=ixnetwork.Vport.add()) \
    .DeviceGroup.add(Name='Dg West') \
    .Ethernet.add() \
    .Ipv4.add(Name='Ipv4 West')

ipv42 = ixnetwork \
    .Topology.add(Vports=ixnetwork.Vport.add()) \
    .DeviceGroup.add(Name='Dg East') \
    .Ethernet.add() \
    .Ipv4.add(Name='Ipv4 East')

traffic = ixnetwork.Traffic.TrafficItem.add(Name='West -> East',
                                            TrafficType='ipv4')
traffic.EndpointSet.add(Sources=ipv41, Destinations=ipv42)

test_details = ixnetwork.Timeline.CreateTest(Arg2='rfc2544back2back',
                                             Arg3=None)
print(test_details)
test = ixnetwork.parent.GetObjectFromHref(test_details['arg1'])
Beispiel #6
0
            isLayer3 = True
        except:
            isLayer3 = False
            print('\n\nTopology isLayer3: False\n')

    return isLayer3


try:
    # LogLevel: none, info, warning, request, request_response, all
    session = SessionAssistant(IpAddress=apiServerIp,
                               RestPort=None,
                               Username='******',
                               Password='******',
                               SessionName=None,
                               SessionId=None,
                               ApiKey=None,
                               ApplicationType=applicationType,
                               ClearConfig=True,
                               LogLevel='all',
                               LogFilename='restpy.log')

    ixNetwork = session.Ixnetwork

    ixNetwork.LoadConfig(Files(configFile, local_file=True))

    # Assign ports
    portMap = session.PortMapAssistant()
    vport = dict()
    for index, port in enumerate(portList):
        # For the port name, get the loaded configuration's port name
Beispiel #7
0
#Test Variables
# ospf or isis
igp = 'isis'

# For Linux API server and Windows Connection Mgr only.
#    debugMode=True:  Leave the session opened for debugging.
#    debugMode=False: Remove the session when the script is done.
debugMode = False

try:
    # LogLevel: none, info, warning, request, request_response, all
    session = SessionAssistant(IpAddress=apiServerIp,
                               RestPort=None,
                               UserName='******',
                               Password='******',
                               SessionName=None,
                               SessionId=None,
                               ApiKey=None,
                               ClearConfig=True,
                               LogLevel='all',
                               LogFilename='restpy.log')

    ixNetwork = session.Ixnetwork

    ixNetwork.info('Assign ports')
    portMap = session.PortMapAssistant()
    vport = dict()
    for index, port in enumerate(portList):
        portName = 'Port_{}'.format(index + 1)
        vport[portName] = portMap.Map(IpAddress=port[0],
                                      CardId=port[1],
                                      PortId=port[2],
        # 4> In order to modify the fields, get the field object
        packetHeaderFieldObj = packetHeaderStackObj.Field.find()
        ixNetwork.info('packetHeaderFieldObj: {}'.format(packetHeaderFieldObj))

        # 5> Save the above configuration to the base config file.
        #ixNetwork.SaveConfig(Files('baseConfig.ixncfg', local_file=True))

        return packetHeaderFieldObj

    # LogLevel: none, info, warning, request, request_response, all
    session = SessionAssistant(IpAddress=apiServerIp,
                               RestPort=None,
                               UserName='******',
                               Password='******',
                               SessionName=None,
                               SessionId=None,
                               ApiKey=None,
                               ClearConfig=True,
                               LogLevel='all',
                               LogFilename='restpy.log')

    ixNetwork = session.Ixnetwork

    # Assign ports
    portMap = session.PortMapAssistant()
    vport = dict()
    for index, port in enumerate(portList):
        portName = 'Port_{}'.format(index + 1)
        vport[portName] = portMap.Map(IpAddress=port[0],
                                      CardId=port[1],
                                      PortId=port[2],
Beispiel #9
0
from ixnetwork_restpy import SessionAssistant
from ixnetwork_restpy import TestPlatform
import time
import pprint

session_assistant = SessionAssistant(IpAddress='172.31.194.141',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO,
                                     ClearConfig=True)

ixnetwork = session_assistant.Ixnetwork
test_platform = session_assistant.TestPlatform
test_platform.Trace = TestPlatform.TRACE_INFO

# create tx and rx port resources
port_map = session_assistant.PortMapAssistant()
port_map.Map('172.21.86.100', 9, 14, Name='Tx')
port_map.Map('172.21.86.100', 9, 2, Name='Rx')

eth = test_platform.Sessions.find().Ixnetwork.Vport.find(
    Name='^Tx').L1Config.Ethernet
eth.Media = 'fiber'
eth = test_platform.Sessions.find().Ixnetwork.Vport.find(
    Name='^Rx').L1Config.Ethernet
eth.Media = 'fiber'

# create a TrafficItem resource

#create topology
eth_s = ixnetwork \
        .Topology.add(Vports=ixnetwork.Vport.find(Name='^Tx')) \
        .DeviceGroup.add(Multiplier='1') \
Beispiel #10
0
    def __init__(self,
                 apiServerIp=None,
                 serverIpPort=None,
                 serverOs='windows',
                 linuxChassisIp=None,
                 manageSessionMode=False,
                 webQuickTest=False,
                 username=None,
                 password='******',
                 licenseServerIp=None,
                 licenseMode=None,
                 licenseTier=None,
                 deleteSessionAfterTest=True,
                 verifySslCert=False,
                 includeDebugTraceback=True,
                 sessionId=None,
                 httpsSecured=None,
                 apiKey=None,
                 generateLogFile=True,
                 robotFrameworkStdout=False,
                 linuxApiServerTimeout=120,
                 traceLevel='all'):
        """
        Description
           Initializing default parameters and making a connection to the API server

        Examples
            Right click on "IxNetwork API server", select properties and under target
            ixnetwork.exe -restInsecure -restPort 11009 -restOnAllInterfaces -tclPort 8009

        Parameters
           apiServerIp: (str): The API server IP address.
           serverIpPort: (str): The API server IP address socket port.
           serverOs: (str): windows|windowsConnectionMgr|linux
           linuxChassisIp: (str): Connect to a Linux OS chassis IP address.
           webQuickTest: (bool): True: Using IxNetwork
                                 Web Quick Test. Otherwise, using IxNetwork.
           includeDebugTraceback: (bool):
                                   True: Traceback messsages are
                                   included in raised exceptions.
                                   False: No traceback.
                                   Less verbose for debugging.
           username: (str): The login username. For Linux API server only.
           password: (str): The login password. For Linux API server only.
           licenseServerIp: (str): The license server IP address.
           licenseMode: (str): subscription | perpetual | mixed
           licenseTier: (str): tier1 | tier2 | tier3
           linuxApiServerTimeout: (int): For Linux API server start operation timeout. Defaults
           to 120 seconds.
           deleteSessionAfterTest: (bool): True: Delete the session.
                                           False: Don't delete the session.
           verifySslCert: (str): Optional: Include your SSL certificate for added security.
           httpsSecured: (bool): This parameter is only used by Connection Mgr when user wants to
           connect to an existing session.
                                True = IxNetwork ReST API server is using HTTPS
                                This parameter must also include sessionId
                                and serverIpPort=<the ssl port number>

           serverOs: (str): Defaults to windows.
                            windows|windowsConnectionMgr|linux.
           includeDebugTraceback: (bool): True: Include tracebacks in raised exceptions.
           sessionId: (str): The session ID on the Linux API server or Windows Connection Mgr to
           connect to.
           apiKey: (str): The Linux API server user account API-Key to use for the sessionId
           connection.
           generateLogFile: True|False|<log file name>.
                            If you want to generate a log file, provide the log file name.
                            True = Then the log file default name is ixNetRestApi_debugLog.txt
                            False = Disable generating a log file.
                            <log file name> = The full path + file name of the log file to create.
           robotFrameworkStdout: (bool):  True = Print to stdout.
           httpInsecure: (bool): This parameter is only for Windows connections.
                                True: Using http.  False: Using https.
                                Starting 8.50: IxNetwork defaults to use https.
                                If you are using versions prior to 8.50, it needs to be a http
                                connection. In this case, set httpInsecure=True.

           Notes
              To connect to an existing configuration.
                Windows: Nothing special to include. The session ID is always "1".
                Linux API server: Include the api-key and sessionId that you want to connect to.
                Windows Connection Manager: Include just the sessionId: For example: 8021.
        """

        # Disable SSL warnings
        requests.packages.urllib3.disable_warnings()

        # Disable non http connections.
        from requests.packages.urllib3.exceptions import InsecureRequestWarning
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

        self._session = requests.Session()

        self.serverOs = serverOs  # windows|windowsConnectionMgr|linux
        self.username = username
        self.password = password
        self.apiKey = apiKey
        self.verifySslCert = verifySslCert
        self.apiServerIp = apiServerIp
        self.deleteSessionAfterTest = deleteSessionAfterTest
        self.manageSessionMode = manageSessionMode
        self.apiServerPort = serverIpPort
        self.webQuickTest = webQuickTest
        self.generateLogFile = generateLogFile
        self.robotFrameworkStdout = robotFrameworkStdout
        self.linuxChassisIp = linuxChassisIp
        self.linuxApiServerTimeout = linuxApiServerTimeout
        self.sessionId = sessionId

        logleveldict = {
            'none': SessionAssistant.LOGLEVEL_NONE,
            'info': SessionAssistant.LOGLEVEL_INFO,
            'warning': SessionAssistant.LOGLEVEL_WARNING,
            'request': SessionAssistant.LOGLEVEL_REQUEST,
            'request_response': SessionAssistant.LOGLEVEL_REQUEST_RESPONSE,
            'all': SessionAssistant.LOGLEVEL_ALL
        }
        self.logLevel = logleveldict[traceLevel]

        # Make Robot print to stdout
        if self.robotFrameworkStdout:
            from robot.libraries.BuiltIn import _Misc
            self.robotStdout = _Misc()
            Connect.robotStdout = self.robotStdout

        if generateLogFile:
            # Default the log file name
            self.restLogFile = 'ixNetRestApi_debugLog.txt'
            Connect.enableDebugLogFile = True
            Connect.debugLogFile = self.restLogFile

        if type(generateLogFile) != bool:
            self.restLogFile = generateLogFile

        try:
            session = SessionAssistant(IpAddress=self.apiServerIp,
                                       UserName=self.username,
                                       Password=self.password,
                                       RestPort=serverIpPort,
                                       ApiKey=self.apiKey,
                                       LogFilename=self.restLogFile,
                                       SessionId=self.sessionId,
                                       LogLevel=self.logLevel,
                                       ClearConfig=True)
            self.ixNetwork = session.Ixnetwork
            self.testPlatform = session.TestPlatform
            self.sessionId = session.Ixnetwork.parent.Id
        except (IxNetRestApiException, Exception, KeyboardInterrupt) as errMsg:
            if bool(re.search('ConnectionError', traceback.format_exc())):
                print('\n%s' % traceback.format_exc())
                raise IxNetRestApiException('Connection Error')

            if licenseServerIp or licenseMode or licenseTier:
                self.configLicenseServerDetails(licenseServerIp, licenseMode,
                                                licenseTier)

            # For Linux API Server and Windoww Connection Mgr only:
            # Delete the session when script is done
            self.deleteSessionAfterTest = deleteSessionAfterTest
            if includeDebugTraceback is False:
                sys.tracebacklimit = 0
Beispiel #11
0
from ixnetwork_restpy import SessionAssistant

session_assistant = SessionAssistant(IpAddress='172.31.194.141',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO,
                                     ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork

#create vport to physical port mapping using PortMapAssistant
port_map = session_assistant.PortMapAssistant()
chassis_ip = '172.21.86.100'
lag_ports = [
    dict(Arg1=chassis_ip, Arg2=10, Arg3=17),
    dict(Arg1=chassis_ip, Arg2=10, Arg3=18)
]

port_map.Map('172.21.86.100', 10, 19, Name='VpcRx')

vports_1 = ixnetwork.Vport.add().add()
connected_ports = ixnetwork.AssignPorts(lag_ports, [], vports_1, True)
lag_1 = ixnetwork.Lag.add(Name='Lag 1', Vports=vports_1)
lag_1.ProtocolStack.add().Ethernet.add().Lagportlacp.add()

vports_2 = ixnetwork.Vport.find(Name='^VpcRx')

ethernet1 = ixnetwork.Topology.add(Ports=lag_1).DeviceGroup.add(
    Multiplier=1).Ethernet.add()
ethernet2 = ixnetwork.Topology.add(Ports=vports_2).DeviceGroup.add(
    Multiplier=1).Ethernet.add()

traffic_item = ixnetwork.Traffic.TrafficItem.add(Name='Lag Traffic pyats',
                                                 TrafficType='raw')
Beispiel #12
0
expects the user to manually start traffic.  Change to use API to start traffic if desired.

Dependencies
------------
- pip install ixnetwork-restpy
- pip install websocket-client
"""
from ixnetwork_restpy import SessionAssistant
import time

apiServerIp = '192.168.70.12'

# State which SesionName to connect to or which SessionId to connect to
session = SessionAssistant(IpAddress=apiServerIp,
                           SessionName=None,
                           SessionId=1,
                           ClearConfig=False,
                           LogLevel='all',
                           LogFilename='restpy.log')

ixNetwork = session.Ixnetwork

# State the stats to watch
watchPortCPU = ixNetwork.Statistics.View.find(
    Caption='Port CPU Statistics').Data
watchPortStats = ixNetwork.Statistics.View.find(Caption='Port Statistics').Data
watchTrafficItem = ixNetwork.Statistics.View.find(
    Caption='Traffic Item Statistics').Data

attributes_to_watch = ['pageValues']
topicPortCPU = 'Port CPU Statistics Watch'
topicPortStats = 'Port Statistics Watch'
"""This script demonstrates how to get started with ixnetwork_restpy scripting.

The script demonstrates the following:
    - connect to an IxNetwork test platform, authenticate, add a new session and clear the config
    - create 1 tx port and 1 rx port
    - create traffic from the tx port to the rx port
    - start traffic
    - print statistics
    - stop traffic
"""
from ixnetwork_restpy import SessionAssistant


session_assistant = SessionAssistant(IpAddress='127.0.0.1', 
    LogLevel=SessionAssistant.LOGLEVEL_INFO, 
    ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork

# create tx and rx port resources
port_map = session_assistant.PortMapAssistant()
port_map.Map('10.36.74.26', 2, 13, Name='Tx')
port_map.Map('10.36.74.26', 2, 14, Name='Rx')

# 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())
Beispiel #14
0
# Import the RestPy module
from ixnetwork_restpy import SessionAssistant

apiServerIp = '192.168.70.12'

# windows|connection_manager|linux
osPlatform = 'linux'

# For Linux API server only
username = '******'
password = '******'

try:
    # LogLevel: none, info, warning, request, request_response, all
    session = SessionAssistant(IpAddress=apiServerIp, RestPort=None, UserName='******', Password='******', 
                               SessionName=None, SessionId=15, ApiKey=None,
                               ClearConfig=False, LogLevel='info', LogFilename='restpy.log')

    # ixNetwork is the root object to the IxNetwork API tree.
    ixNetwork = session.Ixnetwork

    captureControlPlane = True
    captureDataPlane = True

    # Get the packet capturing vport
    vport = ixNetwork.Vport.find()[1]
    vport.RxMode = 'captureAndMeasure'

    # -softwareEnabled == Control Plane
    # -hardwareEnabled == Data Plane
    ixNetwork.info('\nConfigure capture')
Beispiel #15
0
"""Demonstrates how to use the StatViewAssist class

This sample requires an already loaded configuration with at least 2 connected vports.

"""
from ixnetwork_restpy import SessionAssistant, StatViewAssistant


session_assistant = SessionAssistant(IpAddress='127.0.0.1', 
    UserName='******', Password='******',
    LogLevel=SessionAssistant.LOGLEVEL_INFO, 
    ClearConfig=False)
ixnetwork = session_assistant.Ixnetwork

ixnetwork.info('negative test')
try:
    session_assistant.StatViewAssistant('my test view', Timeout=5)
except Exception as e:
    ixnetwork.info(e)

# get a list of all current statistic views that can be used in the StatViewAssistant
print(StatViewAssistant.GetViewNames(ixnetwork))

# create a stat view assistant for a statistics view
port_statistics = session_assistant.StatViewAssistant('Port Statistics')

# print all the rows for a statistics view
print(port_statistics)

# add a filter so that only a single row is retrieved
port_statistics.AddRowFilter('Port Name', StatViewAssistant.REGEX, 'Port 1$')
import json
from ixnetwork_restpy import SessionAssistant

session_assistant = SessionAssistant(IpAddress='127.0.0.1', UserName='******', Password='******',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO, ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork

conf_assist = session_assistant.ConfigAssistant()
config = conf_assist.config
vport = config.Vport.add().add()
vport[0].Name = 'myVport_1'
vport[0].RxMode = 'captureAndMeasure'
vport[1].Name = 'myVport_2'
topo = config.Topology.add(Name='Topology 1', Vports=vport[0]).add(Name='Topology 2', Vports=vport[1])
for i in range(0, 2):
    eth1 = topo[0].DeviceGroup.add(Name='Device Group 1', Multiplier='4').Ethernet.add()
    eth1.Mac.Increment(start_value='00:11:22:33:44:55', step_value='00:11:01:00:00:01')
    eth1.Mtu.Single('1670')
    ipv41 = eth1.Ipv4.add(Name='Ipv4 East')
    ipv41.Address.Increment(start_value='1.1.1.1', step_value='0.1.0.0')
    ipv41.GatewayIp.Increment(start_value='1.1.1.0', step_value='0.1.0.0')
    ipv41.Prefix.Single('26')
    eth2 = topo[1].DeviceGroup.add(Name='Device Group 2', Multiplier='4').Ethernet.add()
    eth2.Mac.Increment(start_value='00:55:44:33:22:11', step_value='00:10:01:00:00:21')
    eth2.Mtu.Single('1770')
    ipv42 = eth2.Ipv4.add(Name='Ipv4 West')
    ipv42.Address.Increment(start_value='1.1.1.0', step_value='0.1.0.0')
    ipv42.GatewayIp.Increment(start_value='1.1.1.1', step_value='0.1.0.0')
    ipv42.Prefix.Single('26')
traffic = config.Traffic.TrafficItem
for i in range(0, 2):
Beispiel #17
0
import sys, os, time, traceback

# Import the RestPy module
from ixnetwork_restpy import SessionAssistant

# For linux and connection_manager only. Set to True to leave the session alive for debugging.
debugMode = False

try:
    # LogLevel: none, info, warning, request, request_response, all
    session = SessionAssistant(IpAddress='192.168.70.3',
                               RestPort=None,
                               Username='******',
                               Password='******',
                               SessionName=None,
                               SessionId=None,
                               ApiKey=None,
                               ClearConfig=True,
                               LogLevel='info',
                               LogFilename='restpy.log')

    ixNetwork = session.Ixnetwork

    ixNetwork.info('Assign ports')
    portMap = session.PortMapAssistant()
    vport1 = portMap.Map(IpAddress='192.168.70.128',
                         CardId=1,
                         PortId=1,
                         Name='Port_1')
    vport2 = portMap.Map(IpAddress='192.168.70.128',
                         CardId=2,
Beispiel #18
0
""" Sample that demonstrates how to take a CSV snapshot of a statistics view

The sample operates under the following assumptions:
    - it is for an established IxNetwork GUI session
    - traffic is running
    - there is a Flow Statistics view

"""
from ixnetwork_restpy import SessionAssistant
import os

session_assistant = SessionAssistant(IpAddress='127.0.0.1',
                                     UserName='******',
                                     Password='******',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO)
ixnetwork = session_assistant.Ixnetwork
session = session_assistant.Session

ixnetwork.info('''
1) setup the csv snapshot parameters
2) ensure the CsvName DOES NOT end with a .csv extension
	the IxNetwork server will add a .csv extension to the final csv filename
3) ensure the CsvLocation is a path on the IxNetwork server that the IxNetwork server has access to, 
	the best practice is to use the Ixnetwork.Statistics.CsvFilePath location
''')
statistics = ixnetwork.Statistics
csvsnapshot = statistics.CsvSnapshot
csvsnapshot.update(CsvName="StatisticsSnapshot",
                   CsvLocation=statistics.CsvFilePath,
                   SnapshotViewCsvGenerationMode='overwriteCSVFile',
                   SnapshotViewContents='allPages',
Beispiel #19
0
#!/usr/bin/python
"""This script demonstrates how to get started with ixnetwork_restpy scripting.

"""
from pprint import pprint
from ixnetwork_restpy import SessionAssistant
import time

# create a test tool session
session_assistant = SessionAssistant(IpAddress='127.0.0.1',
                                     UserName='******', Password='******',
                                     LogLevel=SessionAssistant.LOGLEVEL_INFO,
                                     ClearConfig=True)
ixnetwork = session_assistant.Ixnetwork

#print(session_assistant.Session)

# create tx and rx port resources
port_map = session_assistant.PortMapAssistant()
port_map.Map('172.24.68.5', 5, 17, Name='Tx')
port_map.Map('172.24.68.5', 5, 18, Name='Rx')

port_map.Connect(ForceOwnership=True, HostReadyTimeout=20, LinkUpTimeout=60)
#print(port_map)

#Need to map Tx and Rx to vport1 and vport2
vport1 = ixnetwork.Vport.find(Name='^Tx')
vport2 = ixnetwork.Vport.find(Name='^Rx')

#Topology
topology1 = ixnetwork.Topology.add(Name='Topo1', Ports=vport1)
Beispiel #20
0
    tracking = trafficItemObj.Tracking.find()[0]
    tracking.Egress.Encapsulation = 'Any: Use Custom Settings'
    tracking.Egress.CustomOffsetBits = offsetBits
    tracking.Egress.CustomWidthBits = widthBits

    trafficItemObj.EgressEnabled = True
    trafficItemObj.Generate()
    ixNetwork.Traffic.Apply()


try:
    session = SessionAssistant(IpAddress=apiServerIp,
                               RestPort=None,
                               UserName='******',
                               Password='******',
                               SessionName=None,
                               SessionId=None,
                               ApiKey=None,
                               ClearConfig=True,
                               LogLevel='all')

    ixNetwork = session.Ixnetwork

    # Assign ports
    portMap = session.PortMapAssistant()
    vport = dict()
    for index, port in enumerate(portList):
        portName = 'Port_{}'.format(index + 1)
        vport[portName] = portMap.Map(IpAddress=port[0],
                                      CardId=port[1],
                                      PortId=port[2],
"""Demonstrates creating and copying over tlv templates into a tlv profile
"""
from ixnetwork_restpy import SessionAssistant

session = SessionAssistant('127.0.0.1',
                           LogLevel=SessionAssistant.LOGLEVEL_INFO,
                           ClearConfig=True)
ixnetwork = session.Ixnetwork

# create a custom tlv template
generic_tlv = ixnetwork.Globals.Topology.Dhcpv6client \
    .TlvEditor.find() \
    .Template.add(Name='generic') \
    .Tlv.add(Name='generic')
generic_tlv.Type.update(Name='type').Object.add(Name='type').Field.add(
    Name='type').Value.Single('10')
generic_tlv.Length.update(Name='length').Value.Single('11')
generic_tlv.Value.update(Name='value').Object.add(Name='value').Field.add(
    Name='value').Value.Single('12')
ixnetwork.info(generic_tlv)

# get a default tlv template
option_request = ixnetwork.Globals.Topology.Dhcpv6client \
    .TlvEditor.find() \
    .Defaults.find() \
    .Template.find() \
    .Tlv.find(Name='Option Request')
ixnetwork.info(option_request)

# get the dhcpv6client tlv profile
tlv_profile = ixnetwork.Topology.add() \