Skip to content

Commit

Permalink
"version 1.0.55"
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Jul 22, 2020
1 parent 5a97fdd commit 30ccd1b
Show file tree
Hide file tree
Showing 1,430 changed files with 16,430 additions and 16,413 deletions.
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release Notes

### Jul 2020
* 1.0.55
* PortMapAssistant.Connect method bug fix
* StatViewAssistant processes snapshots using in memory IO
* removal of duplicate attempts in test platform determination
* 1.0.54
* inclusion of uhd_restpy package in distribution
* PortMapAssistant supports user defined timeouts on the .Connect method
Expand Down
8 changes: 7 additions & 1 deletion ixnetwork_restpy/assistants/ports/portmapassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
from ixnetwork_restpy.assistants.statistics.statviewassistant import StatViewAssistant


try:
basestring
except NameError:
basestring = str


class PortMapAssistant(object):
def __init__(self, IxNetwork):
"""Create mappings between test port locations and virtual ports.
Expand Down Expand Up @@ -195,7 +201,7 @@ def _find_xpath(self, nested_dict, card_port):
xpath = self._find_xpath(v, card_port)
if xpath is not None:
return xpath
elif isinstance(v, str) and card_port in v:
elif isinstance(v, basestring) and card_port in v:
return nested_dict['xpath']
return None

Expand Down
67 changes: 35 additions & 32 deletions ixnetwork_restpy/assistants/statistics/statviewassistant.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
""" Assistant class to simplify access to statistics views
"""

from ixnetwork_restpy.assistants.statistics.row import Row
from ixnetwork_restpy.errors import *
from ixnetwork_restpy.files import Files
import re
import os
import io
import time


try:
basestring
except NameError:
Expand Down Expand Up @@ -49,6 +50,7 @@ def __init__(self, IxNetwork, ViewName, Timeout=180, LocalCsvStorage=None,
- PrintColumns (list(str)): A list of statistic column names that will be printed out
If the list is None all columns will be printed out
"""
self._snapshot = None
self._IxNetwork = IxNetwork
self._ViewName = ViewName
self._root_directory = self._IxNetwork._connection._read('%s/files' % self._IxNetwork.href)['absolute']
Expand All @@ -72,13 +74,12 @@ def _take_csv_snapshot(self):
CsvName = snapshot_name,
Views = self._View)
csv_snapshot.TakeCsvSnapshot()
local_filename = self._IxNetwork._connection._get_file(self._IxNetwork.href,
'%s.csv' % snapshot_name, local_directory=self._LocalCsvStorage)
self._snapshot = io.BytesIO(self._IxNetwork._connection._get_file(self._IxNetwork.href,
'%s.csv' % snapshot_name, return_content=True))
self._IxNetwork._connection._delete_file(self._IxNetwork.href,
'%s.csv' % snapshot_name)
self._IxNetwork._connection._delete_file(self._IxNetwork.href,
'%s.csv.columns' % snapshot_name)
return local_filename

