-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
7,869 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
ixnetwork_restpy/samples/ports/l1config/l1_config_pcs_error_generation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
l1_config_pcs_error_generation.py: | ||
- Connect to the API server | ||
- In this test, do the following: | ||
- Add two real ports | ||
- Add two vports | ||
- Assign two real ports in to vports | ||
- Find the pcsErrorGeneration from the l1Config | ||
- Update some attributes of pcsErrorGeneration | ||
- Verify the value of the attributes | ||
Supports IxNetwork API servers: | ||
- Windows, Windows Connection Mgr and Linux | ||
Requirements: | ||
- Minimum IxNetwork 9.30 Update 1 | ||
- Python 2.7 and 3+ | ||
- pip install requests | ||
- pip install ixnetwork_restpy (minimum version 1.1.9) | ||
RestPy Doc: | ||
https://openixia.github.io/ixnetwork_restpy/#/overview | ||
Usage: | ||
- Enter: python <script> | ||
""" | ||
|
||
from ixnetwork_restpy import SessionAssistant | ||
|
||
session_assistant = SessionAssistant( | ||
IpAddress="<chassis-ip>", | ||
RestPort="<rest-port>", | ||
UserName="admin", | ||
Password="admin", | ||
LogLevel=SessionAssistant.LOGLEVEL_INFO, | ||
ClearConfig=True, | ||
) | ||
|
||
ixnetwork = session_assistant.Ixnetwork | ||
|
||
# mapping the ports | ||
port_map = session_assistant.PortMapAssistant() | ||
port_map.Map(Location="<chassis-ip>;<card>;<port>", Name="Port 1") | ||
port_map.Map(Location="<chassis-ip>;<card>;<port>", Name="Port 2") | ||
|
||
# using the map connect test port locations and vports | ||
port_map.Connect(ForceOwnership=True, HostReadyTimeout=20, LinkUpTimeout=60) | ||
vport1 = ixnetwork.Vport.find(Name="Port 1") | ||
vport2 = ixnetwork.Vport.find(Name="Port 2") | ||
|
||
# PCS Error Generation configuration | ||
v1_pcsErrorGeneration = vport1.L1Config.PcsErrorGeneration | ||
v1_pcsErrorGeneration.update(PeriodType="laneMarkersAndPayload") | ||
v1_pcsErrorGeneration.update(ErrorBitsHexLaneMarkers="1122334455DDEEFF") | ||
vport1.StartPcsErrorGeneration() |
56 changes: 56 additions & 0 deletions
56
ixnetwork_restpy/samples/ports/l1config/l1_config_tx_lane_and_skew.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
l1_config_aresone_800g_tx_lane_and_skew_checking.py: | ||
- Connect to the API server | ||
- In this test, do the following: | ||
- Add two real ports of AresOne 800G | ||
- Add two vports | ||
- Assign two the ports in to vports | ||
- Find the AresOneEightHundredGigLanQddC from the l1Config | ||
- Update TxLane and Skew attributes of AresOneEightHundredGigLanQddC | ||
- Verify the value of the attributes | ||
Supports IxNetwork API servers: | ||
- Windows, Windows Connection Mgr and Linux | ||
Requirements: | ||
- Minimum IxNetwork 9.30 Update 1 | ||
- Python 2.7 and 3+ | ||
- pip install requests | ||
- pip install ixnetwork_restpy (minimum version 1.1.9) | ||
RestPy Doc: | ||
https://openixia.github.io/ixnetwork_restpy/#/overview | ||
Usage: | ||
- Enter: python <script> | ||
""" | ||
|
||
from ixnetwork_restpy import SessionAssistant | ||
|
||
session_assistant = SessionAssistant( | ||
IpAddress="<chassis-ip>", | ||
RestPort="<rest-port>", | ||
UserName="admin", | ||
Password="admin", | ||
LogLevel=SessionAssistant.LOGLEVEL_INFO, | ||
ClearConfig=True, | ||
) | ||
|
||
ixnetwork = session_assistant.Ixnetwork | ||
|
||
# mapping the ports. Here we have used AresOne-800G for reference | ||
port_map = session_assistant.PortMapAssistant() | ||
port_map.Map(Location="<chassis-ip>;<card>;<port>", Name="Port 1") | ||
port_map.Map(Location="<chassis-ip>;<card>;<port>", Name="Port 2") | ||
|
||
# using the map connect test port locations and vports | ||
port_map.Connect(ForceOwnership=True, HostReadyTimeout=20, LinkUpTimeout=60) | ||
vport1 = ixnetwork.Vport.find(Name="Port 1") | ||
vport2 = ixnetwork.Vport.find(Name="Port 2") | ||
|
||
# Tx Lane and skew | ||
v1_txLane = vport1.L1Config.AresOneEightHundredGigLanQddC.TxLane | ||
print(v1_txLane) | ||
v1_txLane.update(IsSkewSynchronized="true") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
This sample actually demonstrates how call and see the learned information of a protocol. | ||
The sample will be almost identical for rest of the protocols as well | ||
In this test its assumed that bgp session is configured properly and is up and running | ||
This test fetches the bgpv4 peer interface and calls the operation to get all learned info | ||
After that it showcases from where we can get the learned info information for bgp. | ||
Supports IxNetwork API servers: | ||
- Windows, Windows Connection Mgr and Linux | ||
Requirements: | ||
- Minimum IxNetwork 8.50 | ||
- Python 2.7 and 3+ | ||
RestPy Doc: | ||
https://openixia.github.io/ixnetwork_restpy/#/overview | ||
""" | ||
|
||
from ixnetwork_restpy import SessionAssistant | ||
|
||
# connecting to an existing ixn session , note the clear config is false. | ||
session_assistant = SessionAssistant( | ||
IpAddress="localhost", | ||
RestPort=11009, | ||
UserName="admin", | ||
Password="admin", | ||
LogLevel=SessionAssistant.LOGLEVEL_ALL, | ||
ClearConfig=False, | ||
) | ||
|
||
ixn = session_assistant.Ixnetwork | ||
|
||
# finding the bgpv4 peer according to our need | ||
bgp = ( | ||
ixn.Topology.find() | ||
.DeviceGroup.find() | ||
.Ethernet.find() | ||
.Ipv4.find() | ||
.BgpIpv4Peer.find() | ||
) | ||
|
||
# calling the get all learned info operation | ||
# note here we have showcased a simple call that fetches learned info of all bgp sessions | ||
# if a particular session is required we can pass a list of session indices | ||
# eg: bgp.GetAllLearnedInfo([1,5,9]) | ||
bgp.GetAllLearnedInfo() | ||
|
||
# showcases from where we can retrieve the fetched learned info | ||
learned_info_table = bgp.LearnedInfo.find().Table.find() | ||
print(learned_info_table) |
69 changes: 69 additions & 0 deletions
69
ixnetwork_restpy/samples/statistics/custom_view/port_custom_view.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
Creates a port custom view | ||
This sample requires a running ixnetwork instance that has ports in up state. | ||
It uses all possible port filters and statistics when creating the view. | ||
The last step prior to getting data should be to enable the view. | ||
Supports IxNetwork API servers: | ||
- Windows, Windows Connection Mgr and Linux | ||
Requirements: | ||
- Minimum IxNetwork 9.30 | ||
- Python 2.7 and 3+ | ||
- pip install requests | ||
- pip install ixnetwork_restpy (minimum version 1.1.8) | ||
""" | ||
|
||
from time import sleep | ||
from ixnetwork_restpy import SessionAssistant | ||
|
||
|
||
session_assistant = SessionAssistant( | ||
IpAddress="127.0.0.1", | ||
UserName="admin", | ||
Password="admin", | ||
LogLevel=SessionAssistant.LOGLEVEL_INFO, | ||
ClearConfig=False, | ||
) | ||
ixnetwork = session_assistant.Ixnetwork | ||
|
||
|
||
# remove the view if it already exists | ||
caption = "Port Custom View" | ||
view = ixnetwork.Statistics.View.find(Caption=caption) | ||
if len(view) == 1: | ||
view.remove() | ||
|
||
# create the view | ||
view = ixnetwork.Statistics.View.add( | ||
Caption=caption, Type="layer23ProtocolPort", Visible=True | ||
) | ||
|
||
# set layer 2-3 port filters | ||
l23_port_filter = view.Layer23ProtocolPortFilter.find() | ||
|
||
# iterate over the PortFilters and enable them | ||
for port_filter in l23_port_filter.PortFilters.find(): | ||
# set the port filter to True to enable it | ||
port_filter.Enabled = True | ||
|
||
# enable statistics | ||
for statistic in view.Statistic.find(): | ||
statistic.Enabled = True | ||
|
||
# enable the view | ||
view.Enabled = True | ||
|
||
# wait for data to become available | ||
attempts = 0 | ||
while view.Data.IsReady is False and attempts < 10: | ||
sleep(1) | ||
attempts += 1 | ||
|
||
# print the column headers | ||
print(" ".join(view.Data.ColumnCaptions)) | ||
|
||
# print the snapshot data | ||
for data in view.Data.PageValues: | ||
for row in data: | ||
print(" ".join(row)) |
Oops, something went wrong.