Giter Site home page Giter Site logo

openixia / ixnetwork Goto Github PK

View Code? Open in Web Editor NEW
49.0 49.0 59.0 24.81 MB

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com

License: MIT License

Tcl 34.34% Python 36.36% RobotFramework 3.39% Perl 21.66% OpenEdge ABL 0.12% Ruby 4.14%

ixnetwork's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ixnetwork's Issues

How do I configure double tagged vlans using restPy

In short I am looking for the restpy equivalent of configuring inner and outer vlan(double stacked). What I have from bgpNgpf sample script is single stacked, like below. But there are no examples for double tagged vlans anywhere and also could not gather much info from documentation

ixNetwork.info('Creating Topology Group 1')
topology1 = ixNetwork.Topology.add(Name='Topo1', Ports=vport1)
deviceGroup1 = topology1.DeviceGroup.add(Name='DG1', Multiplier='1')
ethernet1 = deviceGroup1.Ethernet.add(Name='Eth1')
import pdb; pdb.set_trace()
ethernet1.Mac.Increment(start_value='00:01:01:01:00:01', step_value='00:00:00:00:00:01')
ethernet1.EnableVlans.Single(True)

ixNetwork.info('Configuring vlanID')
vlanObj = ethernet1.Vlan.find()[0].VlanId.Increment(start_value=103, step_value=0)

Creating a quicktest

Hello,

I need to create a QuickTest to measure jitter and average/min/max latency of my DUT. I already did this in IxNetwork GUI and tested it. Can you guys point me to an example on this? I saw the load QuickTest.py but that just loads and runs an existing Quicktest; I need to create a new one.

BTW, In IxNetwork, one can change statistics measurement from Latency to Latency and Delay Variation in Statistics Measurement Options. How do we do this in RestPy

Thanks
---Mehrdad

RestPy: Code for generating class hierarchy and doc

AFAIK the code/script to generate the class hierarchy in RestPy/ixnetwork_restpy/testplatform/sessions/ is not there, will it be added or that stays proprietary?

Same for the generation of the doc in RestPy/ixnetwork_restpy/docs.

Iwan

Auto generate MkDocs documentation

Need documentations for all the REST API module APIs and sample scripts in MkDoc format.
Implement auto generating docs so the docs show the latest updates.

RestPy: Do not modify global logging configuration

The TestPlatform class creates logging handles and modifies the root logger.
This should be left to the users of the API instead (or at least be optional).

We (want to) use the API from our test framework which already handles logging configuration.
ATM I would need to duplicate the TestPlatform class to work around this.

Regards,
Iwan

createEthernetNgpf() new VLAN side-effect

A recent change to this function switched from using specific parameters to using a kwArgs (dictionary). Unfortunately, a small unintended change in behaviour appears to have sneaked in.

Previously, specifying vlanId=None worked fine and no VLAN is created on the Ethernet.
However, now if vlanId=None is set, this None 'vlanId' entry appears in the kwArgs dictionary. The logic to decide what to do checks for the presence of 'vlanId' value in kwArgs but does NOT check for its value being none. To cut a long story short, the result is that all Ethernet interfaces created in this way have their traffic tagged with 802.1Q headers for VLAN 1 which is not what happened before, and is not what one would expect.

RestPy: Cannot choose correct connection scheme (https)

I connect to an application server running on windows (with ConnectionManager), for some reason the code assumes that linux -> HTTPS and windows -> HTTP, but AFAIK on windows it also uses HTTPS.
The TestPlaform and Connection classes should take the scheme as argument instead of inferring it from the platform.

I'm not sure why the platform is even one of the arguments, it seems it's only used to choose the connection scheme. So I will put "linux" now even though it's running windows.

generateifrequired not regenerating traffic items

What is .../ixnetwork/traffic/operations/generateifrequired supposed to do ? I know it should regenerate "dirty" traffic but what does it mean exactly ? Does it recognize NexGen protocols ?

My case is like follows:

  1. I load config. It has some NexGen protocols and traffic items between them configured
  2. I start all protocols
  3. When protocols are up I do: post - http://10.10.0.222:11019/api/v1/sessions/1/ixnetwork/traffic/operations/generateifrequired - {'json': {'arg1': '/api/v1/sessions/1/ixnetwork/traffic'}} and get 202 success
  4. I apply and start traffic but traffic fails (100% loss).

If I go to API browser and generate each traffic item one by one using
ixnetwork/traffic/trafficItem//operations/generate and then apply and run traffic it works fine (0% loss)

Best Regards,
PW

Inability to cahnge where PrefixPools connectTo

When I create prefixPools they connect to 'ethernet', which means my ISIS and BGP both will advertise everything I have, which is undesirable.
I could not find way to chnge the connectedTo key.

def monkey_ixianet_configPrefixPoolsConnector(self, prefixPoolsObj, **kwargs):
    url = self.ixnObj.httpHeader + prefixPoolsObj + '/connector'
    response = self.ixnObj.get(url)
    current = response.json()["connectedTo"]
    self.ixnObj.logInfo('Configuring PrefixPool Connector connecedTo from %s to %s' % (current, kwargs['connectedTo']))
    self.ixnObj.patch(url, data={'connectedTo': kwargs['connectedTo']})

setattr(Protocol, "configIpv4LoopNgpf", monkey_ixianet_configIpv4LoopNgpf)
setattr(Protocol, "configIpv6LoopNgpf", monkey_ixianet_configIpv6LoopNgpf)
setattr(Protocol, "configPrefixPoolsConnector", monkey_ixianet_configPrefixPoolsConnector)
setattr(Protocol, "configIpv6NetworkGroup", monkey_ixia_configIpv6NetworkGroup)

The Rest Python API is quite wet and unidiomatic. I see no particular reason why it should implement AFI specific methods and it even changes the AFI-agnostic keys of REST api to AFI-specific keys, for no particular reason.
It seems it would be lot drier to just use same AFI agnostic keys that REST API expects, and to use single method regardless of API.
Also it's not obvious to me what is the target audience of the Python REST API, it doesn't seem to add much value to using raw REST.

What I've implemented on top of now, and what I think is significantly drier and idiomatic:

#!/usr/bin/env python3

import nttixia.ixia

