python-observabilityclient 1.3.0__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/.pre-commit-config.yaml +16 -5
  2. python_observabilityclient-1.5.0/.stestr.conf +3 -0
  3. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/.zuul.yaml +5 -2
  4. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/AUTHORS +3 -0
  5. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/ChangeLog +28 -0
  6. {python_observabilityclient-1.3.0/python_observabilityclient.egg-info → python_observabilityclient-1.5.0}/PKG-INFO +6 -3
  7. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/README.rst +2 -0
  8. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/prometheus_client.py +80 -9
  9. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_prometheus_client.py +86 -0
  10. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_utils.py +12 -9
  11. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/utils/metric_utils.py +26 -32
  12. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/pyproject.toml +50 -7
  13. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0/python_observabilityclient.egg-info}/PKG-INFO +6 -3
  14. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/SOURCES.txt +5 -0
  15. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/entry_points.txt +0 -3
  16. python_observabilityclient-1.5.0/python_observabilityclient.egg-info/pbr.json +1 -0
  17. python_observabilityclient-1.5.0/releasenotes/notes/keep-session-transport-options-6ad0880b46c8b1e1.yaml +8 -0
  18. python_observabilityclient-1.5.0/releasenotes/notes/prometheus-tls-versions.yaml +8 -0
  19. python_observabilityclient-1.5.0/releasenotes/source/2026.1.rst +6 -0
  20. python_observabilityclient-1.5.0/releasenotes/source/2026.2.rst +6 -0
  21. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/index.rst +2 -0
  22. python_observabilityclient-1.5.0/requirements.txt +8 -0
  23. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/tox.ini +6 -13
  24. python_observabilityclient-1.3.0/python_observabilityclient.egg-info/pbr.json +0 -1
  25. python_observabilityclient-1.3.0/requirements.txt +0 -4
  26. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/.coveragerc +0 -0
  27. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/CONTRIBUTING.rst +0 -0
  28. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/LICENSE +0 -0
  29. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/requirements.txt +0 -0
  30. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/api.rst +0 -0
  31. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/conf.py +0 -0
  32. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/contributing.rst +0 -0
  33. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/index.rst +0 -0
  34. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/installation.rst +0 -0
  35. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/doc/source/shell.rst +0 -0
  36. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/__init__.py +0 -0
  37. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/client.py +0 -0
  38. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/i18n.py +0 -0
  39. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/plugin.py +0 -0
  40. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/rbac.py +0 -0
  41. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/__init__.py +0 -0
  42. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/base.py +0 -0
  43. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/test_cli.py +0 -0
  44. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/functional/test_python_api.py +0 -0
  45. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/__init__.py +0 -0
  46. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_cli.py +0 -0
  47. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_python_api.py +0 -0
  48. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/tests/unit/test_rbac.py +0 -0
  49. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/utils/__init__.py +0 -0
  50. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/__init__.py +0 -0
  51. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/base.py +0 -0
  52. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/cli.py +0 -0
  53. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/client.py +0 -0
  54. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/observabilityclient/v1/python_api.py +0 -0
  55. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/dependency_links.txt +0 -0
  56. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/not-zip-safe +0 -0
  57. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/requires.txt +0 -0
  58. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/python_observabilityclient.egg-info/top_level.txt +0 -0
  59. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/add-root-path-192ac0e6ea99b84f.yaml +0 -0
  60. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/allow-for-providing-metric-names-list-for-rbac-e46a4fd0df3fad73.yaml +0 -0
  61. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/allow-for-specifying-rbac-label-name-f99084757cde5f19.yaml +0 -0
  62. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml +0 -0
  63. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml +0 -0
  64. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml +0 -0
  65. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml +0 -0
  66. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/remove-py38-acd461c4350f0dca.yaml +0 -0
  67. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/remove-py39-a3f911847e0075b6.yaml +0 -0
  68. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f6473.yaml +0 -0
  69. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/2025.1.rst +0 -0
  70. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/2025.2.rst +0 -0
  71. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/_static/.placeholder +0 -0
  72. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/conf.py +0 -0
  73. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/releasenotes/source/unreleased.rst +0 -0
  74. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/setup.cfg +0 -0
  75. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/setup.py +0 -0
  76. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/test-requirements.txt +0 -0
  77. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/tools/fix_ca_bundle.sh +0 -0
  78. {python_observabilityclient-1.3.0 → python_observabilityclient-1.5.0}/tools/install_deps.sh +0 -0
@@ -18,19 +18,30 @@ repos:
18
18
  - id: debug-statements
19
19
  - id: check-yaml
20
20
  files: .*\.(yaml|yml)$
21
+ - repo: https://github.com/hhatto/autopep8
22
+ rev: v2.3.2
23
+ hooks:
24
+ - id: autopep8
25
+ files: '^.*\.py$'
21
26
  - repo: https://opendev.org/openstack/hacking
22
- rev: 7.0.0
27
+ rev: 8.0.0
23
28
  hooks:
24
29
  - id: hacking
25
30
  additional_dependencies: []