@property
def _is_view_ready(self):
Expand Down Expand Up @@ -107,37 +108,39 @@ def Rows(self):
obj (ixnetwork_restpy.assistants.statistics.row.Row): An iterable class encapsulating row data
"""
self._is_view_ready
local_filename = self._take_csv_snapshot()
self._take_csv_snapshot()
rows = []
column_headers = []
with open(local_filename, 'r') as fid:
column_headers = fid.readline()[:-1].split(',')
for row in fid:
row = row[:-1]
row = ''.join(x if i % 2 == 0 else x.replace(',', ' ')
for i, x in enumerate(row.split('"')))
row = row.split(',')
match = True
for column_index in range(len(row)):
if column_index in self._filters.keys():
for column_filter in self._filters[column_index]:
comparator = column_filter['comparator']
filter_value = column_filter['filterValue']
if comparator == StatViewAssistant.REGEX:
if filter_value.search(row[column_index]) is None:
column_headers = self._snapshot.readline()
if isinstance(column_headers, bytes) is True:
column_headers = column_headers.decode('ascii')
column_headers = column_headers.rstrip().split(',')
for row in self._snapshot:
if isinstance(row, bytes) is True:
row = row.decode('ascii')
row = row.rstrip()
row = ''.join(x if i % 2 == 0 else x.replace(',', ' ')
for i, x in enumerate(row.split('"')))
row = row.split(',')
match = True
for column_index in range(len(row)):
if column_index in self._filters.keys():
for column_filter in self._filters[column_index]:
comparator = column_filter['comparator']
filter_value = column_filter['filterValue']
if comparator == StatViewAssistant.REGEX:
if filter_value.search(row[column_index]) is None:
match = False
break
else:
try:
expression = '"%s" %s "%s"' % (row[column_index], comparator, filter_value)
if eval(expression) is False:
match = False
break
else:
try:
expression = '"%s" %s "%s"' % (row[column_index], comparator, filter_value)
if eval(expression) is False:
match = False
break
except Exception as e:
self._IxNetwork.debug('%s Rows eval of %s failed: %s' % (__file__, expression, e))
if match is True:
rows.append(row)
os.remove(local_filename)
except Exception as e:
self._IxNetwork.debug('%s Rows eval of %s failed: %s' % (__file__, expression, e))
if match is True:
rows.append(row)
return Row(self._View.Caption, column_headers, rows)

@property
Expand Down
6 changes: 5 additions & 1 deletion ixnetwork_restpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def _determine_test_tool_platform(self, platform):
self._platform = None
rest_ports = [443, 11009]
if self._rest_port is not None:
if self._rest_port in rest_ports:
rest_ports.remove(self._rest_port)
rest_ports.insert(0, self._rest_port)
for rest_port in rest_ports:
for scheme in ['http', 'https']:
Expand Down Expand Up @@ -256,14 +258,16 @@ def _normalize_url(self, url):
url = '%s%s' % (url[0:path_start], url[path_start:].replace('//', '/'))
return (connection, url)

def _get_file(self, url, remote_filename, remote_directory=None, local_filename=None, local_directory=None):
def _get_file(self, url, remote_filename, remote_directory=None, local_filename=None, local_directory=None, return_content=False):
headers = self._headers
url = '%s/files?filename=%s' % (url, remote_filename)
connection, url = self._normalize_url(url)
if remote_directory is not None:
url = '%s&absolute=%s' % (url, remote_directory)
response = self._session.request('GET', url, headers=headers, verify=self._verify_cert)
if response.status_code == 200:
if return_content is True:
return response.content
if local_filename is None:
local_filename = remote_filename
if local_directory is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class AvailableHardware(Base):
__slots__ = ()
_SDM_NAME = 'availableHardware'
_SDM_ATT_MAP = {
'IsOffChassis': 'isOffChassis',
'IsLocked': 'isLocked',
'IsOffChassis': 'isOffChassis',
'OffChassisHwM': 'offChassisHwM',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class Aggregation(Base):
__slots__ = ()
_SDM_NAME = 'aggregation'
_SDM_ATT_MAP = {
'ActivePort': 'activePort',
'ActivePorts': 'activePorts',
'AvailableModes': 'availableModes',
'Mode': 'mode',
'ActivePort': 'activePort',
'ResourcePorts': 'resourcePorts',
'ActivePorts': 'activePorts',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class Card(Base):
__slots__ = ()
_SDM_NAME = 'card'
_SDM_ATT_MAP = {
'AggregationMode': 'aggregationMode',
'AggregationSupported': 'aggregationSupported',
'AvailableModes': 'availableModes',
'CardId': 'cardId',
'AggregationMode': 'aggregationMode',
'Description': 'description',
'AvailableModes': 'availableModes',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class Port(Base):
__slots__ = ()
_SDM_NAME = 'port'
_SDM_ATT_MAP = {
'PortId': 'portId',
'Description': 'description',
'IsAvailable': 'isAvailable',
'IsBusy': 'isBusy',
'IsLinkUp': 'isLinkUp',
'IsUsable': 'isUsable',
'Owner': 'owner',
'IsBusy': 'isBusy',
'IsAvailable': 'isAvailable',
'PortId': 'portId',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class Parameter(Base):
__slots__ = ()
_SDM_NAME = 'parameter'
_SDM_ATT_MAP = {
'AvailableChoices': 'availableChoices',
'CurrentValue': 'currentValue',
'Name': 'name',
'IsReadOnly': 'isReadOnly',
'CustomDefaultValue': 'customDefaultValue',
'DefaultValue': 'defaultValue',
'IsReadOnly': 'isReadOnly',
'MaxValue': 'maxValue',
'MinValue': 'minValue',
'CustomDefaultValue': 'customDefaultValue',
'AvailableChoices': 'availableChoices',
'Name': 'name',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ class Chassis(Base):
__slots__ = ()
_SDM_NAME = 'chassis'
_SDM_ATT_MAP = {
'IsMaster': 'isMaster',
'ErrorState': 'errorState',
'ProtocolBuildNumber': 'protocolBuildNumber',
'ChassisOSType': 'chassisOSType',
'ErrorDescription': 'errorDescription',
'Ip': 'ip',
'Hostname': 'hostname',
'StateV2': 'stateV2',
'SequenceId': 'sequenceId',
'ChassisVersion': 'chassisVersion',
'CableLength': 'cableLength',
'State': 'state',
'IxosBuildNumber': 'ixosBuildNumber',
'ChainTopology': 'chainTopology',
'ConnectRetries': 'connectRetries',
'ChassisOSType': 'chassisOSType',
'ChassisType': 'chassisType',
'IxnBuildNumber': 'ixnBuildNumber',
'MasterChassis': 'masterChassis',
'ChassisVersion': 'chassisVersion',
'ConnectRetries': 'connectRetries',
'ErrorDescription': 'errorDescription',
'ErrorState': 'errorState',
'Hostname': 'hostname',
'Ip': 'ip',
'IsLicensesRetrieved': 'isLicensesRetrieved',
'IsMaster': 'isMaster',
'IxnBuildNumber': 'ixnBuildNumber',
'IxosBuildNumber': 'ixosBuildNumber',
'LicenseErrors': 'licenseErrors',
'MasterChassis': 'masterChassis',
'ProtocolBuildNumber': 'protocolBuildNumber',
'SequenceId': 'sequenceId',
'State': 'state',
'StateV2': 'stateV2',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class DiscoveredAppliance(Base):
__slots__ = ()
_SDM_NAME = 'discoveredAppliance'
_SDM_ATT_MAP = {
'ApplianceType': 'applianceType',
'ApplianceName': 'applianceName',
'ManagementIp': 'managementIp',
'ApplianceType': 'applianceType',
'InterfacesNumber': 'interfacesNumber',
'ManagementIp': 'managementIp',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class DiscoveredInterface(Base):
__slots__ = ()
_SDM_NAME = 'discoveredInterface'
_SDM_ATT_MAP = {
'State': 'state',
'InterfaceName': 'interfaceName',
'State': 'state',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class Hypervisor(Base):
__slots__ = ()
_SDM_NAME = 'hypervisor'
_SDM_ATT_MAP = {
'Type': 'type',
'Password': 'password',
'Enabled': 'enabled',
'User': 'user',
'Password': 'password',
'ServerIp': 'serverIp',
'Type': 'type',
'User': 'user',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class IxVmCard(Base):
__slots__ = ()
_SDM_NAME = 'ixVmCard'
_SDM_ATT_MAP = {
'CardId': 'cardId',
'CardName': 'cardName',
'CardState': 'cardState',
'KeepAliveTimeout': 'keepAliveTimeout',
'CardName': 'cardName',
'ManagementIp': 'managementIp',
'CardId': 'cardId',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class IxVmPort(Base):
__slots__ = ()
_SDM_NAME = 'ixVmPort'
_SDM_ATT_MAP = {
'Interface': 'interface',
'IpAddress': 'ipAddress',
'MacAddress': 'macAddress',
'PromiscMode': 'promiscMode',
'PortId': 'portId',
'PortState': 'portState',
'Mtu': 'mtu',
'Owner': 'owner',
'PortId': 'portId',
'PortName': 'portName',
'Interface': 'interface',
'IpAddress': 'ipAddress',
'PortState': 'portState',
'PromiscMode': 'promiscMode',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class VirtualChassis(Base):
_SDM_NAME = 'virtualChassis'
_SDM_ATT_MAP = {
'EnableLicenseCheck': 'enableLicenseCheck',
'StartTxDelay': 'startTxDelay',
'NtpServer': 'ntpServer',
'Hostname': 'hostname',
'LicenseServer': 'licenseServer',
'NtpServer': 'ntpServer',
'StartTxDelay': 'startTxDelay',
}

def __init__(self, parent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class AppErrors(Base):
__slots__ = ()
_SDM_NAME = 'appErrors'
_SDM_ATT_MAP = {
'LastModified': 'lastModified',
'ErrorCount': 'errorCount',
'LastModified': 'lastModified',
'WarningCount': 'warningCount',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class Error(Base):
__slots__ = ()
_SDM_NAME = 'error'
_SDM_ATT_MAP = {
'InstanceCount': 'instanceCount',
'Description': 'description',
'ErrorCode': 'errorCode',
'ErrorLevel': 'errorLevel',
'InstanceCount': 'instanceCount',
'LastModified': 'lastModified',
'ErrorCode': 'errorCode',
'Name': 'name',
'Provider': 'provider',
'SourceColumns': 'sourceColumns',
'SourceColumnsDisplayName': 'sourceColumnsDisplayName',
'Name': 'name',
}

def __init__(self, parent):
Expand Down
Loading

0 comments on commit 30ccd1b

Please sign in to comment.