ports  = ["3/1"]
ixia   = nttixia.ixia.Ixia(steal_ports=True, api_port=12010)
ports  = ixia.add_ports(ports)
topo   = ixia.add_topology(ports)
group  = topo.add_group(multiplier=4)
eth    = group.add_ethernet()
ipv4   = eth.add_connected(ip="204.42.112.2", mask=24, gw="204.42.112.1")
ipv6   = eth.add_connected(ip="2001:418:3f9:1000::112:2", mask=112, gw="2001:418:3f9:1000::112:1")
isis   = eth.add_isis()
net1   = group.add_network(ip="204.42.110.100")
net2   = group.add_network(ip="100.100.100.0")
net3   = group.add_network(ip="100.100.101.0")
net4   = group.add_network(ip="2001:418:3f9:1000::100")
loop4  = group.add_loopback(ip="204.42.110.100")
loop6  = group.add_loopback(ip="2001:418:3f9:1000::100")
bgp    = loop4.add_bgp(ip="204.42.110.40")
bgp.add_network(net2)
bgp.add_network(net3)
isis.add_network(net1)
isis.add_network(net4)
ixia.start()

Example of Loopback class:

from .rest import Args
from .bgp import Bgp

class Loopback:
  IP   = "10.255.0.2"

  def __init__(self, group, **kwargs):
    self.log = kwargs.pop("log")
    self.group = group

    kwargs.setdefault("ip", self.IP)
    ip = { "start": kwargs["ip"],
           "direction": "increment" }

    args = Args(kwargs)
    args.map(args.name(), "name")
    self.name = args.get("name")

    if ":" in kwargs["ip"]:
      self.loopback = self.ipv6(ip, args)
    else:
      self.loopback = self.ipv4(ip, args)

    self.ipObj = self.loopback
    self.bgps = {}

  def ipv4(self, ip, args):
    ip["step"] = "0.0.0.1"
    args.map(32, "mask", "prefix")
    args.set("ipv4Address", ip)
    args.map("disabled", "ipv4AddressPortStep")
    self.log.debug("setting loop with args: %s" % args.rest)
    return self.group.topology.ixia.protocol.configIpv4LoopNgpf(self.group.group, **args.rest)

  def ipv6(self, ip, args):
    ip["step"] = "0:0:0:0:0:0:0:1"
    args.map(128, "mask", "prefix")
    args.set("ipv6Address", ip)
    args.map("disabled", "ipv6AddressPortStep")
    self.log.debug("setting loop with args: %s" % args.rest)
    return self.group.topology.ixia.protocol.configIpv6LoopNgpf(self.group.group, **args.rest)

  def add_bgp(self, **kwargs):
    kwargs["log"] = self.log
    bgp = Bgp(self, **kwargs)
    self.bgps[bgp.name] = bgp
    return self.get_bgp(bgp.name)

  def get_bgp(self, name):
    return self.bgps[name]

This works just fine, but I likely need to revert to raw rest, as I continue to add functionality, I continue to monkey patch the API, and my monkey patches are equally wet, as I cannot write them very dry without significant refactoring.
It seems to me anyone needing to do anything over the REST API, will over time spend less time by writing it without the library.

VXlan Encap/Decap

Hello,

My two IXIA ports are connected to an Arista EOS device. I'd like to measure the performance of VXLAN decapsulation by generating VXLAN traffic from one of the IXIA ports, have Arista decapsulate the VXLAN header, and then forward IPV4 traffic to the other IXIA port.

(1) Do you have any example for this scenario where decapsulation happens in one direction? I looked at the vxlanNgpf.py but, unlike my case, that consists of two homogenous device groups and bidirectional traffic tests.

(2) If not, can you please comment on if I need to load both my source and destination device groups with the entire VXLAN stack? or only the source DG?

image
Do I need to remove the VTEP stack on the right-hand side to get the above scenario working?

Thanks!

Loading streams

Hey,

I'm a newbie here and got a bunch of questions:

(1) Is it possible to store the streams generated by the python API and then load them?
(2) While the samples are definitely useful, is there any place that I can find the documentation on the Python API?
(3) Is there any Python sample where I can get packet forwarding latency, jitter? or more detailed performance numbers.

Thanks!

RestPy:Can a list of src and dest handles be accepted for endpoint set?

I have a list of src and dest handles. Can I send a list of src and dest handles as part of the endpointset.add()

(Pdb) src_handle_list
[<ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ipv4.Ipv4 object at 0x7fafd85ba290>]
(Pdb) dest_handle_list
[<ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ipv4.Ipv4 object at 0x7fafa38ce490>, <ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ipv4.Ipv4 object at 0x7fafa38ce790>, <ixnetwork_restpy.testplatform.sessions.ixnetwork.topology.ipv4.Ipv4 object at 0x7fafa38ce110>]
(Pdb)

I want to do the following, but the command as below does not work. It only accepts one src and one dest.

