Skip to content

Commit 8d4652a

Browse files
committed
"version 1.8.0"
1 parent ed6243d commit 8d4652a

File tree

79 files changed

+8316
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+8316
-196
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Release Notes
2+
### July 2025
3+
* 1.8.0
4+
* support for ixnetwork version 11.00.2407.67 (11.00 Update-1)
25
### May 2025
36
* 1.7.0
47
* support for ixnetwork version 11.00.2504.10 (11.00 EA)

ixnetwork_restpy/assistants/batch/batchadd.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ def _handle_multivalue_xpath(self, value, xpath):
287287
xpath_dict["stepValue"] = pattern[3]
288288
else:
289289
xpath_dict["step"] = pattern[3]
290+
if packet_field and len(pattern) == 5:
291+
xpath_dict["countValue"] = pattern[4]
290292
elif multivalue_name == "repeatableRandomRange":
291293
if pattern[1] is not None:
292294
xpath_dict["min"] = pattern[1]
@@ -384,6 +386,7 @@ def _insert_dirty_properties(self, dirty_values, xpath_dict):
384386
def _commit(self):
385387
with Timer(self._ixnetwork) as timer:
386388
self._process_cached_objects()
389+
self._sort_traffic_fields()
387390
errs = self._ixnetwork.ResourceManager.ImportConfig(
388391
json.dumps(self._config), False
389392
)
@@ -529,3 +532,19 @@ def __recursively_fill_hrefs(self, href_dict, ixn_object, ignore_list):
529532
for key in obj.keys():
530533
if isinstance(obj[key], Base):
531534
self.__recursively_fill_hrefs(href_dict, obj[key], ignore_list)
535+
536+
def _sort_traffic_fields(self):
537+
tr_fields = {}
538+
for item in self._config[::-1]:
539+
if "stack[@alias" in item["xpath"]:
540+
if len(item.keys()) > 1:
541+
tr_fields[item["xpath"]] = item
542+
self._config.remove(item)
543+
sorted_values = [
544+
it[1]
545+
for it in sorted(
546+
tr_fields.items(),
547+
key=lambda item: tuple(map(int, re.findall(r"-(\d+)", item[0]))),
548+
)
549+
]
550+
self._config += sorted_values

ixnetwork_restpy/multivalue.py

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -314,82 +314,56 @@ def Alternate(self, alternating_value):
314314
else:
315315
self._set_pattern("alternate", {"value": alternating_value})
316316

317-
def Increment(self, start_value=None, step_value=None):
317+
def Increment(self, start_value=None, step_value=None, count_value=None):
318318
"""Sets the multivalue to an incrementing pattern
319319
320320
Args
321321
----
322322
- start_value (str): The value at which to begin incrementing
323323
- step_value (str): The value to increment by
324+
- count_value (str): The number of values after which the patter will .
325+
Please note count_value is only valid when used for traffic field in batch add mode.
324326
"""
325327
if self._parent._mode[0] == "config":
326-
# multivalue_dict = dict()
327-
# if 'stack' in self._parent._properties['xpath']:
328-
# multivalue_dict['xpath'] = self._get_field_multivalue_xpath(self._href)
329-
# multivalue_dict['valueType'] = 'increment'
330-
# multivalue_dict['auto'] = False
331-
# multivalue_dict['optionalEnabled'] = True
332-
# if start_value is not None:
333-
# multivalue_dict['startValue'] = start_value
334-
# if step_value is not None:
335-
# multivalue_dict['stepValue'] = step_value
336-
# else:
337-
# multivalue_dict['xpath'] = self._get_multivalue_xpath(self._href, 'counter')
338-
# multivalue_dict['direction'] = 'increment'
339-
# if start_value is not None:
340-
# multivalue_dict['start'] = start_value
341-
# if step_value is not None:
342-
# multivalue_dict['step'] = step_value
343-
#
344-
# self._xpathObj._config.append(multivalue_dict)
345328
attr_list = ["counter", "increment", start_value, step_value]
346329
if "stack_index" in self._parent._properties:
347330
attr_list = ["field"] + attr_list
331+
if count_value:
332+
attr_list.append(count_value)
348333
if self._dirty:
349334
self._multiValueObj["multiValue"].append({self._href: attr_list})
350335
else:
351336
self._parent._properties["multiValue"].append({self._href: attr_list})
352337
else:
338+
if count_value is not None:
339+
raise Exception("count_value is not valid when used without batch add")
353340
payload = {"direction": "increment"}
354341
if start_value is not None:
355342
payload["start"] = start_value
356343
if step_value is not None:
357344
payload["step"] = step_value
358345
self._set_pattern("counter", payload)
359346