26
- - repo: https://github.com/asottile/pyupgrade
27
- rev: v3.20.0
31
+ - repo: https://github.com/PyCQA/doc8
32
+ rev: v2.0.0
28
33
  hooks:
29
- - id: pyupgrade
30
- args: [--py310-plus]
34
+ - id: doc8
31
35
  - repo: https://github.com/openstack/bashate
32
36
  rev: 2.1.1
33
37
  hooks:
34
38
  - id: bashate
35
39
  args: ['-v', '-iE006']
36
40
  exclude: '.tox/.*'
41
+ - repo: https://github.com/astral-sh/ruff-pre-commit
42
+ rev: v0.15.7
43
+ hooks:
44
+ - id: ruff-check
45
+ args: ['--fix', '--unsafe-fixes', '--show-fixes']
46
+ # TODO(tkajinam): Enable this later
47
+ #- id: ruff-format
@@ -0,0 +1,3 @@
1
+ [DEFAULT]
2
+ test_path=${OS_TEST_PATH:-./observabilityclient/tests/unit}
3
+ top_dir=./
@@ -7,9 +7,10 @@
7
7
  Devstack-based functional tests for observabilityclient.
8
8
  required-projects:
9
9
  - openstack/python-observabilityclient
10
+ - openstack/aetos
10
11
  - openstack/ceilometer
11
- - openstack-k8s-operators/sg-core
12
12
  - openstack/devstack-plugin-prometheus
13
+ - openstack-k8s-operators/sg-core
13
14
  timeout: 4200
14
15
  vars:
15
16
  devstack_localrc:
@@ -17,9 +18,10 @@
17
18
  CEILOMETER_BACKEND: sg-core
18
19
  PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:3000,localhost:9090"
19
20
  devstack_plugins:
20
- sg-core: https://github.com/openstack-k8s-operators/sg-core
21
+ aetos: https://opendev.org/openstack/aetos
21
22
  ceilometer: https://opendev.org/openstack/ceilometer
22
23
  devstack-plugin-prometheus: https://opendev.org/openstack/devstack-plugin-prometheus
24
+ sg-core: https://github.com/openstack-k8s-operators/sg-core
23
25
  devstack_services:
24
26
  node_exporter: false
25
27
  zuul_copy_output:
@@ -30,6 +32,7 @@
30
32
  queue: telemetry
31
33
  templates:
32
34
  - openstack-python3-jobs
35
+ - openstack-python3-next-jobs
33
36
  - publish-openstack-docs-pti
34
37
  - check-requirements
35
38
  - release-notes-jobs-python3
@@ -1,6 +1,7 @@
1
1
  Alfredo Moralejo <amoralej@redhat.com>
2
2
  Chris Sibbitt <csibbitt@redhat.com>
3
3
  Cyril Roelandt <cyril@redhat.com>
4
+ Daniel Pawlik <dpawlik@redhat.com>
4
5
  Emma Foley <efoley@redhat.com>
5
6
  Erno Kuvaja <jokke@usr.fi>
6
7
  Ghanshyam Mann <gmann@ghanshyammann.com>
@@ -12,5 +13,7 @@ Marihan Girgis mgirgisf@redhat.com
12
13
  Martin Magr <mmagr@redhat.com>
13
14
  Martin Mágr <mmagr@redhat.com>
14
15
  OpenStack Release Bot <infra-root@openstack.org>
16
+ Pavlo Shchelokovskyy <shchelokovskyy@gmail.com>
15
17
  Takashi Kajinami <kajinamit@oss.nttdata.com>
18
+ Thomas Goirand <zigo@debian.org>
16
19
  Victoria Martinez de la Cruz <victoria@redhat.com>
@@ -1,6 +1,34 @@
1
1
  CHANGES
2
2
  =======
3
3
 
4
+ 1.5.0
5
+ -----
6
+
7
+ * Declare Python 3.15 support
8
+ * Add set\_max\_tls\_version to PrometheusAPIClient
9
+ * Add autopep8, doc8 and ruff
10
+ * Refactor get\_prom\_client\_from\_file\_or\_env
11
+ * Refactor url composition
12
+ * Add set\_min\_tls\_version to PrometheusAPIClient
13
+ * Add note about lower bounds of requirements
14
+ * Update master for stable/2026.2
15
+
16
+ 1.4.0
17
+ -----
18
+
19
+ * Keep session transport options
20
+ * Remove Python 3.10 support
21
+ * Add openstack-python3-next-jobs
22
+ * Use pbr
23
+ * tox: Use new constraints option
24
+ * Enable Aetos
25
+ * Do not provide /usr/bin/aodh
26
+ * Update master for stable/2026.1
27
+ * Update gitignore to ignore md files for AI agents
28
+ * Apply upper constraints in release note build
29
+ * Add .stestr.conf to manage default OS\_TEST\_PATH
30
+ * tox: Drop redundant injection of VIRTUAL\_ENV variable
31
+
4
32
  1.3.0
5
33
  -----
6
34
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-observabilityclient
3
- Version: 1.3.0
3
+ Version: 1.5.0
4
4
  Summary: OpenStack Observability Client
5
5
  Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
6
  License: Apache-2.0
