Skip to content

OpenIxia/keystack-IxNetworkDataModel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

version: 1.1.1

description:
   This app is driven by user input data-model yaml config files.
   It configures IxNetwork using the SDK ixnetwork_restpy python
   package to execute IxNetwork ReST APIs.

Requirements:
   - Runs on Linux OS only.
   - pip install requests, PyYaml
   - data-model yml config file

   Note: This ixNetworkDataModel package comes with ixnetwork_restpy.
         It is inside the /Apps/IxNetworkDataModel/IxNetworkRestpy directory.

   - For port capturing requirements:
      - IxNetwork Wireshark installed
      - Linux OS wireshark installed
      - sudo chmod o+x /usr/bin/dumpcap (For redhat distributions)
      - sudo chmod o+x /usr/sbin/dumpcap (For ubuntu distributions)
   
In your testcase yml files:

   pythonScript: /Modules/IxNetworkDataModel/Scripts/<the_python_script_to_run>.py

   configParametersFile: configs.yml

   importAppLibraryPaths:
      - /Apps/IxNetworkDataModel/src
      - /Apps/IxNetworkDataModel/IxNetworkRestpy
      

configFile sample (configs.yml):

   ixNetworkApiServerIp: 192.168.28.10

   # Below are for Linux API server only
   username: admin
   password: admin
   apiKey: None
   deleteSession: False

   forceTakePortOwnership: True
   releasePorts: False
   restPort: None
   logLevel: info

   ports:
     - name: Host1
       port: 192.168.28.5, 1, 1
       #type: novusHundredGigLanFcoe
       #enableAutoNegotiation: false
       #ieeeL1Defaults: false
       packetCapture:
         enable: True
         rxMode: captureAndMeasure
         controlPlane: False
         dataPlane: True
         sliceSize: 80

     - name: Host2
       port: 192.168.28.5, 1, 2
       #type: novusHundredGigLanFcoe
       #enableAutoNegotiation: false
       #ieeeL1Defaults: false       
       packetCapture:
         enable: True
         rxMode: captureAndMeasure
         controlPlane: False
         dataPlane: True
         sliceSize: 80
      
   topologies:
      - name: Host1
        ports:
          - Host1
        deviceGroups:
          - name: Host1
            multiplier: 1
            ethernet:
              name: Host1
            ipv4:
              name: Host1
              ipStartValue: 1.1.1.1
              ipStepValue: 0.0.0.0
              subnet: 255.255.255.0
              ipGatewayStartValue: 1.1.1.2
              ipGatewayStepValue: 0.0.0.0

      - name: Host2
        ports:
          - Host2
        deviceGroups:
          - name: Host2
            multiplier: 1
            ethernet:
              name: Host2
            ipv4:
              name: Host2
              ipStartValue: 1.1.1.2
              ipStepValue: 0.0.0.0
              subnet: 255.255.255.0
              ipGatewayStartValue: 1.1.1.1
              ipGatewayStepValue: 0.0.0.0

   trafficItems:
     - name: Host1
       enable: True
       trafficType: raw
       srcPortName: Host1
       destPortName: Host2
       biDirection: True
       frameRate:
         type: percentLineRate
         rate: 50
       transmissionControl:
         # fixedFrameCount | continuous
         type: fixedFrameCount
         frameCount: 100
       frameSize: 128
       packetHeaders:
         ethernet:
           src:
             valueType: increment
             startValue: ngpfSrcMac
             stepValue: 00:00:00:00:00:00
             stepValue: 00:00:00:00:00:00
             count: 1
           dst:
             valueType: increment
             startValue: ngpfResolvedGatewayMac
             stepValue: 00:00:00:00:00:01
             count: 1
         ipv4:
           appendToStack: ethernet
           src:
             valueType: increment
             startValue: 1.1.1.1
             stepValue: 0.0.0.1
             count: 1
           dst:
             valueType: increment
             startValue: 1.1.1.2
             stepValue: 0.0.0.1
             count: 1
         udp:
           appendToStack: ipv4
           dstPort:
             startValue: 4791
	   srcPort:
             startValue: 1111

script example:

import sys, traceback

from ixNetworkDataModel import ConfigIxNetworkRestPy
from keystackEnv import keystackObj

dataModelYamlFile = keystackObj.configParamsFileFullPath

try:
    mainObj = ConfigIxNetworkRestPy(dataModelFile=dataModelYamlFile, dataModelObj=None,
                                    sessionName=None, sessionId=None, apiKey=None, clearConfig=True,
                                    logLevel='info', logFilename=None, keystackObj=keystackObj)

    mainObj.ports.assignPorts()
    mainObj.portCapture.configure()
    mainObj.closeAllTabs()
    mainObj.ngpf.configure()
    mainObj.ngpf.startAllProtocols()
    mainObj.ngpf.verifyProtocolsUp()
    ngpfMacAddresses = mainObj.ngpf.getNgpfLearnedMacAddresses()
    mainObj.trafficItem.configRawTrafficItems(ngpfMacAddresses=ngpfMacAddresses)
    mainObj.trafficItem.generateAll()
    mainObj.trafficItem.apply()
    mainObj.portCapture.start()
    mainObj.trafficItem.start()
    mainObj.trafficItem.waitForTrafficCompletion(maxCounter=10)
    mainObj.portCapture.stop()
    mainObj.portCapture.getDataPlaneCaptureFile(writeCaptureToFile=False,
                                                amountOfPacketsToWrite=5,
                                                captureFileDestPath=keystackObj.moduleProperties['artifactsRepo'])

    if mainObj.configs.get('releasePorts', False):
        mainObj.ports.releasePorts()
    
    if mainObj.configs.get('deleteSession', True):
        mainObj.deleteSession()

except Exception as errMsg:
    if 'mainObj' in locals():
        mainObj.logFailed(traceback.format_exc(None, errMsg))