360-
def Decrement(self, start_value=None, step_value=None):
347+
def Decrement(self, start_value=None, step_value=None, count_value=None):
361348
"""Sets the multivalue to a decrementing pattern
362349
363350
Args
364351
----
365352
- start_value (str): The value at which to begin decrementing
366353
- step_value (str): The value to decrement by
354+
- count_value (str): The number of values after which the patter will .
355+
Please note count_value is only valid when used for traffic field in batch add mode.
367356
"""
368357
if self._parent._mode[0] == "config":
369-
# multivalue_dict = dict()
370-
# if 'stack' in self._parent._properties['xpath']:
371-
# multivalue_dict['xpath'] = self._get_field_multivalue_xpath(self._href)
372-
# multivalue_dict['valueType'] = 'decrement'
373-
# multivalue_dict['auto'] = False
374-
# multivalue_dict['optionalEnabled'] = True
375-
# if start_value is not None:
376-
# multivalue_dict['startValue'] = start_value
377-
# if step_value is not None:
378-
# multivalue_dict['stepValue'] = step_value
379-
# else:
380-
# multivalue_dict['xpath'] = self._get_multivalue_xpath(self._href, 'counter')
381-
# multivalue_dict['direction'] = 'decrement'
382-
# if start_value is not None:
383-
# multivalue_dict['start'] = start_value
384-
# if step_value is not None:
385-
# multivalue_dict['step'] = step_value
386-
#
387-
# self._xpathObj._config.append(multivalue_dict)
388358
attr_list = ["counter", "decrement", start_value, step_value]
389359
if "stack_index" in self._parent._properties:
390360
attr_list = ["field"] + attr_list
361+
if count_value:
362+
attr_list.append(count_value)
391363
self._parent._properties["multiValue"].append({self._href: attr_list})
392364
else:
365+
if count_value is not None:
366+
raise Exception("count_value is not valid when used without batch add")
393367
payload = {"direction": "decrement"}
394368
if start_value is not None:
395369
payload["start"] = start_value

ixnetwork_restpy/pytest_tests/tests/batch/batch_add/test_batch_add_traffic.py

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,127 @@ def test_batch_add_traffic_for_non_active_fields(ixnetwork):
313313
assert field.SingleValue == "1.1.1.1"
314314

315315