@@ -13,12 +13,13 @@ Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
22
23
  Description-Content-Type: text/markdown; charset=UTF-8
23
24
  License-File: LICENSE
24
25
  Requires-Dist: osc-lib>=1.0.1
@@ -47,6 +48,7 @@ Install your OpenStack environment and patch your ``openstack`` client
47
48
  application using python.
48
49
 
49
50
  .. code:: console
51
+
50
52
  git clone https://opendev.org/openstack/python-observabilityclient.git
51
53
  cd python-observabilityclient
52
54
  sudo pip install .
@@ -60,6 +62,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
60
62
  To use the python api do the following:
61
63
 
62
64
  .. code:: python
65
+
63
66
  from observabilityclient import client
64
67
 
65
68
  c = client.Client(
@@ -17,6 +17,7 @@ Install your OpenStack environment and patch your ``openstack`` client
17
17
  application using python.
18
18
 
19
19
  .. code:: console
20
+
20
21
  git clone https://opendev.org/openstack/python-observabilityclient.git
21
22
  cd python-observabilityclient
22
23
  sudo pip install .
@@ -30,6 +31,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
30
31
  To use the python api do the following:
31
32
 
32
33
  .. code:: python
34
+
33
35
  from observabilityclient import client
34
36
 
35
37
  c = client.Client(
@@ -13,13 +13,51 @@
13
13
  # under the License.
14
14
 
15
15
  import logging
16
+ import ssl
17
+ import urllib.parse
16
18
 
17
19
  import requests
20
+ from requests.adapters import HTTPAdapter
21
+ from urllib3.util.ssl_ import create_urllib3_context
18
22
 
19
23
 
20
24
  LOG = logging.getLogger(__name__)
21
25
 
22
26
 
27
+ _TLS_VERSIONS = {
28
+ '1.2': ssl.TLSVersion.TLSv1_2,
29
+ '1.3': ssl.TLSVersion.TLSv1_3,
30
+ }
31
+
32
+
33
+ class _PrometheusTLSAdapter(HTTPAdapter):
34
+ """HTTP adapter pinning TLS version bounds on new connections."""
35
+
36
+ def __init__(self, min_version, max_version, verify, **kwargs):
37
+ self._min_version = min_version
38
+ self._max_version = max_version
39
+ # requests/urllib3 set verify_mode and load the CA bundle per request,
40
+ # but CERT_NONE on a context with check_hostname enabled raises, so the
41
+ # context has to be built knowing whether we verify.
42
+ self._cert_reqs = None if verify else ssl.CERT_NONE
43
+ super().__init__(**kwargs)
44
+
45
+ def init_poolmanager(self, *args, **kwargs):
46
+ kwargs['ssl_context'] = create_urllib3_context(
47
+ ssl_minimum_version=self._min_version,
48
+ ssl_maximum_version=self._max_version,
49
+ cert_reqs=self._cert_reqs)
50
+ return super().init_poolmanager(*args, **kwargs)
51
+
52
+
53
+ def _resolve_tls_version(version):
54
+ if version not in _TLS_VERSIONS:
55
+ raise ValueError(
56
+ f"Unknown TLS version: {version}. Supported values are "
57
+ f"{', '.join(sorted(_TLS_VERSIONS))}")
58
+ return _TLS_VERSIONS[version]
59
+
60
+
23
61
  class PrometheusAPIClientError(Exception):
24
62
  def __init__(self, response):
25
63
  self.resp = response
@@ -53,21 +91,47 @@ class PrometheusMetric:
53
91
 
54
92
 
55
93
  class PrometheusAPIClient:
56
- def __init__(self, host, session=None, root_path=""):
94
+ def __init__(self, host, session=None, root_path=None, scheme=None):
95
+ self._scheme = scheme
57
96
  self._host = host
58
- if not self._host.endswith('/'):
59
- self._host += '/'
97
+ self._root_path = root_path or ''
98
+
60
99
  if session is None:
61
100
  self._session = requests.Session()
101
+ self._session.verify = False
62
102
  else:
63
103
  self._session = session
64
- self._session.verify = False
65
- self._root_path = root_path
66
- if root_path != "" and not self._root_path.endswith('/'):
67
- self._root_path += '/'
104
+ self._min_tls_version = None
105
+ self._max_tls_version = None
68
106
 
69
107
  def set_ca_cert(self, ca_cert):
70
108
  self._session.verify = ca_cert
109
+ self._mount_tls_adapter()
110
+
111
+ def set_min_tls_version(self, version):
112
+ """Set the minimum TLS version for HTTPS connections to Prometheus.
113
+
114
+ :param version: TLS version, ``1.2`` or ``1.3``
115
+ :type version: str
116
+ """
117
+ self._min_tls_version = _resolve_tls_version(version)
118
+ self._mount_tls_adapter()
119
+
120
+ def set_max_tls_version(self, version):
121
+ """Set the maximum TLS version for HTTPS connections to Prometheus.
122
+
123
+ :param version: TLS version, ``1.2`` or ``1.3``
124
+ :type version: str
125
+ """
126
+ self._max_tls_version = _resolve_tls_version(version)
127
+ self._mount_tls_adapter()
128
+
129
+ def _mount_tls_adapter(self):
130
+ if self._min_tls_version is None and self._max_tls_version is None:
131
+ return
132
+ self._session.mount('https://', _PrometheusTLSAdapter(
133
+ self._min_tls_version, self._max_tls_version,
134
+ self._session.verify))
71
135
 
72
136
  def set_client_cert(self, client_cert, client_key):
73
137
  self._session.cert = (client_cert, client_key)
@@ -76,8 +140,15 @@ class PrometheusAPIClient:
76
140
  self._session.auth = (auth_user, auth_password)
77
141
 
78
142
  def _get_url(self, endpoint):
79
- scheme = 'https' if self._session.verify else 'http'
80
- return f"{scheme}://{self._host}{self._root_path}api/v1/{endpoint}"
143
+ if self._scheme is None:
144
+ scheme = 'https' if self._session.verify else 'http'
145
+ else:
146
+ scheme = self._scheme
147
+ components = (scheme, self._host, self._root_path, '', '')
148
+ base_url = urllib.parse.urlunsplit(components)
149
+ if not base_url.endswith('/'):
150
+ base_url += '/'
151
+ return urllib.parse.urljoin(base_url, f'api/v1/{endpoint}')
81
152
 
82
153
  def _get(self, endpoint, params=None):
83
154
  url = self._get_url(endpoint)
@@ -14,6 +14,8 @@
14
14
 
15
15
  from unittest import mock
16
16
 
17
+ import ssl
18
+
17
19
  import requests
18
20
 
19
21
  import testtools
@@ -83,6 +85,90 @@ class PrometheusAPIClientTestBase(testtools.TestCase):
83
85
 
84
86
 
85
87
  class PrometheusAPIClientTest(PrometheusAPIClientTestBase):
88
+ def _ssl_context(self, c):
89
+ adapter = c._session.get_adapter("https://localhost:9090/")
90
+ self.assertIsInstance(adapter, client._PrometheusTLSAdapter)
91
+ return adapter.poolmanager.connection_pool_kw['ssl_context']
92
+
93
+ def test_set_min_tls_version(self):
94
+ c = client.PrometheusAPIClient("localhost:9090")
95
+ c.set_min_tls_version("1.2")
96
+ ctx = self._ssl_context(c)
97
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.minimum_version)
98
+ # verify is False by default, so the context must not demand certs
99
+ self.assertEqual(ssl.CERT_NONE, ctx.verify_mode)
100
+
101
+ def test_set_min_tls_version_with_ca_cert(self):
102
+ c = client.PrometheusAPIClient("localhost:9090")
103
+ c.set_ca_cert(True)
104
+ c.set_min_tls_version("1.3")
105
+ ctx = self._ssl_context(c)
106
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.minimum_version)
107
+ self.assertEqual(ssl.CERT_REQUIRED, ctx.verify_mode)
108
+ self.assertTrue(ctx.check_hostname)
109
+
110
+ def test_set_min_tls_version_invalid(self):
111
+ c = client.PrometheusAPIClient("localhost:9090")
112
+ self.assertRaises(ValueError, c.set_min_tls_version, "TLSv1_2")
113
+ self.assertRaises(ValueError, c.set_min_tls_version, "1.1")
114
+
115
+ def test_set_max_tls_version(self):
116
+ c = client.PrometheusAPIClient("localhost:9090")
117
+ c.set_max_tls_version("1.2")
118
+ ctx = self._ssl_context(c)
119
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.maximum_version)
120
+ self.assertEqual(ssl.CERT_NONE, ctx.verify_mode)
121
+
122
+ def test_set_max_tls_version_with_ca_cert(self):
123
+ c = client.PrometheusAPIClient("localhost:9090")
124
+ c.set_ca_cert(True)
125
+ c.set_max_tls_version("1.3")
126
+ ctx = self._ssl_context(c)
127
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.maximum_version)
128
+ self.assertEqual(ssl.CERT_REQUIRED, ctx.verify_mode)
129
+ self.assertTrue(ctx.check_hostname)
130
+
131
+ def test_set_min_and_max_tls_version(self):
132
+ c = client.PrometheusAPIClient("localhost:9090")
133
+ c.set_min_tls_version("1.2")
134
+ c.set_max_tls_version("1.3")
135
+ ctx = self._ssl_context(c)
136
+ self.assertEqual(ssl.TLSVersion.TLSv1_2, ctx.minimum_version)
137
+ self.assertEqual(ssl.TLSVersion.TLSv1_3, ctx.maximum_version)
138
+
139
+ def test_set_max_tls_version_invalid(self):
140
+ c = client.PrometheusAPIClient("localhost:9090")
141
+ self.assertRaises(ValueError, c.set_max_tls_version, "TLSv1_2")
142
+ self.assertRaises(ValueError, c.set_max_tls_version, "1.1")
143
+
144
+ def test_init_scheme_default(self):
145
+ c = client.PrometheusAPIClient("localhost:9090")
146
+ self.assertIsNone(c._scheme)
147
+
148
+ def test_init_scheme_passed(self):
149
+ c = client.PrometheusAPIClient("localhost:9090", scheme="https")
150
+ self.assertEqual("https", c._scheme)
151
+
152
+ def test_get_url_without_scheme_uses_verify(self):
153
+ c = client.PrometheusAPIClient("localhost:9090")
154
+ c._session.verify = False
155
+ self.assertEqual("http://localhost:9090/api/v1/query",
156
+ c._get_url("query"))
157
+ c._session.verify = True
158
+ self.assertEqual("https://localhost:9090/api/v1/query",
159
+ c._get_url("query"))
160
+
161
+ def test_get_url_with_scheme_ignores_verify(self):
162
+ c = client.PrometheusAPIClient("localhost:9090", scheme="https")
163
+ c._session.verify = False
164
+ self.assertEqual("https://localhost:9090/api/v1/query",
165
+ c._get_url("query"))
166
+
167
+ c = client.PrometheusAPIClient("localhost:9090", scheme="http")
168
+ c._session.verify = True
169
+ self.assertEqual("http://localhost:9090/api/v1/query",
170
+ c._get_url("query"))
171
+
86
172
  def test_get(self):
