Skip to content

Commit

Permalink
"version 1.1.10"
Browse files Browse the repository at this point in the history
  • Loading branch information
vhowdhur committed Jul 19, 2023
1 parent a191299 commit c8ecc77
Show file tree
Hide file tree
Showing 279 changed files with 18,634 additions and 498 deletions.
11 changes: 11 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Release Notes
### July 2023
* 1.1.10
* support ixnetwork version 9.30.2306.60 (9.30 Update-2)
* Bug Fixes and features
* Support to ignore strong password policy
* New attribute in SessionAssistant name `IgnoreStrongPasswordPolicy`, by default `True`
* fix missing files of pcep learned info
* fix issue related to overlays
* fix issue regarding improper cache clearance for poll urls
* minor improvements to port map assistant

### April 2023
* 1.1.9
* support ixnetwork version 9.30.2304.57 (9.30 Update-1)
Expand Down
27 changes: 23 additions & 4 deletions ixnetwork_restpy/assistants/ports/portmapassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,34 @@ def _add_hosts(self, HostReadyTimeout):
if ";" in map["location"]:
chassis_address = map["location"].split(";")[0]
ip_addresses.append(chassis_address)
ip_addresses = set(ip_addresses)
ip_addresses = list(set(ip_addresses))
if len(ip_addresses) > 0:
self._IxNetwork.info(
"Adding test port hosts [%s]..." % ", ".join(ip_addresses)
)
ip_str = ", ".join(ip_addresses)
self._IxNetwork.info("Adding test port hosts [%s]..." % ip_str)

# check if chassis is already added
res = self._select_chassis("")
ips_not_ready = []
if "chassis" in res:
for chassis_info in res["chassis"]:
ip = chassis_info["hostname"]
if ip in ip_addresses:
if chassis_info["state"] != "ready":
ips_not_ready.append(ip)
ip_addresses.remove(ip)

if len(ip_addresses) == 0:
self._IxNetwork.info("[%s] is already added." % ip_str)

url = self._IxNetwork.href + "/availableHardware/chassis"
for ip_address in ip_addresses:
payload = {"hostname": ip_address}
self._IxNetwork._connection._create(url, payload)

ip_addresses = ip_addresses + ips_not_ready
if len(ip_addresses) == 0:
return