trafficItem.EndpointSet.add(Sources=src_handle_list, Destinations=dest_handle_list

RestPy: Adding a list of values for ip, Mac etc rather than using increment

I can’t seem to find any examples or how to add a list of values when using the multivalue wrappers in restpy.

I see examples like below where you can increment with a step value and start value.

ixNetwork.info('Configuring IPv4')

ipv4 = ethernet1.Ipv4.add(Name='Ipv4')

ipv4.Address.Increment(start_value='1.1.1.1', step_value='0.0.0.1')

ipv4.GatewayIp.Increment(start_value='1.1.1.2', step_value='0.0.0.0')

But I want something where I have a list of Ips, and I want to configure them as a list.

ip_list = '56.26.0.2,56.26.1.3,56.26.0.4,56.26.0.18,56.26.0.16,56.26.0.7,56.26.0.8,56.26.0.9,56.26.0.10,56.26.0.11'

ixNetwork.info('Configuring IPv4')

ipv4 = ethernet1.Ipv4.add(Name='Ipv4')

ipv4.Address.SomeFunction(ip_list). <<ß---

in HLT Api we did it using multivalue like below.

ip_list

        if ip_version == 4:

            counter_start='1.1.1.1'

            counter_step='0.0.1.0'

            nest_step='0.1.0.0'

        else:

            counter_start='1:1:1:1:1:1:1:1'

            counter_step='0:0:0:0:1:0:0:0'

            nest_step='0:0:0:1:0:0:0:0'

        import pdb; pdb.set_trace()

        ip_construct = device_group.add_multi_value(pattern='counter',

                                      counter_start=counter_start,

                                      counter_step=counter_step,

                                      counter_direction='increment',

                                      nest_step=nest_step,

                                      nest_owner=topo.topology_handle,

                                      nest_enabled='1',

                                      overlay_value=ip_list,

                                      overlay_value_step=ip_list,

                                      overlay_index=overlay_index,

                                      overlay_index_step=overlay_index_step,

                                      overlay_count=overlay_count)

Missing license

The repository is missing a LICENSE file and/or any license header in the source files.

Under which license are the files of this repository?

Kind regards,
Christoph

RestPy:Getting a session handle for windows platform

Hi Team,
I know how to get the session handle when using the linux platform. But if I wanted to do the same for a windows session that already has configuration. How do I do this?

For linux it would be as follows

session = testPlatform.Sessions.find(Id=22)
session.Ixnetwork

For Windows I tried the same thing, but It doesn't work it hangs

test_platform = TestPlatform('172.29.205.16', rest_port=11009, platform='windows')
test_platform.Trace = 'request_response'2019-04-09 18:48:17 [ixnetwork_restpy.connection] [INFO] using python version 2.7.13 (default, Dec 17 2016, 23:03:43)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
2019-04-09 18:48:17 [ixnetwork_restpy.connection] [INFO] using ixnetwork-restpy version 1.0.27

sessions = test_platform.Sessions.find(Id=1)
2019-04-09 18:48:46 [ixnetwork_restpy.connection] [DEBUG] GET http://172.29.205.16:11009/api/v1/sessions None
2019-04-09 18:48:46 [ixnetwork_restpy.connection] [DEBUG] 307 Temporary Redirect
2019-04-09 18:48:46 [ixnetwork_restpy.connection] [DEBUG] GET https://172.29.205.16:11009/api/v1/sessions None

Non-existent dictionary key referenced in 'getTrafficItemPktHeaderStackObj'

Hi,

I am using the 'modifyTrafficItemIpPriorityTos' function in IxNetRestApiTraffic.py to configure different ToS values across a number of traffic streams..

In the function 'getTrafficItemPktHeaderStackObj', the following call is made:

response = self.ixnObj.get(self.ixnObj.httpHeader+configElementObj+'/stack')

The subsequent 'for' loop then references the dictionary key 'stackTypeId' (eachStack['stackTypeId']) which is not a valid key in the response of this call, resulting in a KeyError.

for eachStack in response.json():
            self.ixnObj.logInfo('\nstack: {0}: {1}'.format(eachStack, eachStack['stackTypeId']), timestamp=False)
            if bool(re.match(packetHeaderName, eachStack['stackTypeId'], re.I)):
                stackObj = eachStack['links'][0]['href']
                break
        else:
            raise IxNetRestApiException('\nError: No such stack name found: %s' % stackName)

return stackObj

Sample of dictionaries returned in the list:

[
    {
        "id": 1,
        "displayName": "Ethernet II",
        "templateName": "ethernet-template.xml",
        "links": [
            {
                "rel": "meta",
                "method": "OPTIONS",
                "href": "/api/v1/sessions/1/ixnetwork/traffic/trafficItem/1/configElement/1/stack/1"
            }
        ]
    },
    {
        "id": 2,
        "displayName": "VLAN",

<<  output cut  >>

I have the following patch file that is applied during my packaging process that modifies the eachStack['stackTypeId'] to eachStack['displayName'] within this snippet to get the function to work as I think it is intended.

diff --git a/RestApi/Python/Modules/IxNetRestApiTraffic.py b/RestApi/Python/Modules/IxNetRestApiTraffic.py
index 50532fd..b022f46 100644
--- a/RestApi/Python/Modules/IxNetRestApiTraffic.py
+++ b/RestApi/Python/Modules/IxNetRestApiTraffic.py
@@ -620,8 +620,8 @@ class Traffic(object):
         print('\n--- packetHeaderName:', packetHeaderName)
 
         for eachStack in response.json():
-            self.ixnObj.logInfo('\nstack: {0}: {1}'.format(eachStack, eachStack['stackTypeId']), timestamp=False)
-            if bool(re.match(packetHeaderName, eachStack['stackTypeId'], re.I)):
+            self.ixnObj.logInfo('\nstack: {0}: {1}'.format(eachStack, eachStack['displayName']), timestamp=False)
+            if bool(re.match(packetHeaderName, eachStack['displayName'], re.I)):
                 stackObj = eachStack['links'][0]['href']
                 break
         else:

Thanks,
Nick

"Error in L2/L3 Traffic Apply" response from TrafficItem's Generate() method.


I have some basic code and a basic test (code below) but Ixnetwork.Traffic.TrafficItem.Generate is not working correctly. But I get the error when I try ixnetwork.traffic.apply() (pic below) . 



def doBasicTest():
  IP = '22.254.11.181'
  test_platform = TestPlatform( IP , platform='linux', log_file_name='restpy.log')
  sess = test_platform.Sessions.find(Id=8020)
  ix = sess.Ixnetwork

  ix.LoadConfig(Files('ixNetworkTestSample.ixncfg'))

  traffItem = ix.Traffic.TrafficItem.find()
  tGenerated = traffItem[0].Generate()
  ix.Traffic.Apply()

image



I believe the problem is on RestPy's end b/c if I comment out traffItem[0].Generate() and comment out ix.Traffic.Apply() and then use the API browser to run both those methods, ie run a generate() method on the trafficItem and run the Apply method on Traffic, then it will work with no problems. (At /api/v1/sessions/8020/ixnetwork/traffic/trafficItem/2 via clicking Operations then choosing the Generate method and clicking commit, and same-ish thing for traffic.apply()).

Also, if I go into the directory of my python library to [pythonpath]/ixnetwork_restpy/connection.py, and add a sleep command (shown below, line 173) then it works every time.


screen shot 2019-01-16 at 3 56 45 pm

RestPy: How do I configure VLAN on Interface?

Hi,

I would like to use VLAN at Interface.
However, I cannot find method with a name that enables vlan.

I tried following code and it is work fine.

test_platform = TestPlatform('10.0.0.249', rest_port=11009, platform='windows')     
test_platform.Trace = 'request_response'
sessions = test_platform.Sessions.find(Id=1)
ixnetwork = sessions.Ixnetwork
ixnetwork.NewConfig()

vports = ixnetwork.Vport.find()

interface1 = vports[0].Interface.add(Enabled=True)
interface1.Ipv4.add(Ip="10.140.1.10", Gateway="10.140.1.2", MaskWidth=24)

interface1.Vlan.VlanId = 401
interface1.Vlan.VlanEnable = True
interface1.refresh()

Is my code good implementation?
Otherwise do you have better way to enable VLAN?

Restpy:take csv snaphot erroring out on incorrect api key

The csv file that is saved has an error as such and no data

{"error":"Your API key was not supplied or is incorrect make sure that you are logged-in or using the correct API key."}

Code is exactly as below

testPlatform = TestPlatform(ip_address=apiServerIp, rest_port=apiServerPort, platform=platform, log_file_name='restpy.log')
testPlatform.Trace = 'request_response'
testPlatform.Authenticate(username, password)

Using an existing Session. Not sure if this is the issue.

session = testPlatform.Sessions.find(Id=3)
stats = StatViewAssistant(session.Ixnetwork, 'Flow Statistics')
result = stats._take_csv_snapshot()

Then opening the file throws an error and no data in it.

RestPy: TCP stack add does not src and dest port

Hi Team,
I tried adding the tcp stack to the configElement as described in one of the samples and I see that the stack is added without any issues. but the src and dest port fields do not seem to get added. The commands go through without any errors though. RestPy snippet also added to the end.

from ixnetwork_restpy.testplatform.testplatform import TestPlatform
test_platform = TestPlatform('127.0.0.1', rest_port=11009)^M
test_platform.Trace = 'none'
sessions = test_platform.Sessions.find(Id=1)
ixnetwork = sessions.Ixnetwork^M

trafficItem = ixnetwork.Traffic.TrafficItem.add(Name='Test Traffic', BiDirectional=True, TrafficType='ipv4')
trafficItem.EndpointSet.add(Sources=src_handle_list, Destinations=dest_handle_list)
configElement = trafficItem.ConfigElement.find()[0]
configElement.FrameRate.Rate = 1000
configElement.FrameRate.Type = 'framesPerSecond'
configElement.FrameSize.FixedSize = 1000
configElement.TransmissionControl.Type = 'continous'
trafficItem.Tracking.find()[0].TrackBy = ['sourceDestValuePair0']

protocol_template = ixnetwork.Traffic.ProtocolTemplate.find(StackTypeId='tcp')
ipstack = configElement.Stack.find(StackTypeId='ipv4')
tcpFieldObj = configElement.Stack.read(ipstack.AppendProtocol(protocol_template))
tcpFieldObj.find(DisplayName='TCP-Source-Port').Auto = False
tcpFieldObj.find(DisplayName='TCP-Source-Port').SingleValue = 1000
tcpFieldObj.find(DisplayName='TCP-Dest-Port').Auto = False
tcpFieldObj.find(DisplayName='TCP-Dest-Port').SingleValue = 1000

2019-03-13 21:24:27 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1", "properties": [], "children": [{"properties": [""], "filters": [], "child": "tracking"}]}]}
2019-03-13 21:24:27 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:24:27 [ixnetwork_restpy.connection] [DEBUG] PATCH https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/tracking?deprecated=true {"trackBy": ["sourceDestValuePair0"]}
2019-03-13 21:24:28 [ixnetwork_restpy.connection] [DEBUG] 200 OK
2019-03-13 21:29:19 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/", "properties": [], "children": [{"properties": ["
"], "filters": [], "child": "traffic"}]}]}
2019-03-13 21:29:20 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:29:20 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic", "properties": [], "children": [{"properties": [""], "filters": [{"regex": "tcp", "property": "stackTypeId"}], "child": "protocolTemplate"}]}]}
2019-03-13 21:29:20 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:29:28 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1", "properties": [], "children": [{"properties": ["
"], "filters": [{"regex": "ipv4", "property": "stackTypeId"}], "child": "stack"}]}]}
2019-03-13 21:29:28 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:29:38 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1/stack/3/operations/appendprotocol?deprecated=true {"Arg1": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1/stack/3", "Arg2": "/api/v1/sessions/12/ixnetwork/traffic/protocolTemplate/387"}
2019-03-13 21:29:38 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:29:38 [ixnetwork_restpy.connection] [DEBUG] GET https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1/stack/4?deprecated=true None
2019-03-13 21:29:38 [ixnetwork_restpy.connection] [DEBUG] 200 OK
2019-03-13 21:29:48 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1", "properties": [], "children": [{"properties": [""], "filters": [{"regex": "TCP-Source-Port", "property": "displayName"}], "child": "stack"}]}]}
2019-03-13 21:29:48 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:29:54 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1", "properties": [], "children": [{"properties": ["
"], "filters": [{"regex": "TCP-Source-Port", "property": "displayName"}], "child": "stack"}]}]}
2019-03-13 21:29:54 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:30:00 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1", "properties": [], "children": [{"properties": [""], "filters": [{"regex": "TCP-Dest-Port", "property": "displayName"}], "child": "stack"}]}]}
2019-03-13 21:30:00 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:30:13 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/operations/select?deprecated=true {"selects": [{"inlines": [], "from": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/configElement/1", "properties": [], "children": [{"properties": ["
"], "filters": [{"regex": "TCP-Dest-Port", "property": "displayName"}], "child": "stack"}]}]}
2019-03-13 21:30:13 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:38:14 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1/operations/generate?deprecated=true {"Arg1": "/api/v1/sessions/12/ixnetwork/traffic/trafficItem/1"}
2019-03-13 21:38:15 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 21:39:34 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1

How to add a step iterator for TCP

Hi,
Do you have examples of adding a step iterator for TCP stack. I only see the option for a single value.

configElement = trafficItem.ConfigElement.find()[0]
protocol_template=ixNetwork.Traffic.ProtocolTemplate.find(StackTypeId='tcp')
ipstack = configElement.Stack.find(StackTypeId='ipv4')
tcpFieldObj = configElement.Stack.read(ipstack.AppendProtocol(protocol_template))
tcpFieldObj.Field.find(DisplayName='TCP-Source-Port').Auto = False
tcpFieldObj.Field.find(DisplayName='TCP-Source-Port').SingleValue = int(stream_params['sFromPort'])
tcpFieldObj.Field.find(DisplayName='TCP-Dest-Port').Auto = False
tcpFieldObj.Field.find(DisplayName='TCP-Dest-Port').SingleValue = int(stream_params['dFromPort'])

Something similar to ip address
ip_construct.Address.Increment(start_value=ip_value, step_value=counter_step)

Packet capture in restpy

I'm trying to do packet capture using RestPy. However, the downloaded pcap is empty (while the traffic correctly flows from IXIA port 1 to 2 and the stats show %0 traffic loss). Just wanted to double check with you folks if the following steps are correct (I do have an ongoing ticket--#854652 but the progress is slow there).

Before traffic item creation:
ixNetwork.Vport.find(Name='Ethernet - 002').Capture.SoftwareEnabled = True

After traffic item creation:
ixNetwork.StartCapture()
ixNetwork.Traffic.Apply()
ixNetwork.Traffic.Start()
flowStatistics = StatViewAssistant(ixNetwork, 'Flow Statistics')
ixNetwork.StopCapture()
ixNetwork.SaveCaptureFiles("D:\UserData\memoradi\Desktop", "trace.pcap")

Memory Error

Hello,

I have a list of 16 million ethernet addresses and getting the following memory error when generating the traffic item. I can run my tests when the list size is around 2M.

File "vxlan-encap-multiple.py", line 119, in create_vlan_traffic_item
ethernetDstField.ValueList = list(packets["#DMAC"].values)
File "C:\Python27\lib\site-packages\ixnetwork_restpy\testplatform\sessions\ixnetwork\traffic\trafficitem\configelement\stack\field\field.py", line 418, in ValueList
self._set_attribute('valueList', value)
File "C:\Python27\lib\site-packages\ixnetwork_restpy\base.py", line 129, in _set_attribute
raise e
MemoryError

How can I fix this issue?

Bad string check in connectIxChassis

Hi,
I hit a problem when invoking connectIxChassis() in IxNetRestApiPortMgmt.py from RobotFramework.
This check at the top of the function is too restrictive:
"if type(chassisIp) is str:"
The problem is that when I invoke the function from RF the type of chassisIp passed into this is actually "unicode", which is a sub-class of string... but which fails this test. This makes this function unusable for me.

This alternative line works for string or any sub-class of string, so I request you fix up using that logic or similar. This works as basestring is a common base class of all strings:
"if isinstance(chassisIp, basestring):"

I have been running with this for several months, but would be good if you could integrate the fix, so I don't have to keep manually applying the delta.

Thanks,

David

Idiomatic install

What is the recommended way to install this in your own python projects?

Idiomatically I'd like to use pip:

cat >> requirements.txt
-e git+https://github.com/OpenIxia/IxNetwork#egg=ixnetwork
^D

But this won't work because you do not have 'setup.py'. And the organisation of the repository does not really support this. You'd need separate repositories for lowlevel, highlevel, rest etc.

If you want example how to make your repository pip installable, look for example textfsm:
-e git+https://github.com/google/textfsm.git#egg=textfsm

Need to reboot ports to factory default after assigning vport to test port

Hi,
I have a config file, which has certain ports. If I load that config file, during the assignment, the port goes for a reboot and come up online [green]. No issues! Now, If I do the same activity on the same port via RES, then port remains down [red]. To bring up the port, I have to explicitly issue the port reboot to factory default. Below is the code snapshot.

#######################################
import sys, os, time, traceback
import linecache
from ixnetwork_restpy.testplatform.testplatform import TestPlatform
from ixnetwork_restpy.assistants.statistics.statviewassistant import StatViewAssistant
platform = 'windows'
apiServerPort = 11009
apiServerIp = '172.22.202.213'
forceTakePortOwnership = True
ixChassisIpList = ['10.195.151.238']
portList = [[ixChassisIpList[0], 8,14],[ixChassisIpList[0], 8,1]]
testPorts = []
testPlatform = TestPlatform(ip_address=apiServerIp, rest_port=apiServerPort, platform=platform, log_file_name='restpy.log')
session = testPlatform.Sessions.add()
ixNetwork = session.Ixnetwork
ixNetwork.NewConfig()

Port_8_14 = ixNetwork.Vport.add(Name='Port_8_14')
Port_8_1 = ixNetwork.Vport.add(Name='Port_8_1')
vportList = [vport.href for vport in ixNetwork.Vport.find()]

for port in portList:
testPorts.append(dict(Arg1=port[0], Arg2=port[1], Arg3=port[2]))

hrefvport1 = ixNetwork.AssignPorts(testPorts, [], vportList, forceTakePortOwnership)

After the above step, port reboots and remains down. I have to use the below steps to bring up the ports online. Is there anything which I'm doing wrong? Any known issues?

Port_8_14.ResetPortCpuAndFactoryDefault()
Port_8_1.ResetPortCpuAndFactoryDefault()

RestPy:Fastest way to get ipv4 object associated with a specific Ip?

Hi Folks,
Is there a short and fast way to get the ipv4 object associated with an ipv4 or ipv6 address if we have the address?
I am looking to see if you have something below.
IxNetwork.Topology.DeviceGroup.Ethernet.Ipv4.find(Value = '2.2.2.2')

Note: there could be an iterator so it could be a list of ips also and not a single value.

RestPy: RestPy equivalent for HLTAPI DisableSuppressArpAllPorts proc

Hi Team,
Is there a restPy equivalent for disabling suppress arp on all ports? In HLTAPI, we had the function below. Please let me know if there is a corresponding restAPI equivalent.

def disable_suppress_arp(self):
results = self.tcl.eval('DisableSuppressArpAllPorts false')
results = self.tcl.eval('DisableSuppressArpAllPorts false ipv6')
return results

proc DisableSuppressArpAllPorts { action {ipType ipv4} } {
# Description:
# This API will automatically disable or enable
# suppress ARP for duplicate gateway on all the
# ports with ipv4.

# action = true or false

# Psuedo code:
#    - Verify if the multiValue -pattern is "counter"
#    - If not, make it counter (so that we could create overlays to modify things.)
#    - If it is counter, verify if there is any overlay.
#    - If there are overlays, verify if the correct portName index exists.
#    - If yes, then change its value true/false.
#    - If no, create an overlay and set true/false for the portIndex number.

set root [ixNet getRoot]
set globals $root\globals
set globalTopology $globals/topology
set globalTopologyIp $globalTopology/$ipType

if { $ipType eq "ipv4" } {
    set suppressKey -suppressArpForDuplicateGateway
} else {
    set suppressKey -suppressNsForDuplicateGateway
}

set portNameList [ixNet getAttribute $globalTopologyIp -rowNames]

foreach portName $portNameList {
    set multiValue [ixNet getAttribute $globalTopologyIp $suppressKey]
    set portIndex [expr [lsearch $portNameList $portName] + 1]

    if {$portIndex != -1} {
        set overlayDiscoveredFlag 0

        # currentValues = true true
        # portList = 1/1/1 1/1/2
        set overlayList [ixNet getList $multiValue overlay]
        if {$overlayList != ""} {
            foreach overlay $overlayList {
                set currentIndex [ixNet getAttribute $overlay -index]

                if {$portIndex == $currentIndex} {
                    set overlayDiscoveredFlag 1
                    puts "\nEnableDisableSuppressArpAllPorts = $action"
                    catch {ixNet setMultiAttribute $overlay -value $action -valueStep $action -count 1 -indexStep 0} errMsg
                    if {$errMsg != "::ixNet::OK"} {
                        puts "Error EnableDisableSuppressArp setAttr: $errMsg"
                    }

                    catch {ixNet commit} errMsg
                    if {$errMsg != "::ixNet::OK"} {
                        puts "Error EnableDisableSuppressArp: $errMsg"
                    } else {
                        puts "EnableDisableSuppressArp: Set to $action: $errMsg"
                    }
                }
            }

            if {$overlayDiscoveredFlag == 0} {
                # Getting here means no overlay index found for the $portIndex.
                # Have to create an overlay with the proper -index number.
                puts "\nEnableDisableSuppressArpAllPorts: No overlay found for: $portName"
                puts "Creating an overlay ..."
                set currentOverlay [ixNet add $multiValue overlay]
                ixNet setMultiAttr $currentOverlay -value $action -valueStep $action -count 1 -index $portIndex
                ixNet commit
            }

        } else {
            # Getting here means there is no overlays.
            # Change the multiValue pattern to counter so that we
            # are able to modify anything
            ixNet setAttribute $multiValue -pattern counter
            ixNet commit
            ixNet setAttribute $multiValue/counter -start true
            ixNet commit

            puts "\nEnableDisableSuppressArpAllPorts: Creating overlay: $portName -index $portIndex -value $action"
            # Create Overlays with proper index number based on the portIndex
            # in $root/globals/topology/ipv4 -rowNames indexes
            set currentOverlay [ixNet add $multiValue overlay]
            ixNet setMultiAttr $currentOverlay -value $action -valueStep $action -count 1 -index $portIndex
            ixNet commit
        }
    } else {
        puts "Error: No such port configured: $portName"
        return 1
    }
}
return 0

}

Any samples for dscp values modification in ip stack?

Figured out 802.1p can be changed by adjusting field values within vlan stack, but seems like DSCP is a little more involved and needs manipulation of multiple fields? Is there any other easy way to do this? If you have an example please post it

Basically what I need to do with DSCP is that when the user provides a specific DSCP value (i.e af11), I need to be able to translate this to adding it to the stack in the traffic item. When looking at the api browser under fields for ip stack there are quite a few and we would need to modify quite a few fields in order to update to a specific dscp value.

Assigned and connected ixia ports are showing as unassigned in IXIA REST

I configured vports and assigned them to test ports. Below is the GUI snapshot for same.
When I try to retrieve the vport attributes, for most of them it shows false or None/unassigned. Is there any known issue for this? Any fix available for this?

(Pdb) vport.ConnectionState
u'unassigned'
(Pdb) vport.ConnectionStatus
u'Unassigned'
(Pdb) vport.State
u'unassigned'
(Pdb) vport.IsAvailable
True
(Pdb) vport.IsConnected
False
(Pdb) vport.IsMapped
False
(Pdb) vport.AssignedTo
u''
(Pdb)
IXIA_Screenshot

Looking for verify arp and ns function.

Looking for a call that verifies if arp or ns is resolved and if not lists all the unresolved ns or arp. I see that under ixNetwork there is a call for sending Ns or Arp across all interfaces, but do not see one for validation of arp resolution.

ixnetwork.py:
def SendArpAll(self):
"""Executes the sendArpAll operation on the server.

            Send ARP for all interfaces.

            Raises:
                    NotFoundError: The requested resource does not exist on the server
                    ServerError: The server has encountered an uncategorized error condition
            """
            return self._execute('SendArpAll', payload=locals(), response_object=None)

    def SendNsAll(self):
            """Executes the sendNsAll operation on the server.

            Send neighbor solicitation to all interfaces.

            Raises:
                    NotFoundError: The requested resource does not exist on the server
                    ServerError: The server has encountered an uncategorized error condition
            """
            return self._execute('SendNsAll', payload=locals(), response_object=None)

Looking for something like we have in HLT
def verify_arp(self, max_retry=3, handles=False):
'''
For all the unresolved ARPs, ixia returns a string in the below format
with all the IP addresses
'{topology:6 Port:1/4 IP:200.140.2.3 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv4:2}
{topology:6 Port:1/4 IP:200.140.2.4 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv4:2}'
This fucntion return iplist ['200.140.2.3', '200.140.2.4']
or iplist, handle_list
'''
ip_list = list()
handle_list = list()
cmd = 'set unresolved [VerifyArpNgpf ipv4 ' + str(max_retry) + ']'
unresolved_arp = self.tcl.eval(cmd)
if unresolved_arp != '0':
for (ip,handle) in re.findall('IP:(.+?) HANDLE:(.+?)}', unresolved_arp):
ip_list.append(ip)
handle_list.append(handle)
pass
#remove dups in handles
handle_list = list(set(handle_list))
if not handles:
return ip_list
else:
return (ip_list, handle_list)

def verify_nd(self, max_retry=3, handles=False):
    '''
       For all the unresolved NDs, ixia returns a string in the below format
       with all the IP addresses
       '{topology:6 Port:1/4 IP:2000:140:2:0:0:0:3:1 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv6:2} \
        {topology:6 Port:1/4 IP:2000:140:2:0:0:0:3:2 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv6:2}'
       This fucntion return iplist ['2000:140:2:0:0:0:3:1', '2000:140:2:0:0:0:3:2']
       or iplist, handle_list
    '''
    ip_list = list()
    handle_list = list()
    cmd = 'set unresolved [VerifyArpNgpf ipv6 ' + str(max_retry) + ']'
    unresolved_nd = self.tcl.eval(cmd)
    if unresolved_nd != '0':
        for (ip,handle) in re.findall('IP:(.+?) HANDLE:(.+?)}', unresolved_nd):
            ip_list.append(ip)
            handle_list.append(handle)
        pass
    #remove dups in handles
    handle_list = list(set(handle_list))
    if not handles:
        return ip_list
    else:
        return (ip_list, handle_list)

Using a list for Mac addresses instead of increment

Hello,

In my IXIA application, I create a raw traffic item where I need to pass a list of mac addresses rather than doing auto increment (like the following). How can I achieve this in RestPy? ( I know how to do this in IxNetwork but could not see any example in this repo.) Thanks!

ixNetwork.info('Configuring Ethernet packet header')
ethernetDstField = ethernetStackObj.Field.find(DisplayName='Destination MAC Address')
ethernetDstField.ValueType = 'increment'
ethernetDstField.StartValue = "00:00:00:40:08:02"
ethernetDstField.StepValue = "00:00:00:00:00:00"
ethernetDstField.CountValue = 1

the script "loadJsonConfigFile.robot" can not work

the script "loadJsonConfigFile.robot" can not work 。Error happen in executing function “”fileMgmtObj.Import Json Config File‘’, shown that "
20181018 14:21:31.029 : INFO : 14:21:31.020000: Reading saved config file
20181018 14:21:31.032 : FAIL : TypeError: initial_value must be unicode or None, not str
Ending test: Robot.loadJsonConfigFile.Load a JSON config file
"

configure IxNetwork licensing setting is failing

Hello, when using a REST client with a PATCH to the link: https://192.168.45.131/api/v1/sessions/2/ixnetwork/globals/licensing
Body
{
"licensingServers": [ "192.168.45.133" ],
"mode": "subscription",
"tier": "tier3"
}
everything is working. But when using RestPy it is failing.

license_server = ['192.168.45.133']
license_mode = 'mixed'
license_tier = 'tier3'

ixnetwork.Globals.Licensing.LicensingServers(license_server)
2019-05-14 07:31:15 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/", "properties": [], "children": [{"child": "globals", "properties": [""], "filters": []}], "inlines": []}]}
2019-05-14 07:31:15 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
2019-05-14 07:31:15 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/globals", "properties": [], "children": [{"child": "licensing", "properties": ["
"], "filters": []}], "inlines": []}]}
2019-05-14 07:31:15 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
Traceback (most recent call last):
File "", line 1, in
TypeError: 'list' object is not callable

ixnetwork.Globals.Licensing.Mode(license_mode)
2019-05-14 07:31:20 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/", "properties": [], "children": [{"child": "globals", "properties": [""], "filters": []}], "inlines": []}]}
2019-05-14 07:31:21 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
2019-05-14 07:31:21 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/globals", "properties": [], "children": [{"child": "licensing", "properties": ["
"], "filters": []}], "inlines": []}]}
2019-05-14 07:31:21 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
Traceback (most recent call last):
File "", line 1, in
TypeError: 'str' object is not callable

ixnetwork.Globals.Licensing.Tier(license_tier)
2019-05-14 07:31:25 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/", "properties": [], "children": [{"child": "globals", "properties": [""], "filters": []}], "inlines": []}]}
2019-05-14 07:31:26 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
2019-05-14 07:31:26 [ixnetwork_restpy.connection] [DEBUG] POST https://192.168.45.131:443/api/v1/sessions/2/ixnetwork/operations/select?deprecated=true {"selects": [{"from": "/api/v1/sessions/2/ixnetwork/globals", "properties": [], "children": [{"child": "licensing", "properties": ["
"], "filters": []}], "inlines": []}]}
2019-05-14 07:31:26 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted b''
Traceback (most recent call last):
File "", line 1, in
TypeError: 'str' object is not callable

Could you please tell me, what is going wrong?
The version is IxNetwork 8.50 EA.
Application Version: 8.50.1.41IxNetwork API Server Version: 8.50.1.53

Thanks,
Michael

RestPy:Class based queries

Hi Folks,
I remember in one of the deep dive sessions provided to us we went through an example that describes my query below. But I can't seem to recollect the solution. Would someone be able to provide the answer or point to an implementation.

What I basically need is a class based query for a specific class that is the input to the function, without having to derive the tree of parent Objects.

What works now:

ipV4Object = ethernetObject.Ipv4.find(Name='1/11/13_ethernet_t0:ctx0_b5_sepg4_ 1')

What I need to work: IxNetwork.Topology.DeviceGroup.Ethernet.Ipv4.find(Name='1/7/11_ethernet_t0:ctx1_b4_sepg5_ 1')

Right now the above command typed as is results in the following error.

IxNetwork.Topology.DeviceGroup.Ethernet.Ipv4.find(Name='1/7/11_ethernet_t0:ctx1_b4_sepg5_ 1')
Traceback (most recent call last):
File "", line 1, in
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/testplatform/sessions/ixnetwork/topology/ipv4.py", line 690, in find
return self._select(locals())
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/base.py", line 342, in _select
end = len(self._parent.href)
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/base.py", line 102, in href
return self._get_attribute('href')
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/base.py", line 122, in _get_attribute
raise NotFoundError('The attribute %s is not in the internal list of object dicts. (%s)' % (name, e))
NotFoundError: The attribute href is not in the internal list of object dicts. (list index out of range)

load QuickTest config run it and get Report

Hi,
is it possible, to load a QuickTest config run it and get an Report in RestPy?
I am not sure at the moment, if all the features are implemented in RestPy. If not, is there some documentation, what is missing?
Thanks,
Michael

RestPy: lookup by Href not working as expected.

Opening this issue as a continuation to issue#40
RestPy:Any example to retreive object using href? #40

Seems like the options provided do not work as expected, or I probably need to use a different set of procs to attain the same objective.

Has anyone tried this? I can't seem to get the ixnetwork object or any other object instance using this

session = testPlatform.Sessions.find(Id='17')
2019-03-05 00:04:34 [ixnetwork_restpy.connection] [DEBUG] GET https://10.23.239.233:443/api/v1/sessions None
2019-03-05 00:04:34 [ixnetwork_restpy.connection] [DEBUG] 200 OK
ixNetwork = session.GetObjectFromHref('/api/v1/sessions/17/ixnetwork')
ixNetwork
ixNetwork = session.GetObjectFromHref(href = '/api/v1/sessions/17/ixnetwork')
ixNetwork

r = session.GetObjectFromHref(href = '/api/v1/sessions/17/ixnetwork/topology')
r

getMultivalueValues fails, while startAllProtocols(verifyDeviceGroupStatus)

Traceback (most recent call last):
  File "addPacketHeaderRawTraffic.py", line 169, in <module>
    protocolObj.startAllProtocols()
  File "../Modules/IxNetRestApiProtocol.py", line 1222, in startAllProtocols
    self.verifyDeviceGroupStatus()
  File "../Modules/IxNetRestApiProtocol.py", line 1178, in verifyDeviceGroupStatus
    enabled = self.ixnObj.getMultivalueValues(enabledMultivalue, silentMode=True)
  File "../Modules/IxNetRestApi.py", line 998, in getMultivalueValues
    response = self.post(self.sessionUrl+'/multivalue/operations/getValues', data=data, silentMode=silentMode)
  File "../Modules/IxNetRestApi.py", line 291, in post
    raise IxNetRestApiException('POST error: {0}\n'.format(response.json()['errors'][0]['detail']))
IxNetRestApi.IxNetRestApiException: POST error: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

while attempting to fetch

    'enabled': '/api/v1/sessions/1/ixnetwork/multivalue/23',    # count = 1 returned by query

Currently bypassed by,

    def getMultivalueValues(self, multivalueObj, silentMode=False):
        return self.get(self.httpHeader+multivalueObj+'?includes=values', silentMode=silentMode).json()["values"]

IxNetwork Version: 8.10.1046.6 EA
Could not find "getValues" exec in the API Browser (nor docs). (only "/multivalue/operations/getValue")

RestPy:Cannot modify or add OspfRouteProperty

Whenever I try to add or change a property in this default added OspfRouteProperty under Network Group, the restPy module errors out on me. Looks like some modules maybe missing in restPy

networkGroup1.OspfRouteProperty.routeOrigin.Single(

Traceback (most recent call last):
File "/opt/cisco/aci/python2.7/bin/bpython", line 9, in
load_entry_point('bpython==0.12', 'console_scripts', 'bpython')()
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 1918, in main
banner=banner)
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 1815, in curses_wrapper
return func(stdscr, *args, **kwargs)
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 1888, in main_curses
exit_value = clirepl.repl()
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 1116, in repl
inp = self.get_line()
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 673, in get_line
if self.p_key(key) is None:
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 1011, in p_key
self.addstr(key)
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 348, in addstr
self.complete()
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/cli.py", line 445, in complete
self.list_win_visible = repl.Repl.complete(self, tab)
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/repl.py", line 546, in complete
if not self.get_args():
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/repl.py", line 505, in get_args
f = self.get_object(func)
File "/opt/cisco/aci/python2.7/lib/python2.7/site-packages/bpython/repl.py", line 451, in get_object
obj = getattr(obj, attributes.pop(0))
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/testplatform/sessions/ixnetwork/topology/ospfrouteproperty.py", line 297, in RouteOrigin
return self._get_attribute('routeOrigin')
File "/local/vamuthal/Ixia_RestPy/RestPy/ixnetwork_restpy/base.py", line 122, in _get_attribute
raise NotFoundError('The attribute %s is not in the internal list of object dicts. (%s)' % (name, e))
ixnetwork_restpy.errors.NotFoundError: The attribute routeOrigin is not in the internal list of object dicts. (list index out of range)

RestPy: Is there an api to check traffic state?

I keep hitting this issue on and off and it seems to be with scaled config. Ixnetwork does not seem to be ready to accept a traffic apply or start right after another traffic operation. I tried adding a delay of about 5 seconds after each operation but that does not help always either.
In this instance below. I did a traffic.Stop() and then a traffic.Apply() and the command errors out. It does not happen always. But at least once out of three tries. Is there a way to check state before the apply,stop or start command. This way I do not have to add guesstimated sleep commands all throughout.
FYI: The command does go through if I try it again.

File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py", line 292, in _send_recv
raise ServerError(response)
ServerError: https://10.23.239.233:443/api/v1/sessions/14/ixnetwork/traffic/operations/apply?deprecated=true => ERROR None Error in L2/L3 Traffic Apply

2019-03-13 22:37:56 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/14/ixnetwork/operations/select?deprecated=true
{"selects": [{"inlines": [], "from": "/api/v1/sessions/14/ixnetwork/", "properties": [], "children": [{"properties": ["*"], "filters": [], "child": "tra
ffic"}]}]}
2019-03-13 22:37:56 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
2019-03-13 22:37:56 [ixnetwork_restpy.connection] [DEBUG] POST https://10.23.239.233:443/api/v1/sessions/14/ixnetwork/traffic/operations/apply?deprecate
d=true {"Arg1": "/api/v1/sessions/14/ixnetwork/traffic"}
2019-03-13 22:37:56 [ixnetwork_restpy.connection] [DEBUG] 202 Accepted
Test block action failed. Error was: Traceback (most recent call last):
File "harness.py", line 5318, in Do_Test_Block_Action_List
RV = self.Do_Test_Block_Action( Action=Action )
File "harness.py", line 5851, in Do_Test_Block_Action
Action['Action_Result_Details'] = Action['Method'](Params = Test_Block['Params'])
File "ifabric/test_blocks/Debugger/Classes_Debugger_OnDemand_AC_HW_Ixia_optimized.py", line 1233, in Main_Action
my_ixia.start_traffic_hlt()
File "ifabric/ifav/libs/ixia/ixia_NGPF_Restpy.py", line 690, in start_traffic_hlt
self.ixNetwork.Traffic.Apply()
File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/testplatform/sessions/ixnetwork/traffic/traffic.py", line 675, in Apply
return self._execute('apply', payload=payload, response_object=None)
File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/base.py", line 279, in _execute
response = self._connection._execute(url, payload)
File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py", line 136, in _execute
return self._send_recv('POST', url, payload)
File "/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py", line 292, in _send_recv
raise ServerError(response)
ServerError: https://10.23.239.233:443/api/v1/sessions/14/ixnetwork/traffic/operations/apply?deprecated=true => ERROR None Error in L2/L3 Traffic Apply

            Main action result: Failed

            ***Test block Main failed. Error was: Traceback (most recent call last):

File 'harness.py', line 5318, in Do_Test_Block_Action_List
RV = self.Do_Test_Block_Action( Action=Action )
File 'harness.py', line 5851, in Do_Test_Block_Action
Action['Action_Result_Details'] = Action['Method'](Params = Test_Block['Params'])
File 'ifabric/test_blocks/Debugger/Classes_Debugger_OnDemand_AC_HW_Ixia_optimized.py', line 1233, in Main_Action
my_ixia.start_traffic_hlt()
File 'ifabric/ifav/libs/ixia/ixia_NGPF_Restpy.py', line 690, in start_traffic_hlt
self.ixNetwork.Traffic.Apply()
File '/local/vamuthal/IxiaSDK/ixnetwork_restpy/testplatform/sessions/ixnetwork/traffic/traffic.py', line 675, in Apply
return self._execute('apply', payload=payload, response_object=None)
File '/local/vamuthal/IxiaSDK/ixnetwork_restpy/base.py', line 279, in _execute
response = self._connection._execute(url, payload)
File '/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py', line 136, in _execute
return self._send_recv('POST', url, payload)
File '/local/vamuthal/IxiaSDK/ixnetwork_restpy/connection.py', line 292, in _send_recv
raise ServerError(response)
ServerError: https://10.23.239.233:443/api/v1/sessions/14/ixnetwork/traffic/operations/apply?deprecated=true => ERROR None Error in L2/L3 Traffic Apply

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.