316+
def test_add_multiple_same_traffic_stacks(ixnetwork):
317+
with BatchAdd(ixnetwork):
318+
vport = ixnetwork.Vport.add().add()
319+
vport[0].Name = "myVport_1"
320+
vport[0].RxMode = "captureAndMeasure"
321+
vport[1].Name = "myVport_2"
322+
traffic = ixnetwork.Traffic.TrafficItem
323+
tr1 = traffic.add(
324+
Name="RAW TCP",
325+
BiDirectional=False,
326+
TrafficType="raw",
327+
TrafficItemType="l2L3",
328+
)
329+
tr1.EndpointSet.add(
330+
Sources=vport[0].Protocols.add(), Destinations=vport[1].Protocols.add()
331+
)
332+
333+
stack = tr1.ConfigElement.add().Stack.add()
334+
eth_st = stack.Ethernet.add()
335+
eth_st.SourceAddress.Single("00:11:00:00:22:00")
336+
eth_st.DestinationAddress.Single("00:33:00:11:22:00")
337+
338+
vlan_st = stack.Vlan.add()
339+
vlan_st.VlanTagVlanID.Single(2)
340+
vlan_st.VlanTagVlanUserPriority.Single(7)
341+
vlan_st.VlanTagCfi.Single(1)
342+
343+
vlan_st2 = stack.Vlan.add()[-1]
344+
vlan_st2.VlanTagVlanID.Single(1)
345+
vlan_st2.VlanTagVlanUserPriority.Single(5)
346+
vlan_st2.VlanTagCfi.Single(0)
347+
348+
ipv4_st = stack.Ipv4.add()
349+
ipv4_st.SrcIp.Increment("1.1.1.1", "0.1.1.1", 3)
350+
351+
tcp_st = stack.Tcp.add()
352+
tcp_st.Reserved.Single(1)
353+
354+
ipv4_st2 = stack.Ipv4.add()[-1]
355+
ipv4_st2.Ttl.Decrement("60", "1", 5)
356+
357+
# finding all stacks now
358+
stacks = ixnetwork.Traffic.TrafficItem.find().ConfigElement.find().Stack.find()
359+
assert len(stacks) == 7
360+
assert stacks[0].StackTypeId == "ethernet"
361+
assert stacks[1].StackTypeId == "vlan"
362+
assert stacks[2].StackTypeId == "vlan"
363+
assert stacks[3].StackTypeId == "ipv4"
364+
assert stacks[5].StackTypeId == "ipv4"
365+
366+
p1 = stacks[1].Field.find(FieldTypeId="^vlan.header.vlanTag.vlanUserPriority$")
367+
p2 = stacks[2].Field.find(FieldTypeId="^vlan.header.vlanTag.vlanUserPriority$")
368+
p3 = stacks[3].Field.find(FieldTypeId="^ipv4.header.srcIp$")
369+
p4 = stacks[5].Field.find(FieldTypeId="^ipv4.header.ttl$")
370+
assert p1.SingleValue == "7"
371+
assert p2.SingleValue == "5"
372+
assert p3.ValueType == "increment"
373+
assert p3.StartValue == "1.1.1.1"
374+
assert p3.StepValue == "0.1.1.1"
375+
assert p3.CountValue == "3"
376+
assert p4.ValueType == "decrement"
377+
assert p4.StartValue == "60"
378+
assert p4.StepValue == "1"
379+
assert p4.CountValue == "5"
380+
381+
382+
def test_add_multiple_custom_traffic_stacks(ixnetwork):
383+
with BatchAdd(ixnetwork):
384+
vport = ixnetwork.Vport.add().add()
385+
vport[0].Name = "myVport_1"
386+
vport[0].RxMode = "captureAndMeasure"
387+
vport[1].Name = "myVport_2"
388+
traffic = ixnetwork.Traffic.TrafficItem
389+
tr1 = traffic.add(
390+
Name="RAW TCP",
391+
BiDirectional=False,
392+
TrafficType="raw",
393+
TrafficItemType="l2L3",
394+
)
395+
tr1.EndpointSet.add(
396+
Sources=vport[0].Protocols.add(), Destinations=vport[1].Protocols.add()
397+
)
398+
399+
stack = tr1.ConfigElement.add().Stack.add()
400+
eth_st = stack.Ethernet.add()
401+
eth_st.SourceAddress.Single("00:11:00:00:22:00")
402+
eth_st.DestinationAddress.Single("00:33:00:11:22:00")
403+
404+
custom1 = stack.Custom.add()
405+
custom1.HeaderLength.Single(20)
406+
custom1.HeaderData.Single("a")
407+
408+
custom2 = stack.Customv2.add()
409+
custom2.HeaderLength.Single(20)
410+
custom2.HeaderData.Single("4aec")
411+
412+
custom3 = stack.Custom.add()[-1]
413+
custom3.HeaderLength.Single(20)
414+
custom3.HeaderData.Single("5ecff")
415+
416+
custom4 = stack.Customv2.add()[-1]
417+
custom4.HeaderLength.Single(20)
418+
custom4.HeaderData.Single("abc")
419+
420+
stacks = ixnetwork.Traffic.TrafficItem.find().ConfigElement.find().Stack.find()
421+
assert len(stacks) == 6
422+
assert stacks[0].StackTypeId == "ethernet"
423+
assert stacks[1].StackTypeId == "custom"
424+
assert stacks[2].StackTypeId == "custom_v2"
425+
assert stacks[3].StackTypeId == "custom"
426+
assert stacks[4].StackTypeId == "custom_v2"
427+
428+
p1 = stacks[1].Field.find(FieldTypeId="^custom.header.data$")
429+
p2 = stacks[2].Field.find(FieldTypeId="^custom_v2.header.data$")
430+
p3 = stacks[3].Field.find(FieldTypeId="^custom.header.data$")
431+
p4 = stacks[4].Field.find(FieldTypeId="^custom_v2.header.data$")
432+
assert p1.SingleValue == "a"
433+
assert p2.SingleValue == "4AEC"
434+
assert p3.SingleValue == "5ecff"
435+
assert p4.SingleValue == "0ABC"
436+
437+
316438
if __name__ == "__main__":
317439
pytest.main(["-v", "-s", "--server", "localhost:11009:windows", __file__])