start_time = time.time()
while True:
select = self._select_chassis("^(%s)$" % "|".join(ip_addresses))
Expand Down
7 changes: 6 additions & 1 deletion ixnetwork_restpy/assistants/sessions/sessionassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def __init__(
SessionName=None,
ApplicationType=APP_TYPE_IXNETWORK,
ClearConfig=False,
UrlPrefix=None,
IgnoreStrongPasswordPolicy=True,
):
"""Create a session or connect to an existing session.
Provides access to the TestPlatform, Sessions, Ixnetwork, PortMapAssistant and StatViewAssistant classes.
Expand Down Expand Up @@ -68,6 +70,8 @@ def __init__(
- SessionName (str): The name of the session to connect to.
- ApplicationType (str(APP_TYPE_IXNETWORK|APP_TYPE_QUICKTEST)): The type of IxNetwork middleware test session to create
- ClearConfig (bool): Clear the current configuration
- UrlPrefix (str): Some appliances (like novus-mini) needs url prefix in their rest url nomenclature
- IgnoreStrongPasswordPolicy (bool): By default True, it rejects authentication with server if password is weak.
Raises
------
Expand All @@ -83,11 +87,12 @@ def __init__(
ignore_env_proxy=IgnoreEnvProxy,
verify_cert=VerifyCertificates,
trace=LogLevel,
url_prefix=UrlPrefix,
)
if ApiKey is not None:
testplatform.ApiKey = ApiKey
elif UserName is not None and Password is not None:
testplatform.Authenticate(UserName, Password)
testplatform.Authenticate(UserName, Password, IgnoreStrongPasswordPolicy)
session = None
if SessionId is not None:
session = testplatform.Sessions.find(Id=SessionId)
Expand Down
33 changes: 26 additions & 7 deletions ixnetwork_restpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Connection(object):
TRACE_ALL = "all"
PLATFORMS = {
"Jetty": "linux",
"nginx/1.17.8": "linux",
"nginx": "linux",
"SelfHost": "windows",
"Kestrel": "windows",
"Microsoft-HTTPAPI/2.0": "connection_manager",
Expand All @@ -78,6 +78,7 @@ def __init__(
verify_cert=False,
trace="none",
script_watch=True,
url_prefix=None,
):
"""Set the connection parameters to a rest server
Expand All @@ -89,6 +90,7 @@ def __init__(
ignore_env_proxy (bool):
verify_cert (bool):
script_watch (bool):
url_prefix (str): the prefix that needs to added in the rest url
"""
self.trace = trace
if len(logging.getLogger(__name__).handlers) == 0:
Expand Down Expand Up @@ -135,6 +137,7 @@ def __init__(
if ignore_env_proxy is True:
os.environ["no_proxy"] = "*"
self._hostname = hostname
self._url_prefix = url_prefix
if ":" in self._hostname and "[" not in self._hostname:
self._hostname = "[%s]" % self._hostname
self._rest_port = rest_port
Expand Down Expand Up @@ -162,11 +165,19 @@ def _determine_test_tool_platform(self, platform):
for rest_port in rest_ports:
for scheme in ["http", "https"]:
try:
url = "%s://%s:%s/api/v1/auth/session" % (
scheme,
self._hostname,
rest_port,
)
if self._url_prefix is not None:
url = "%s://%s:%s/%s/api/v1/auth/session" % (
scheme,
self._hostname,
rest_port,
self._url_prefix,
)
else:
url = "%s://%s:%s/api/v1/auth/session" % (
scheme,
self._hostname,
rest_port,
)
payload = json.dumps({"username": "", "password": ""})
headers = self._headers
headers["content-type"] = "application/json"
Expand Down Expand Up @@ -328,6 +339,8 @@ def _normalize_url(self, url):
if ":" in hostname and "[" not in hostname:
hostname = "[%s]" % hostname
connection = "%s://%s:%s" % (self._scheme, hostname, self._rest_port)
if self._url_prefix is not None:
connection += "/" + self._url_prefix
if url.startswith(self._scheme) == False:
url = "%s/%s" % (connection, url.strip("/"))
path_start = url.find("://") + 3
Expand Down Expand Up @@ -553,7 +566,13 @@ def _send_recv(self, method, url, payload=None):
self._async_operation.poll_headers = headers.copy()
self._async_operation.async_response = response
if self._async_operation.request is None:
return self._poll()
try:
return self._poll()
finally:
self._async_operation.request = None
self._async_operation.async_response = None
self._async_operation.poll_url = None
self._async_operation.poll_headers = None

while response.status_code == 409:
time.sleep(6)
Expand Down
17 changes: 3 additions & 14 deletions ixnetwork_restpy/multivalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def _custom_select(self):
self._set_properties(self._connection._execute(url, payload)[0], clear=True)
return self

def Overlay(self, index, value):
def Overlay(self, index, value, count=1):
"""Add an overlay at a specific device index in a pattern.
This is meant to overwrite an existing pattern with a few non-contiguous, random values.
Expand All @@ -760,20 +760,9 @@ def Overlay(self, index, value):
----
- index (int): 1 based device index
- value (str): the overlay value
- count (int): the number of indices to update with the overlay value starting from index attribute, default: 1
"""
if self._parent._mode[0] == "config":
# if self.parent._properties.get('OverlayIndex', None) is not None:
# self._overlay_index = self.parent._properties.get('OverlayIndex')
# multivalue_dict = dict()
# self._overlay_index += 1
# pattern = 'overlay[' + str(self._overlay_index) + ']'
# multivalue_dict['xpath'] = self._get_multivalue_xpath(self._href, pattern)
# multivalue_dict['count'] = '1'
# multivalue_dict['index'] = index
# multivalue_dict['indexStep'] = '1'
# multivalue_dict['value'] = value
# self._xpathObj._config.append(multivalue_dict)
# self.parent._properties['OverlayIndex'] = self._overlay_index
attribute_present = False
for multivaute_attr in self.parent._properties["multiValue"]:
if self._href in multivaute_attr:
Expand All @@ -793,7 +782,7 @@ def Overlay(self, index, value):
)
else:
href = "%s/overlay" % (self._href)
payload = {"count": 1, "index": index, "indexStep": 1, "value": value}
payload = {"count": count, "index": index, "indexStep": 1, "value": value}
self._connection._create(href, payload)

def ClearOverlays(self):
Expand Down
2 changes: 2 additions & 0 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Created by pytest automatically.
*
4 changes: 4 additions & 0 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/CACHEDIR.TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by pytest.
# For information about cache directory tags, see:
# https://bford.info/cachedir/spec.html
8 changes: 8 additions & 0 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pytest cache directory #

This directory contains data from the pytest's cache plugin,
which provides the `--lf` and `--ff` options, as well as the `cache` fixture.

**Do not** commit this to version control.

See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
16 changes: 16 additions & 0 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"tests/batch/batch_add/test_batch_add_classic.py::test_batch_add_with_dependent_attr[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_classic.py::test_batch_add_with_classic_config[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_traffic.py::test_batch_add_with_traffic[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_traffic.py::test_batch_add_with_multicast_traffic[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_traffic.py::test_batch_add_with_traffic_having_href_objects[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_with_load_config.py::test_batch_add_with_multiple_nodes[10.39.51.146:443:linux]": true,
"tests/batch/batch_add/test_batch_add_with_load_config.py::test_precedence_with_batch_add[10.39.51.146:443:linux]": true,
"tests/session_tests/test_qt_or_ixnrest.py::test_add_ixnrest_session[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_can_create_sessions[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_can_set_session_name[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_can_retrieve_sessions_by_id[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_should_return_no_session_when_wrong_session_id_provided[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_can_login_to_server_by_api_key[10.39.51.146:443:linux]": true,
"tests/session_tests/test_sessions.py::test_should_fail_on_wrong_auth_creds[10.39.51.146:443:linux]": true
}
Loading

0 comments on commit c8ecc77

Please sign in to comment.