def __init__(self, ip, username="", password="", port="8181"):
"""Initialize session using hardcoded text data, remember credentials."""
- self.rest_prefix = "http://" + ip + ":" + port + "/restconf/"
+ self.rest_prefix = "http://" + ip + ":" + port + "/rests/"
self.session = requests.Session()
if username:
self.session.auth = (username, password) # May work with non-string values
def __init__(self, ip, username="", password="", port="8181"):
"""Prepare session initialization data using hardcoded text, remember credentials."""
- self.rest_prefix = "http://" + ip + ":" + port + "/restconf/"
+ self.rest_prefix = "http://" + ip + ":" + port + "/rests/"
if username:
self.auth = (username, password) # May work with non-string values
else:
def __init__(self, ip, username, password, scope, port="8181"):
"""Initialize session using hardcoded text data."""
self.auth_url = "http://" + ip + ":" + port + "/oauth2/token"
- self.rest_prefix = "http://" + ip + ":" + port + "/restconf/"
+ self.rest_prefix = "http://" + ip + ":" + port + "/rests/"
self.auth_data = "grant_type=password&username=" + username
self.auth_data += "&password=" + password + "&scope=" + scope
self.auth_header = {"Content-Type": "application/x-www-form-urlencoded"}
def __init__(self, ip, username, password, scope, port="8181"):
"""Prepare session initialization data using hardcoded text."""
self.auth_url = "http://" + ip + ":" + port + "/oauth2/token"
- self.rest_prefix = "http://" + ip + ":" + port + "/restconf/"
+ self.rest_prefix = "http://" + ip + ":" + port + "/rests/"
self.auth_data = "grant_type=password&username=" + username
self.auth_data += "&password=" + password + "&scope=" + scope
self.auth_header = {"Content-Type": "application/x-www-form-urlencoded"}
Get_Pcep_Topology_Data
[Documentation] Use session object to download PCEP topology JSON. Check status and return Response object.
- ${resp} = AuthStandalone.Get_Using_Session ${rest_session} operational/network-topology:network-topology/topology/pcep-topology
+ ${resp} = AuthStandalone.Get_Using_Session ${rest_session} data/${TOPOLOGY_URL}\=pcep-topology?content\=nonconfig
# Not Logging content, as it may be huge.
BuiltIn.Should_Be_Equal ${resp.status_code} ${200}
[Return] ${resp}
${resp} = Get_Pcep_Topology_Data
# Used before topology had chance to grow huge. Be aware when creating a longevity suite from this.
BuiltIn.Log ${resp.text}
- BuiltIn.Should_Be_Equal ${resp.text} {"topology":[{"topology-id":"pcep-topology","topology-types":{"network-topology-pcep:topology-pcep":{}}}]}
+ BuiltIn.Should_Be_Equal ${resp.text} {"network-topology:topology":[{"topology-id":"pcep-topology","topology-types":{"network-topology-pcep:topology-pcep":{}}}]}
Pcep_On
[Documentation] Get topology count of current hop, assert the number of matches.
# The previous line relies on a fact that Execute_Command spawns separate shels, so running pcc-mock is not affected.
Set_Hop ${iteration}
SSHLibrary.Switch_Connection updater
- ${response} = SSHLibrary.Execute_Command bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' --delegate '${delegate}' --pccip '${pccip}' --tunnelnumber '${tunnel_no}' 2>&1"
+ ${response} = SSHLibrary.Execute_Command bash -c "cd ${UPDATERVM_WORKSPACE}; taskset 0x00000001 python3 updater.py --workers '${workers}' --odladdress '${UPDATER_ODLADDRESS}' --user '${RESTCONF_USER}' --password '${RESTCONF_PASSWORD}' --scope '${RESTCONF_SCOPE}' --pccaddress '${mock-ip}' --pccs '${pccs}' --lsps '${lsps}' --hop '${hop}' --timeout '${UPDATER_TIMEOUT}' --refresh '${UPDATER_REFRESH}' --reuse '${RESTCONF_REUSE}' --delegate '${delegate}' --pccip '${pccip}' --tunnelnumber '${tunnel_no}' 2>&1"
Check Updater response ${response} ${parallel}
Check Updater response
import threading
import time
-try:
- from collections import Counter
-except ImportError: # Python 2.6 does not have Counter in collections.
- from Counter import Counter # Assumes that user copies Counter.py around.
+from collections import Counter
import AuthStandalone
# The response perhaps points to some data stored in session,
# and the session implementation may explicitly call close() to free that data.
# To be sure, we clone information before further processing.
- status = int(response.status_code) # copy constructor
- content = str(response.content) # copy constructor
+ status = int(response.status_code)
+ content = response.content.decode()
resp_tuple = (status, content)
queue_responses.append(resp_tuple)
"""Return 'pass' or a reason what is wrong with response."""
prepend = ""
status = resp_tuple[0]
- if (status != 200) and (status != 204): # is it int?
- prepend = "status: " + str(status) + " "
+ if (status != 200) and (status != 204):
+ prepend = f"status: {status}"
content = resp_tuple[1]
if prepend or (content != expected and content != ""):
- return prepend + "content: " + str(content)
+ return f"{prepend} content: {content}"
return "pass"