Skip to content

Commit

Permalink
24.10.1
Browse files Browse the repository at this point in the history
* Update common api default version 1.0 to 1.1
* Patch warning /api/profiler/1.0/reporting/columns.json returned status 400 (Bad Request), WARNING Exception raised fetching columns for triplet: msq, hos, slm #11
* Fix supported_versions (based on Cookie Auth + Version steelscript#48 )
* New simple example "versions" 
 (#12)
  • Loading branch information
gwenblum authored Dec 20, 2024
1 parent 50e61a9 commit 31c636a
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 39 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
CHANGELOG
=========
[24.10.1]
* Remove submodule
* Enable oauth code authentication support

[24.2.1]
* Python 3.12
* New versioning scheme 24.2.1
* Change versioning gitpy for manual 24.2.1
* Remove deprecated namespace_packages parameter
* Fix bug else syntax

[1.4]
* Add appfwk example utilization report
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Riverbed SteelScript for NetProfiler

This package as part of [SteelScript](https://github.com/riverbed/steelscript) provides specific bindings for interacting with [Riverbed NetProfiler](https://www.riverbed.com/products/netprofiler)

## License

Copyright (c) 2019-2024 Riverbed Technology, Inc.

SteelScript-NetProfiler is licensed under the terms and conditions of the MIT
License accompanying the software ("License"). SteelScript-NetProfiler is
distributed "AS IS" as set forth in the License.
19 changes: 0 additions & 19 deletions README.rst

This file was deleted.

48 changes: 48 additions & 0 deletions examples/versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
'''
' Riverbed Community SteelScript
'
' .py
' Encoding: UTF8
' End of Line Sequence: LF
'
' Copyright (c) 2024 Riverbed Technology, Inc.
'
' This software is licensed under the terms and conditions of the MIT License
' accompanying the software ("License"). This software is distributed "AS IS"
' as set forth in the License.
Usage example in Bash:
export RIVERBED_NETPROFILER_HOST=n31-prf
export RIVERBED_NETPROFILER_USERNAME=yourusername
export RIVERBED_NETPROFILER_PASSWORD=******
python versions.py
'''

## Step 1. Import steelscript libraries in Python

from steelscript.netprofiler.core import NetProfiler
from steelscript.common.service import UserAuth

import os

## Step 2. Configure and connect the service object for NetProfiler

host = os.getenv('RIVERBED_NETPROFILER_HOST')
username = os.getenv('RIVERBED_NETPROFILER_USERNAME')
password = os.getenv('RIVERBED_NETPROFILER_PASSWORD')

auth = UserAuth(username, password)
netprofiler_service = NetProfiler(host, auth=auth)

## Step 3. Check versions info

print(f"NetProfiler version: {netprofiler_service.version}")

print(f"Supported API versions: {netprofiler_service.supported_versions}")

print(f"Services API url: {netprofiler_service._services_api}")
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

setup_args = {
'name': 'steelscript.netprofiler',
'version': '24.2.1',
'version': '24.10.1',
'author': 'Riverbed Technology',
'author_email': '[email protected]',
'url': 'http://pythonhosted.org/steelscript',
'url': 'https://github.com/riverbed/steelscript',
'license': 'MIT',
'description': 'Python module for interacting with Riverbed '
'NetProfiler with SteelScript',
Expand All @@ -27,9 +27,8 @@
SteelScript is a collection of libraries and scripts in Python and JavaScript
for interacting with Riverbed Technology devices.
For a complete guide to installation, see:
More about SteelScript: https://github.com/riverbed/steelscript
http://pythonhosted.org/steelscript/
''',

'platforms': 'Linux, Mac OS, Windows',
Expand All @@ -53,7 +52,7 @@
),

'install_requires': (
'steelscript>=24.2.0',
'steelscript>=24.10.0',
),

'extras_require': {
Expand Down
1 change: 1 addition & 0 deletions steelscript/netprofiler/core/_api1.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def get_widget(self, template_id, widget_id):

class Handler(object):
def __init__(self, profiler):
# TODO: if possible use more recent API versions
self.report = Report('/api/profiler/1.0/reporting', profiler)
self.devices = Devices('/api/profiler/1.0/devices', profiler)
self.common = Common('/api/common/1.0', profiler)
Expand Down
28 changes: 13 additions & 15 deletions steelscript/netprofiler/core/netprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

__all__ = ['NetProfiler']

API_VERSIONS = ["1.0"]

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -65,17 +63,16 @@ def __init__(self, host, port=None, auth=None):
"""
super(NetProfiler, self).__init__("profiler", host, port,
auth=auth,
versions=[APIVersion("1.0")],
enable_auth_detection = False,
supports_auth_basic=True,
supports_auth_oauth=True,
override_services_api='/api/common/1.0/services')
override_services_api='/api/common/1.1/services')

self.api = _api1.Handler(self)

self.groupbys = DictObject.create_from_dict(_constants.groupbys)
self.realms = _constants.realms
self.centricities = _constants.centricities
self.groupbys = DictObject.create_from_dict(_constants.groupbys)

self._info = None

Expand All @@ -93,7 +90,7 @@ def __init__(self, host, port=None, auth=None):
self.columns = ColumnContainer(self._unique_columns())
self.colnames = set(c.key for c in self.columns)

self.areas = AreaContainer(self._areas_dict.items())
self.areas = AreaContainer(self._areas_dict.items())

def _load_file_caches(self):
"""Load and unroll locally cached files
Expand Down Expand Up @@ -163,17 +160,16 @@ def _verify_cache(self, refetch=False):
'%s, %s, %s' % (realm,
centricity,
groupby))

# TODO: fix properly and remove the patch
# Patch to avoid /api/profiler/1.0/reporting/columns.json returned status 400 (Bad Request)
if realm =="msq" and centricity == "hos" and groupby == "slm":
continue

try:
api_call = self.api.report.columns(realm,
centricity,
groupby)
api_call = self.api.report.columns(realm,centricity,groupby)
except RvbdHTTPException as e:
logger.warning('Exception raised fetching columns'
'for triplet: {0}, {1}, {2} with '
'message {3}'.format(realm,
centricity,
groupby,
e.message))
logger.warning(f"Exception raised fetching columns for triplet( realm:{realm}, centricity:{centricity}, groupby:{groupby} with message {e.message}")
have_exception = True
continue

Expand Down Expand Up @@ -264,6 +260,8 @@ def version(self):
def supports_version(self, version):
if isinstance(version, (str,)):
version = APIVersion(version)
if self.supported_versions is None:
return True
return version in self.supported_versions

def get_columns(self, columns, groupby=None, strict=True):
Expand Down

0 comments on commit 31c636a

Please sign in to comment.