Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatible with latest model #563

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ on:

jobs:
cicd:
runs-on: [self-hosted, Linux, Ubuntu, x64]
strategy:
max-parallel: 1
matrix:
python-version: [python27, python38]

runs-on: [snappi-ixn-ci-novus100g]
steps:
- name: Checkout source
uses: actions/checkout@v2
Expand All @@ -22,7 +17,7 @@ jobs:
submodules: recursive
- name: Set python path
id: path
run: echo "::set-output name=pythonv::/home/otg/${{matrix.python-version}}/bin/python"
run: echo "::set-output name=pythonv::/home/github-runner/pyenv/.env/bin/python"
- name: Install dependencies
run: |
rm -rf .env
Expand Down
22 changes: 5 additions & 17 deletions do.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,13 @@ def lint():

def test():
coverage_threshold = 67
# args = [
# '--location="https://10.39.71.97:443"',
# (
# '--ports="10.39.65.230;6;1 10.39.65.230;6;2 10.39.65.230;6;3'
# ' 10.39.65.230;6;4"'
# ),
# '--media="fiber"',
# "tests",
# '-m "not e2e and not l1_manual"',
# '--cov=./snappi_ixnetwork --cov-report term'
# ' --cov-report html:cov_report',
# ]
args = [
'--location="https://otg-novus100g.lbj.is.keysight.com:5000"',
'--location="https://snappi-ixn-ci-novus100g.lbj.is.keysight.com:5000"',
(
'--ports="otg-novus100g.lbj.is.keysight.com;1;1'
" otg-novus100g.lbj.is.keysight.com;1;2"
" otg-novus100g.lbj.is.keysight.com;1;5"
' otg-novus100g.lbj.is.keysight.com;1;6"'
'--ports="snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;1'
" snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;2"
" snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;5"
' snappi-ixn-ci-novus100g.lbj.is.keysight.com;1;6"'
),
"--ext=ixnetwork",
"--speed=speed_100_gbps",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# snappi Extension for IxNetwork

[![license](https://img.shields.io/badge/license-MIT-green.svg)](https://en.wikipedia.org/wiki/MIT_License)
[![Project Status: Active The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Build](https://github.com/open-traffic-generator/snappi-ixnetwork/workflows/Build/badge.svg)](https://github.com/open-traffic-generator/snappi-ixnetwork/actions)
[![pypi](https://img.shields.io/pypi/v/snappi_ixnetwork.svg)](https://pypi.org/project/snappi_ixnetwork)
[![python](https://img.shields.io/pypi/pyversions/snappi_ixnetwork.svg)](https://pypi.python.org/pypi/snappi_ixnetwork)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import setuptools

pkg_name = "snappi_ixnetwork"
version = "0.9.1"
version = "0.11.5"

# read long description from readme.md
base_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -37,7 +37,7 @@
install_requires=["ixnetwork-restpy>=1.0.52"],
extras_require={
"testing": [
"snappi==0.9.1",
"snappi==0.11.5",
"snappi_convergence==0.4.1",
"pytest",
"mock",
Expand Down
9 changes: 4 additions & 5 deletions snappi_ixnetwork/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Ping(object):
def __init__(self, ixnetworkapi):
self._api = ixnetworkapi

def results(self, ping_request):
def results(self, req_type, ping_request):
Vibaswan marked this conversation as resolved.
Show resolved Hide resolved
responses = []
v4_names = []
for device in self._api._config.devices:
Expand All @@ -33,9 +33,8 @@ def results(self, ping_request):
v6_names.append(ip.name)

with Timer(self._api, "Ping requests completed in"):
for endpoint in ping_request.endpoints:
for endpoint in ping_request.requests:
response = {}
req_type = endpoint.parent.choice
src_name = endpoint.get("src_name")
dst_ip = endpoint.get("dst_ip")
if req_type == "ipv4":
Expand Down Expand Up @@ -71,9 +70,9 @@ def results(self, ping_request):
for reply in ping_status:
if dst_ip in reply["arg3"]:
if reply["arg2"]:
response["result"] = "success"
response["result"] = "succeeded"
else:
response["result"] = "failure"
response["result"] = "failed"
response["src_name"] = src_name
response["dst_ip"] = dst_ip
responses.append(response)
Expand Down
4 changes: 2 additions & 2 deletions snappi_ixnetwork/protocolmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,5 @@ def results(self, request):
if len(self.columns) > 0:
self.columns.append("name") if "name" not in self.columns else None
self.columns = list(set(self.columns))
with Timer(self._api, "Fetching {} Metrics".format(protocol)):
return self._filter_stats(protocol)
#with Timer(self._api, "Fetching {} Metrics".format(protocol)):
Vibaswan marked this conversation as resolved.
Show resolved Hide resolved
return self._filter_stats(protocol)
100 changes: 97 additions & 3 deletions snappi_ixnetwork/snappi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __init__(self, **kwargs):
self._device_encap = {}
self.ixn_objects = None
self._config_type = self.config()
self._control_state = self.control_state()
self._control_action = self.control_action()
self._protocol_state = self.protocol_state()
self._flows_update = self.flows_update()
self._transmit_state = self.transmit_state()
Expand Down Expand Up @@ -160,7 +162,7 @@ def _dict_to_obj(self, source):
return o

def _request_detail(self):
request_detail = snappi.ResponseWarning()
request_detail = snappi.Warning()
errors = self._errors
warnings = list()
app_errors = self._globals.AppErrors.find()
Expand Down Expand Up @@ -301,9 +303,62 @@ def _protocols_exists(self):
return True
else:
return False


def set_control_state(self, payload):
try:
control_option = payload.choice
control_obj = getattr(payload, control_option)
control_choice = control_obj.get("choice")
request_payload = getattr(control_obj, control_choice)
self._connect()
if control_option == "port":
if control_choice == "capture":
self.capture.set_capture_state(request_payload)
elif control_choice == "link":
self.vport.set_link_state(request_payload)
elif control_option == "protocol":
if control_choice == "all":
self.ngpf.set_protocol_state(request_payload)
elif control_choice == "route":
self.ngpf.set_route_state(request_payload)
elif control_choice == "lacp":
self.ngpf.set_device_state(request_payload)
elif control_option == "traffic":
self.traffic_item.transmit(request_payload)
except Exception as err:
raise SnappiIxnException(err)
return self._request_detail()

def set_control_action(self, payload):
try:
control_option = payload.choice
control_obj = getattr(payload, control_option)
control_choice = control_obj.get("choice")
choice_obj = getattr(control_obj, control_choice)
if control_choice == "ipv4":
choice = choice_obj.get("choice")
request_payload = getattr(choice_obj, choice)
if choice == "ping":
res = self.control_action_response()
self._connect()
res.response.protocol.ipv4.ping.responses.deserialize(self.ping.results(control_choice, request_payload))
elif control_choice == "ipv6":
choice = choice_obj.get("choice")
request_payload = getattr(choice_obj, choice)
if choice == "ping":
res = self.control_action_response()
self._connect()
res.response.protocol.ipv6.ping.responses.deserialize(self.ping.results(control_choice, request_payload))
res.warnings=snappi.Warning()
return res
except Exception as err:
raise SnappiIxnException(err)

def set_protocol_state(self, payload):
Vibaswan marked this conversation as resolved.
Show resolved Hide resolved
"""Set the transmit state of flows"""
self.add_warnings(
"set_protocol_state api is deprecated, Please use `set_control_state` with `protocol.all` choice instead"
)
try:
if isinstance(payload, (type(self._protocol_state), str)) is False:
raise TypeError(
Expand All @@ -320,6 +375,9 @@ def set_protocol_state(self, payload):

def set_transmit_state(self, payload):
"""Set the transmit state of flows"""
self.add_warnings(
"set_transmit_state api is deprecated, Please use `set_control_state` with `traffic` choice instead"
)
try:
if isinstance(payload, (type(self._transmit_state), str)) is False:
raise TypeError(
Expand All @@ -334,6 +392,9 @@ def set_transmit_state(self, payload):
return self._request_detail()

def set_link_state(self, link_state):
self.add_warnings(
"set_link_state api is deprecated, Please use `set_control_state` with `port.link` choice instead"
)
try:
if isinstance(link_state, (type(self._link_state), str)) is False:
raise TypeError(
Expand All @@ -350,6 +411,9 @@ def set_link_state(self, link_state):

def set_capture_state(self, payload):
"""Starts capture on all ports that have capture enabled."""
self.add_warnings(
"set_capture_state api is deprecated, Please use `set_control_state` with `port.capture` choice instead"
)
try:
if isinstance(payload, (type(self._capture_state), str)) is False:
raise TypeError(
Expand All @@ -364,6 +428,9 @@ def set_capture_state(self, payload):
return self._request_detail()

def set_route_state(self, payload):
self.add_warnings(
"set_route_state api is deprecated, Please use `set_control_state` with `protocol.all` choice instead"
)
try:
route_state = self.route_state()
if isinstance(payload, (type(route_state), str)) is False:
Expand All @@ -380,6 +447,9 @@ def set_route_state(self, payload):
raise SnappiIxnException(err)

def set_device_state(self, payload):
self.add_warnings(
"set_device_state api is deprecated, Please use `set_control_state` with `protocol.link` choice instead"
)
try:
device_state = self.device_state()
if isinstance(payload, (type(device_state), str)) is False:
Expand All @@ -396,6 +466,9 @@ def set_device_state(self, payload):
raise SnappiIxnException(err)

def send_ping(self, ping_request, cvg_api=None):
self.add_warnings(
"send_ping api is deprecated, Please use `set_control_action` with `protocol.ipv4.ping` choice instead"
)
try:
if cvg_api:
if isinstance(ping_request, type(cvg_api.ping_request())):
Expand Down Expand Up @@ -432,6 +505,7 @@ def send_ping(self, ping_request, cvg_api=None):
except Exception as err:
raise SnappiIxnException(err)


def get_capture(self, request):
"""Gets capture file and returns it as a byte stream"""
try:
Expand Down Expand Up @@ -1135,4 +1209,24 @@ def debug(self, message):
self.logger.debug(message)

def warning(self, message):
logging.warning(message)
logging.warning(message)

def get_version(self):
try:
import pkg_resources
sdk_version = (
"snappi-"
+ pkg_resources.get_distribution("snappi").version
)
app_version = (
"snappi_ixnetwork-"
+ pkg_resources.get_distribution(
"snappi_ixnetwork"
).version
)

return {"api_spec_version" : "open-api-models-" + snappi.Api.get_local_version(self).api_spec_version,
"sdk_version" : sdk_version,
"app_version" : app_version}
except:
raise SnappiIxnException("unable to get version")
3 changes: 1 addition & 2 deletions tests/bgp/test_bgpv4_stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.mark.skip(reason="Revisit CI/CD fail")
#@pytest.mark.skip(reason="Revisit CI/CD fail")
def test_bgpv4_stats(api, b2b_raw_config, utils):
"""
Test for the bgpv4 metrics
Expand Down Expand Up @@ -68,7 +68,6 @@ def test_bgpv4_stats(api, b2b_raw_config, utils):
req.bgpv4.peer_names = []
req.bgpv4.column_names = enums[:3]
results = api.get_metrics(req)

assert len(results.bgpv4_metrics) == 2
for bgp_res in results.bgpv4_metrics:
for i, enum in enumerate(enums[:3]):
Expand Down
Loading