87
173
  url = "test"
88
174
  root_path = "root_path"
@@ -57,7 +57,7 @@ class GetPrometheusClientTest(testtools.TestCase):
57
57
  mock.patch.object(prometheus_client.PrometheusAPIClient,
58
58
  "__init__", return_value=None) as m:
59
59
  metric_utils.get_prometheus_client()
60
- m.assert_called_with("somehost:1234", None, "")
60
+ m.assert_called_with("somehost:1234", None, None)
61
61
 
62
62
  def test_get_prometheus_client_env_override(self):
63
63
  with mock.patch.dict(os.environ,
@@ -67,7 +67,7 @@ class GetPrometheusClientTest(testtools.TestCase):
67
67
  mock.patch.object(prometheus_client.PrometheusAPIClient,
68
68
  "__init__", return_value=None) as m:
69
69
  metric_utils.get_prometheus_client()
70
- m.assert_called_with("env_override:1234", None, "")
70
+ m.assert_called_with("env_override:1234", None, None)
71
71
 
72
72
  def test_get_prometheus_client_no_config_file(self):
73
73
  patched_env = {'PROMETHEUS_HOST': 'env_override',
@@ -78,7 +78,7 @@ class GetPrometheusClientTest(testtools.TestCase):
78
78
  mock.patch.object(prometheus_client.PrometheusAPIClient,
79
79
  "__init__", return_value=None) as m:
80
80
  metric_utils.get_prometheus_client()
81
- m.assert_called_with("env_override:env_port", None, "")
81
+ m.assert_called_with("env_override:env_port", None, None)
82
82
 
83
83
  def test_get_prometheus_client_prefix_in_env_variable(self):
84
84
  patched_env = {'PROMETHEUS_HOST': 'env_override',
@@ -115,7 +115,7 @@ class GetPrometheusClientTest(testtools.TestCase):
115
115
  "set_ca_cert") as ca_m:
116
116
  metric_utils.get_prometheus_client(keystone_session)
117
117
  init_m.assert_called_with(
118
- "localhost:1234", keystone_session, "prometheus"
118
+ "localhost:1234", keystone_session, "prometheus", scheme="http"
119
119
  )
120
120
  ca_m.assert_not_called()
121
121
 
@@ -133,9 +133,11 @@ class GetPrometheusClientTest(testtools.TestCase):
133
133
  "set_ca_cert") as ca_m:
134
134
  metric_utils.get_prometheus_client(keystone_session)
135
135
  init_m.assert_called_with(
136
- "localhost:1234", keystone_session, "prometheus"
136
+ "localhost:1234", keystone_session, "prometheus", scheme="https"
137
137
  )
138
- ca_m.assert_called_with(True)
138
+ # Session transport options (verify/insecure) must be preserved;
139
+ # do not override them based on the endpoint URL scheme.
140
+ ca_m.assert_not_called()
139
141
 
140
142
  def test_get_prometheus_client_from_env_vars_ipv6(self):
141
143
  patched_env = {'PROMETHEUS_HOST': '2607:5300:201:2000::654',
@@ -146,7 +148,7 @@ class GetPrometheusClientTest(testtools.TestCase):
146
148
  mock.patch.object(prometheus_client.PrometheusAPIClient,
147
149
  "__init__", return_value=None) as m:
148
150
  metric_utils.get_prometheus_client()
149
- m.assert_called_with("[2607:5300:201:2000::654]:1234", None, "")
151
+ m.assert_called_with("[2607:5300:201:2000::654]:1234", None, None)
150
152
 
151
153
  def test_get_prometheus_client_from_conf_file_ipv6(self):
152
154
  config_data = '''
@@ -161,7 +163,7 @@ class GetPrometheusClientTest(testtools.TestCase):
161
163
  "__init__", return_value=None) as init_m:
162
164
  metric_utils.get_prometheus_client()
163
165
  init_m.assert_called_with(
164
- "[2607:5300:201:2000::654]:80", None, ""
166
+ "[2607:5300:201:2000::654]:80", None, None
165
167
  )
166
168
 
167
169
  def test_get_prometheus_client_from_keystone_ipv6(self):
@@ -178,7 +180,8 @@ class GetPrometheusClientTest(testtools.TestCase):
178
180
  "set_ca_cert") as ca_m:
179
181
  metric_utils.get_prometheus_client(keystone_session)
180
182
  init_m.assert_called_with(
181
- "[2607:5300:201:2000::654]:80", keystone_session, "prometheus"
183
+ "[2607:5300:201:2000::654]:80", keystone_session, "prometheus",
184
+ scheme="http"
182
185
  )
183
186
  ca_m.assert_not_called()
184
187
 
@@ -59,47 +59,41 @@ def get_prom_client_from_keystone(session, adapter_options=None):
59
59
 
60
60
  escaped_host = netutils.escape_ipv6(parsed_url.hostname)
61
61
  root_path = parsed_url.path.strip('/')
62
- tls = parsed_url.scheme == "https"
63
62
 
64
63
  if parsed_url.port is not None:
65
64
  url = f'{escaped_host}:{parsed_url.port}'
66
65
  else:
67
66
  url = escaped_host
68
67
 
69
- client = PrometheusAPIClient(url, session, root_path)
70
-
71
- if tls:
72
- client.set_ca_cert(True)
73
- return client
68
+ return PrometheusAPIClient(
69
+ url, session, root_path, scheme=parsed_url.scheme)
74
70
 
75
71
 
76
72
  def get_prom_client_from_file_or_env():
77
- host = port = ca_cert = None
78
- root_path = ''
79
- conf_file = get_config_file()
80
- if conf_file is not None:
81
- conf = yaml.safe_load(conf_file)
82
- if 'host' in conf:
83
- host = conf['host']
84
- if 'port' in conf:
85
- port = conf['port']
86
- if 'ca_cert' in conf:
87
- ca_cert = conf['ca_cert']
88
- if 'root_path' in conf:
89
- root_path = conf['root_path']
90
- conf_file.close()
91
- if 'PROMETHEUS_HOST' in os.environ:
92
- host = os.environ['PROMETHEUS_HOST']
93
- if 'PROMETHEUS_PORT' in os.environ:
94
- port = os.environ['PROMETHEUS_PORT']
95
- if 'PROMETHEUS_CA_CERT' in os.environ:
96
- ca_cert = os.environ['PROMETHEUS_CA_CERT']
97
- if 'PROMETHEUS_ROOT_PATH' in os.environ:
98
- root_path = os.environ['PROMETHEUS_ROOT_PATH']
99
- if host is None or port is None:
100
- raise ConfigurationError("Can't find prometheus host and "
101
- "port configuration in config file or "
102
- "environment variables.")
73
+ host = ca_cert = root_path = None
74
+ port = 9090
75
+ try:
76
+ conf_file = get_config_file()
77
+ if conf_file is not None:
78
+ conf = yaml.safe_load(conf_file)
79
+ host = conf.get('host', host)
80
+ port = conf.get('port', port)
81
+ ca_cert = conf.get('ca_cert', ca_cert)
82
+ root_path = conf.get('root_path', root_path)
83
+ finally:
84
+ if conf_file is not None:
85
+ conf_file.close()
86
+
87
+ host = os.environ.get('PROMETHEUS_HOST', host)
88
+ port = os.environ.get('PROMETHEUS_PORT', port)
89
+ ca_cert = os.environ.get('PROMETHEUS_CA_CERT', ca_cert)
90
+ root_path = os.environ.get('PROMETHEUS_ROOT_PATH', root_path)
91
+
92
+ if host is None:
93
+ raise ConfigurationError(
94
+ "Can't find prometheus host configuration in config file or "
95
+ "environment variables.")
96
+
103
97
  escaped_host = netutils.escape_ipv6(host)
104
98
  client = PrometheusAPIClient(
105
99
  f"{escaped_host}:{port}", None, root_path
@@ -1,6 +1,6 @@
1
1
  [build-system]
2
- requires = ['setuptools>=68']
3
- build-backend = 'setuptools.build_meta'
2
+ requires = ["pbr>=6.1.1"]
3
+ build-backend = "pbr.build"
4
4
 
5
5
  [project]
6
6
  name = "python-observabilityclient"
@@ -11,7 +11,7 @@ authors = [
11
11
  readme = {file = "README.rst", content-type = "text/markdown; charset=UTF-8"}
12
12
  license = {text = "Apache-2.0"}
13
13
  dynamic = ["version", "dependencies"]
14
- requires-python = ">=3.10"
14
+ requires-python = ">=3.11"
15
15
  classifiers = [
16
16
  "Environment :: Console",
17
17
  "Environment :: OpenStack",
@@ -22,10 +22,11 @@ classifiers = [
22
22
  "Operating System :: OS Independent",
23
23
  "Programming Language :: Python",
24
24
  "Programming Language :: Python :: 3",
25
- "Programming Language :: Python :: 3.10",
26
25
  "Programming Language :: Python :: 3.11",
27
26
  "Programming Language :: Python :: 3.12",
28
27
  "Programming Language :: Python :: 3.13",
28
+ "Programming Language :: Python :: 3.14",
29
+ "Programming Language :: Python :: 3.15",
29
30
  "Programming Language :: Python :: 3 :: Only",
30
31
  ]
31
32
 
@@ -34,9 +35,6 @@ packages = [
34
35
  "observabilityclient"
35
36
  ]
36
37
 
37
- [project.scripts]
38
- aodh = "aodhclient.shell:main"
39
-
40
38
  [project.entry-points."openstack.cli.extension"]
41
39
  observabilityclient = "observabilityclient.plugin"
42
40
 
@@ -47,3 +45,48 @@ metric_query = "observabilityclient.v1.cli:Query"
47
45
  metric_delete = "observabilityclient.v1.cli:Delete"
48
46
  metric_clean-tombstones = "observabilityclient.v1.cli:CleanTombstones"
49
47
  metric_snapshot = "observabilityclient.v1.cli:Snapshot"
48
+
49
+ [tool.autopep8]
50
+ aggressive = 3
51
+ in-place = true
52
+ recursive = true
53
+ ignore = ["E731"]
54
+
55
+ [tool.doc8]
56
+ ignore = ["D001"]
57
+
58
+ [tool.ruff]
59
+ line-length = 79
60
+
61
+ [tool.ruff.lint]
62
+ select = [
63
+ # mcabe complexity checks
64
+ "C90",
65
+ # multiple-imports-on-one-line, module-import-not-at-top-of-file
66
+ "E4",
67
+ # line-too-long, redundant-backslash
68
+ "E5",
69
+ "E7",
70
+ "E9",
71
+ # pyflakes
72
+ "F",
73
+ "G",
74
+ "LOG",
75
+ "S",
76
+ "UP",
77
+ "W",
78
+ ]
79
+ external = ["H"]
80
+ ignore = [
81
+ # UP031 % format — defer f-string migration to a later pass
82
+ "UP031",
83
+ # UP032 f-string — defer migration to a later pass
84
+ "UP032",
85
+ ]
86
+
87
+ [tool.ruff.lint.per-file-ignores]
88
+ "observabilityclient/tests/*" = ["S"]
89
+
90
+ [tool.ruff.lint.mccabe]
91
+ # Flag errors (`C901`) whenever the complexity level exceeds 20.
92
+ max-complexity = 20
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-observabilityclient
3
- Version: 1.3.0
3
+ Version: 1.5.0
4
4
  Summary: OpenStack Observability Client
5
5
  Author-email: OpenStack <openstack-discuss@lists.openstack.org>
6
6
  License: Apache-2.0
@@ -13,12 +13,13 @@ Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Programming Language :: Python :: 3.12
19
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
20
21
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
22
23
  Description-Content-Type: text/markdown; charset=UTF-8
23
24
  License-File: LICENSE
24
25
  Requires-Dist: osc-lib>=1.0.1
@@ -47,6 +48,7 @@ Install your OpenStack environment and patch your ``openstack`` client
47
48
  application using python.
48
49
 
49
50
  .. code:: console
51
+
50
52
  git clone https://opendev.org/openstack/python-observabilityclient.git
51
53
  cd python-observabilityclient
52
54
  sudo pip install .
@@ -60,6 +62,7 @@ Use ``openstack metric query somequery`` to query for metrics in prometheus.
60
62
  To use the python api do the following:
61
63
 
62
64
  .. code:: python
65
+
63
66
  from observabilityclient import client
64
67
 
65
68
  c = client.Client(
@@ -1,5 +1,6 @@
1
1
  .coveragerc
2
2
  .pre-commit-config.yaml
3
+ .stestr.conf
3
4
  .zuul.yaml
4
5
  AUTHORS
5
6
  CONTRIBUTING.rst
@@ -56,12 +57,16 @@ releasenotes/notes/allow-for-specifying-rbac-label-name-f99084757cde5f19.yaml
56
57
  releasenotes/notes/change-aetos-service-type-37a53a86f4975803.yaml
57
58
  releasenotes/notes/disable-config-overrides-for-keystone-discovered-endpoints-0b36ad382f029fa0.yaml
58
59
  releasenotes/notes/fix-ipv6-escaping-faef776565954baa.yaml
60
+ releasenotes/notes/keep-session-transport-options-6ad0880b46c8b1e1.yaml
61
+ releasenotes/notes/prometheus-tls-versions.yaml
59
62
  releasenotes/notes/refactor-rbac-967ed5edcc1ef2a4.yaml
60
63
  releasenotes/notes/remove-py38-acd461c4350f0dca.yaml
61
64
  releasenotes/notes/remove-py39-a3f911847e0075b6.yaml
62
65
  releasenotes/notes/send-token-only-when-communicating-with-aetos-21299ccc710f6473.yaml
63
66
  releasenotes/source/2025.1.rst
64
67
  releasenotes/source/2025.2.rst
68
+ releasenotes/source/2026.1.rst
69
+ releasenotes/source/2026.2.rst
65
70
  releasenotes/source/conf.py
66
71
  releasenotes/source/index.rst
67
72
  releasenotes/source/unreleased.rst
@@ -1,6 +1,3 @@
1
- [console_scripts]
2
- aodh = aodhclient.shell:main
3
-
4
1
  [openstack.cli.extension]
5
2
  observabilityclient = observabilityclient.plugin
6
3
 
@@ -0,0 +1 @@
1
+ {"git_version": "8ba76b1", "is_release": true}
@@ -0,0 +1,8 @@
1
+ ---
2
+ fixes:
3
+ - |
4
+ Preserve transport options (such as ``verify`` / ``insecure``) on a
5
+ pre-created Keystone session when talking to Aetos. Previously, TLS
6
+ verification was forced on solely from the endpoint URL scheme, which
7
+ prevented using observabilityclient against endpoints with self-signed
8
+ certificates configured via ``clouds.yaml`` / openstackclient.
@@ -0,0 +1,8 @@
1
+ ---
2
+ features:
3
+ - |
4
+ ``PrometheusAPIClient`` now supports ``set_min_tls_version`` and
5
+ ``set_max_tls_version`` to configure the TLS protocol version bounds used
6
+ for HTTPS connections to Prometheus. Accepted values are ``1.2`` and
7
+ ``1.3``, matching the spelling used by ``keystoneauth1``'s
8
+ ``tls_min_version``.
@@ -0,0 +1,6 @@
1
+ ===========================
2
+ 2026.1 Series Release Notes
3
+ ===========================
4
+
5
+ .. release-notes::
6
+ :branch: stable/2026.1
@@ -0,0 +1,6 @@
1
+ ===========================
2
+ 2026.2 Series Release Notes
3
+ ===========================
4
+
5
+ .. release-notes::
6
+ :branch: stable/2026.2
@@ -8,6 +8,8 @@ Contents
8
8
  :maxdepth: 2
9
9
 
10
10
  unreleased
11
+ 2026.2
12
+ 2026.1
11
13
  2025.2
12
14
  2025.1
13
15
 
@@ -0,0 +1,8 @@
1
+ # Requirements lower bounds listed here are our best effort to keep them up to
2
+ # date but we do not test them so no guarantee of having them all correct. If
3
+ # you find any incorrect lower bounds, let us know or propose a fix.
4
+
5
+ osc-lib>=1.0.1 # Apache-2.0
6
+ keystoneauth1>=1.0.0 # Apache-2.0
7
+ cliff>=1.14.0 # Apache-2.0
8
+ PyYAML>5.1 # Apache-2.0
@@ -1,21 +1,18 @@
1
1
  [tox]
2
- minversion = 4.2.5
2
+ minversion = 4.28.0
3
3
  envlist = py3,pep8
4
4
 
5
5
  [testenv]
6
6
  usedevelop = True
7
- setenv =
8
- VIRTUAL_ENV={envdir}
9
- OBSERVABILITY_CLIENT_EXEC_DIR={envdir}/bin
10
- OS_TEST_PATH = ./observabilityclient/tests/unit
11
7
  passenv =
12
8
  PROMETHEUS_*
13
9
  OBSERVABILITY_*
10
+ constraints =
11
+ {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
14
12
  deps =
15
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
16
13
  -r{toxinidir}/requirements.txt
17
14
  -r{toxinidir}/test-requirements.txt
18
- commands = stestr run --slowest --test-path {env:OS_TEST_PATH} {posargs}
15
+ commands = stestr run --slowest {posargs}
19
16
 
20
17
  [testenv:pep8]
21
18
  skip_install = true
@@ -29,8 +26,7 @@ commands = {posargs}
29
26
 
30
27
  [testenv:cover]
31
28
  setenv =
32
- {[testenv]setenv}
33
- PYTHON=coverage run --source observabilityclient --parallel-mode
29
+ PYTHON=coverage run --source observabilityclient --parallel-mode
34
30
  commands =
35
31
  coverage erase
36
32
  {[testenv]commands}
@@ -51,12 +47,12 @@ commands =
51
47
 
52
48
  [testenv:docs]
53
49
  deps =
54
- -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
55
50
  -r{toxinidir}/requirements.txt
56
51
  -r{toxinidir}/doc/requirements.txt
57
52
  commands = sphinx-build --keep-going -b html doc/source doc/build/html
58
53
 
59
54
  [flake8]
55
+ select = H
60
56
  show-source = True
61
57
  # W504 line break after binary operator
62
58
  ignore = W504
@@ -80,7 +76,4 @@ application-import-names = observabilityclient
80
76
  [testenv:releasenotes]
81
77
  deps =
82
78
  -r{toxinidir}/doc/requirements.txt
83
- -r{toxinidir}/requirements.txt
84
- allowlist_externals =
85
- sphinx-build
86
79
  commands = sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
@@ -1 +0,0 @@
1
- {"git_version": "5e7f98b", "is_release": true}
@@ -1,4 +0,0 @@
1
- osc-lib>=1.0.1 # Apache-2.0
2
- keystoneauth1>=1.0.0 # Apache-2.0
3
- cliff>=1.14.0 # Apache-2.0
4
- PyYAML>5.1 # Apache-2.0