ixnetwork_restpy/testplatform/sessions/ixnetwork/globals/porttestoptions/porttestoptions.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ class PortTestOptions(Base):
3636
_SDM_NAME = "portTestOptions"
3737
_SDM_ATT_MAP = {
3838
"EnableDpdkPerformanceAcceleration": "enableDpdkPerformanceAcceleration",
39+
"PortLldpOperation": "portLldpOperation",
40+
}
41+
_SDM_ENUM_MAP = {
42+
"portLldpOperation": ["noOp", "enablePortLldp", "disablePortLldp"],
3943
}
40-
_SDM_ENUM_MAP = {}
4144

4245
def __init__(self, parent, list_op=False):
4346
super(PortTestOptions, self).__init__(parent, list_op)
@@ -61,22 +64,38 @@ def EnableDpdkPerformanceAcceleration(self, value):
6164
self._SDM_ATT_MAP["EnableDpdkPerformanceAcceleration"], value
6265
)
6366

64-
def update(self, EnableDpdkPerformanceAcceleration=None):
65-
# type: (bool) -> PortTestOptions
67+
@property
68+
def PortLldpOperation(self):
69+
# type: () -> str
70+
"""
71+
Returns
72+
-------
73+
- str(noOp | enablePortLldp | disablePortLldp): Port LLDP operation performed during port connect/reboot. Please reconnect or reboot the port(s) for this to take effect.
74+
"""
75+
return self._get_attribute(self._SDM_ATT_MAP["PortLldpOperation"])
76+
77+
@PortLldpOperation.setter
78+
def PortLldpOperation(self, value):
79+
# type: (str) -> None
80+
self._set_attribute(self._SDM_ATT_MAP["PortLldpOperation"], value)
81+
82+
def update(self, EnableDpdkPerformanceAcceleration=None, PortLldpOperation=None):
83+
# type: (bool, str) -> PortTestOptions
6684
"""Updates portTestOptions resource on the server.
6785
6886
Args
6987
----
7088
- EnableDpdkPerformanceAcceleration (bool): Enable DPDK traffic engine mode for performance acceleration in data plane.
89+
- PortLldpOperation (str(noOp | enablePortLldp | disablePortLldp)): Port LLDP operation performed during port connect/reboot. Please reconnect or reboot the port(s) for this to take effect.
7190
7291
Raises
7392
------
7493
- ServerError: The server has encountered an uncategorized error condition
7594
"""
7695
return self._update(self._map_locals(self._SDM_ATT_MAP, locals()))
7796

78-
def find(self, EnableDpdkPerformanceAcceleration=None):
79-
# type: (bool) -> PortTestOptions
97+
def find(self, EnableDpdkPerformanceAcceleration=None, PortLldpOperation=None):
98+
# type: (bool, str) -> PortTestOptions
8099
"""Finds and retrieves portTestOptions resources from the server.
81100
82101
All named parameters are evaluated on the server using regex. The named parameters can be used to selectively retrieve portTestOptions resources from the server.
@@ -86,6 +105,7 @@ def find(self, EnableDpdkPerformanceAcceleration=None):
86105
Args
87106
----
88107
- EnableDpdkPerformanceAcceleration (bool): Enable DPDK traffic engine mode for performance acceleration in data plane.
108+
- PortLldpOperation (str(noOp | enablePortLldp | disablePortLldp)): Port LLDP operation performed during port connect/reboot. Please reconnect or reboot the port(s) for this to take effect.
89109
90110
Returns
91111
-------

0 commit comments

Comments
 (0)