Skip to content

Commit

Permalink
"version 1.1.11"
Browse files Browse the repository at this point in the history
  • Loading branch information
vhowdhur committed Nov 17, 2023
1 parent c8ecc77 commit 476942f
Show file tree
Hide file tree
Showing 69 changed files with 1,317 additions and 373 deletions.
8 changes: 8 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Release Notes
### November 2023
* 1.1.11
* support ixnetwork version 9.30.2309.46 (9.30 Update-3)
* New Feature in Stat View Assistant Utility to `filter` Statistics
* please refer to sample script filter_stats_using_stat_view_assistant.py
* Bug fixes in Stat View Assistant Utility
* fixed fetching of the correct traffic item node after drill down
* fixed drill down statics for views apart from Traffic Item Statistics
### July 2023
* 1.1.10
* support ixnetwork version 9.30.2306.60 (9.30 Update-2)
Expand Down
55 changes: 52 additions & 3 deletions ixnetwork_restpy/assistants/statistics/statviewassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
from ixnetwork_restpy.assistants.statistics.row import Row
from ixnetwork_restpy.errors import *
from ixnetwork_restpy.assistants.batch.batchupdate import BatchUpdate
from ixnetwork_restpy.files import Files
import re
import os
Expand Down Expand Up @@ -42,12 +43,14 @@ def __init__(
LocalCsvStorage=None,
PrintFormat=OBJECT,
PrintColumns=[],
FilterType=None,
):
"""
Args
----
- IxNetwork (obj (ixnetwork_restpy.testplatform.sessions.ixnetwork.Ixnetwork)): An Ixnetwork object
- ViewName (str): The name of a statistics view, supports regex
- ViewName (str): The name of a statistics view, supports regex.
If used for filtering the parameter needs to be a string.
- Timeout (int): The timeout in seconds to wait for the ViewName to be available and/or ready
- LocalCsvStorage (str): The local path where downloaded csv statistic files will be stored.
The path must exist and will not be created.
Expand All @@ -56,10 +59,16 @@ def __init__(
If PrintFormat is TABLE each row will be output as a single line
- 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
- FilterType (str) The type of filter the needs to be imposed on the view
"""
self._snapshot = None
self._IxNetwork = IxNetwork
self._ViewName = ViewName
self._filter_view = None
if FilterType is not None:
# redirect to custom filter stats creation
self._create_view_for_filter(FilterType)
return
self._root_directory = self._IxNetwork._connection._read(
"%s/files" % self._IxNetwork.href
)["absolute"]
Expand Down Expand Up @@ -187,6 +196,10 @@ def ColumnHeaders(self):
"""Returns a list of all the column headers in the view."""
return self._View.Page.ColumnCaptions

@property
def FilterView(self):
return self._filter_view

def AddRowFilter(self, ColumnName, Comparator, FilterValue):
"""Add a filter that reduces the Row resultset
Expand Down Expand Up @@ -288,6 +301,7 @@ def DrillDownOptions(self, TargetIndex=0):
"""
drill_down = self._View.DrillDown.find()
drill_down.TargetRowIndex = TargetIndex
drill_down.refresh()
return drill_down.AvailableDrillDownOptions

def TargetRowFilters(self, TargetIndex=0):
Expand All @@ -301,15 +315,19 @@ def TargetRowFilters(self, TargetIndex=0):
"""
drill_down = self._View.DrillDown.find()
drill_down.TargetRowIndex = TargetIndex
drill_down.refresh()
return drill_down.AvailableTargetRowFilters.find()

def Drilldown(self, TargetRowIndex, DrillDownOption, TargetRowFilter):
def Drilldown(
self, TargetRowIndex, DrillDownOption, TargetRowFilter, DrillDownView=None
):
"""Drilldown on an existing view to get a new StatViewAssistant
Args:
TargetRowIndex (int): the 0 based index of the row that you are interested in drilling down into
DrillDownOption (str): drill down options are dynamic and are based on tracking options selected during traffic item creation
TargetRowFilter (str): drill down filters are dynamic and are based on tracking options selected during traffic item creation
DrillDownView (str): The resultant drill down for which you want the stat view assistant info. Default is None.
Returns:
obj(ixnetwork_restpy.assistants.statistics.statviewassistant.StatViewAssistant)
Expand All @@ -319,7 +337,12 @@ def Drilldown(self, TargetRowIndex, DrillDownOption, TargetRowFilter):
drill_down.TargetDrillDownOption = DrillDownOption
drill_down.TargetRowFilter = TargetRowFilter
drill_down.DoDrillDown()
return StatViewAssistant(self._IxNetwork, "User Defined Statistics")
self._View = None
self._is_view_ready
if self._ViewName == "Traffic Item Statistics":
return StatViewAssistant(self._IxNetwork, "User Defined Statistics")
elif DrillDownView is not None:
return StatViewAssistant(self._IxNetwork, DrillDownView)

def __str__(self):
"""Return a string with all the rows in the current view"""
Expand Down Expand Up @@ -348,3 +371,29 @@ def __str__(self):
for row in self.Rows:
statistics += row.__str__()
return statistics.rstrip()

def _create_view_for_filter(self, filter_type):
# create custom view
self._filter_view = self._IxNetwork.Statistics.View.add(
Caption=self._ViewName, Type=filter_type, Visible=True
)
self._IxNetwork.debug(
"custom view for filter created successfully: " + self._filter_view.href
)

def GetFilteredStats(self):
"""
Get filtered statistics
Returns:
obj(ixnetwork_restpy.assistants.statistics.statviewassistant.StatViewAssistant)
"""
if self._filter_view is None:
raise Exception(
"No filter view, This method is only valid if FilterType was provided"
)
self._IxNetwork.debug("Enabling all the statistics for the filter view")
with BatchUpdate(self._IxNetwork):
for statistic in self._filter_view.Statistic.find():
statistic.Enabled = True
self._filter_view.Enabled = True
return StatViewAssistant(self._IxNetwork, self._ViewName)
2 changes: 0 additions & 2 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/CACHEDIR.TAG

This file was deleted.

8 changes: 0 additions & 8 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions ixnetwork_restpy/pytest_tests/.pytest_cache/v/cache/lastfailed

This file was deleted.

Loading

0 comments on commit 476942f

Please sign in to comment.