diff --git a/CHANGELOG b/CHANGELOG index baa800e..59c1e60 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3e16da7 --- /dev/null +++ b/README.md @@ -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. diff --git a/README.rst b/README.rst deleted file mode 100644 index fe24b28..0000000 --- a/README.rst +++ /dev/null @@ -1,19 +0,0 @@ -Riverbed SteelScript for SteelCentral NetProfiler -================================================= - -This package provides device specific bindings for interacting -with Riverbed Cascade NetProfiler devices as part of the Riverbed -Steelscript for Python. - -For a complete guide to installation, see: - - `https://support.riverbed.com/apis/steelscript/index.html `_ - -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. diff --git a/examples/versions.py b/examples/versions.py new file mode 100644 index 0000000..b75df9b --- /dev/null +++ b/examples/versions.py @@ -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}") \ No newline at end of file diff --git a/setup.py b/setup.py index 713a596..5a49ec2 100644 --- a/setup.py +++ b/setup.py @@ -13,10 +13,10 @@ setup_args = { 'name': 'steelscript.netprofiler', - 'version': '24.2.1', + 'version': '24.10.1', 'author': 'Riverbed Technology', 'author_email': 'eng-github@riverbed.com', - 'url': 'http://pythonhosted.org/steelscript', + 'url': 'https://github.com/riverbed/steelscript', 'license': 'MIT', 'description': 'Python module for interacting with Riverbed ' 'NetProfiler with SteelScript', @@ -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', @@ -53,7 +52,7 @@ ), 'install_requires': ( - 'steelscript>=24.2.0', + 'steelscript>=24.10.0', ), 'extras_require': { diff --git a/steelscript/netprofiler/core/_api1.py b/steelscript/netprofiler/core/_api1.py index aeb6f01..af5725c 100644 --- a/steelscript/netprofiler/core/_api1.py +++ b/steelscript/netprofiler/core/_api1.py @@ -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) diff --git a/steelscript/netprofiler/core/netprofiler.py b/steelscript/netprofiler/core/netprofiler.py index 4b72950..a7578b6 100644 --- a/steelscript/netprofiler/core/netprofiler.py +++ b/steelscript/netprofiler/core/netprofiler.py @@ -27,8 +27,6 @@ __all__ = ['NetProfiler'] -API_VERSIONS = ["1.0"] - logger = logging.getLogger(__name__) @@ -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 @@ -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 @@ -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 @@ -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):