badfish 1.0.6__py3-none-any.whl → 1.1.0__py3-none-any.whl
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.
- badfish/__init__.py +1 -0
- badfish/helpers/http_client.py +2 -2
- badfish/main.py +11 -7
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/METADATA +4 -4
- badfish-1.1.0.dist-info/RECORD +15 -0
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/WHEEL +1 -1
- badfish/helpers/async_lru.py +0 -215
- badfish-1.0.6.dist-info/RECORD +0 -16
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/entry_points.txt +0 -0
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/top_level.txt +0 -0
- {badfish-1.0.6.dist-info → badfish-1.1.0.dist-info}/zip-safe +0 -0
badfish/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.0"
|
badfish/helpers/http_client.py
CHANGED
|
@@ -4,8 +4,8 @@ from typing import Any, Dict, Optional
|
|
|
4
4
|
|
|
5
5
|
import aiohttp
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
7
|
+
from async_lru import alru_cache
|
|
8
|
+
from badfish.helpers.exceptions import BadfishException
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class HTTPClient:
|
badfish/main.py
CHANGED
|
@@ -13,11 +13,11 @@ import yaml
|
|
|
13
13
|
import tempfile
|
|
14
14
|
from urllib.parse import urlparse
|
|
15
15
|
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
19
|
-
from
|
|
20
|
-
from
|
|
16
|
+
from badfish.helpers import get_now
|
|
17
|
+
from badfish.helpers.parser import parse_arguments
|
|
18
|
+
from badfish.helpers.logger import BadfishLogger
|
|
19
|
+
from badfish.helpers.http_client import HTTPClient
|
|
20
|
+
from badfish.helpers.exceptions import BadfishException
|
|
21
21
|
|
|
22
22
|
from logging import (
|
|
23
23
|
DEBUG,
|
|
@@ -393,7 +393,7 @@ class Badfish:
|
|
|
393
393
|
|
|
394
394
|
_uri = "%s%s" % (self.host_uri, session_uri)
|
|
395
395
|
check_response = await self.http_client.get_request(_uri, _continue=True, _get_token=True)
|
|
396
|
-
if check_response is None:
|
|
396
|
+
if check_response is None or check_response.status != 200:
|
|
397
397
|
session_uri = "/redfish/v1/SessionService/Sessions"
|
|
398
398
|
|
|
399
399
|
return session_uri
|
|
@@ -2674,7 +2674,11 @@ def main(argv=None):
|
|
|
2674
2674
|
output = _args["output"]
|
|
2675
2675
|
bfl = BadfishLogger(_args["verbose"], multi_host, _args["log"], output)
|
|
2676
2676
|
|
|
2677
|
-
|
|
2677
|
+
try:
|
|
2678
|
+
loop = asyncio.get_event_loop()
|
|
2679
|
+
except RuntimeError:
|
|
2680
|
+
loop = asyncio.new_event_loop()
|
|
2681
|
+
asyncio.set_event_loop(loop)
|
|
2678
2682
|
tasks = []
|
|
2679
2683
|
host_order = {}
|
|
2680
2684
|
if host_list:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: badfish
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Badfish is a Redfish-based API tool for managing bare-metal systems via the Redfish API
|
|
5
5
|
Home-page: https://github.com/redhat-performance/badfish
|
|
6
6
|
Author: Gonzalo Rafuls
|
|
7
7
|
Author-email: gonza@redhat.com
|
|
8
|
-
License:
|
|
8
|
+
License: GPL-3.0-or-later
|
|
9
9
|
Project-URL: Bug Tracker, https://github.com/redhat-performance/badfish/issues
|
|
10
10
|
Project-URL: Documentation, https://github.com/redhat-performance/badfish/blob/master/README.md
|
|
11
11
|
Project-URL: Source Code, https://github.com/redhat-performance/badfish
|
|
@@ -24,8 +24,9 @@ Requires-Python: >=3.10
|
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: pyyaml>=3.10
|
|
27
|
-
Requires-Dist: aiohttp>=3.
|
|
27
|
+
Requires-Dist: aiohttp>=3.10
|
|
28
28
|
Requires-Dist: setuptools>=39.0
|
|
29
|
+
Requires-Dist: async-lru>=2.0
|
|
29
30
|
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
<p align="center">
|
|
@@ -753,7 +754,6 @@ With rack, ULocation and blade being optional in a hierarchical fashion otherwis
|
|
|
753
754
|
|
|
754
755
|
Please refer to our contributing [guide](CONTRIBUTING.md).
|
|
755
756
|
|
|
756
|
-
|
|
757
757
|
* Here is some useful documentation
|
|
758
758
|
- [Creating a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)
|
|
759
759
|
- [Keeping a cloned fork up to date](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
badfish/__init__.py,sha256=LGVQyDsWifdACo7qztwb8RWWHds1E7uQ-ZqD8SAjyw4,22
|
|
2
|
+
badfish/config.py,sha256=lTkdP2mE3W7bYcnBSS7gwKvwqhcjm04_JemyQAac2iA,13
|
|
3
|
+
badfish/main.py,sha256=yAIHpwGrdg4WyDkEkQB7kHVPArwt4UxC6O1qqgo5Iqk,114704
|
|
4
|
+
badfish/helpers/__init__.py,sha256=PPiwRZmMOraluom_4xHo2txsWiKTp5pOb8VJkRoMtlI,73
|
|
5
|
+
badfish/helpers/exceptions.py,sha256=00Es3q0VEkUMDiDt-FaNfEPMmXdILva4QqxAKFCLK3Y,44
|
|
6
|
+
badfish/helpers/http_client.py,sha256=6rNxU0Qsg1vKAoiZ5di7H0AtxvayC3RRLLddYOgNHYU,9468
|
|
7
|
+
badfish/helpers/logger.py,sha256=tVGzDVgspIA88uwJ1n9Ga89ut-sEguECJUzCJRm_Vbo,8405
|
|
8
|
+
badfish/helpers/parser.py,sha256=ZId0VSA9zDnhpTjaXhBu4DS8IzdGuJGYaR3GN5EuvLI,8742
|
|
9
|
+
badfish-1.1.0.dist-info/licenses/LICENSE,sha256=WJ7YI-moTFb-uVrFjnzzhGJrnL9P2iqQe8NuED3hutI,35141
|
|
10
|
+
badfish-1.1.0.dist-info/METADATA,sha256=3uKxU9lsngwZ6tt8A3zmh0Ti12uI_21W5T1uUafMUYM,40475
|
|
11
|
+
badfish-1.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
+
badfish-1.1.0.dist-info/entry_points.txt,sha256=Fpg4ZrKAnJQfsL6KHFsFE-5z-RAUJPm-L1c0VVYPVBU,46
|
|
13
|
+
badfish-1.1.0.dist-info/top_level.txt,sha256=-OHxYfrQDO7kPx6REmjwwVzwQ5QyMozHou-imfoME28,8
|
|
14
|
+
badfish-1.1.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
15
|
+
badfish-1.1.0.dist-info/RECORD,,
|
badfish/helpers/async_lru.py
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
# The MIT License
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018 aio-libs team https://github.com/aio-libs/
|
|
4
|
-
# Copyright (c) 2017 Ocean S. A. https://ocean.io/
|
|
5
|
-
# Copyright (c) 2016-2017 WikiBusiness Corporation http://wikibusiness.org/
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in
|
|
15
|
-
# all copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
# THE SOFTWARE.
|
|
24
|
-
|
|
25
|
-
import asyncio
|
|
26
|
-
from collections import OrderedDict
|
|
27
|
-
from functools import _CacheInfo, _make_key, partial, wraps
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
__version__ = "1.0.2"
|
|
31
|
-
|
|
32
|
-
__all__ = ("alru_cache",)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def unpartial(fn):
|
|
36
|
-
while hasattr(fn, "func"):
|
|
37
|
-
fn = fn.func
|
|
38
|
-
|
|
39
|
-
return fn
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _done_callback(fut, task):
|
|
43
|
-
if task.cancelled():
|
|
44
|
-
fut.cancel()
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
exc = task.exception()
|
|
48
|
-
if exc is not None:
|
|
49
|
-
fut.set_exception(exc)
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
fut.set_result(task.result())
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _cache_invalidate(wrapped, typed, *args, **kwargs):
|
|
56
|
-
key = _make_key(args, kwargs, typed)
|
|
57
|
-
|
|
58
|
-
exists = key in wrapped._cache
|
|
59
|
-
|
|
60
|
-
if exists:
|
|
61
|
-
wrapped._cache.pop(key)
|
|
62
|
-
|
|
63
|
-
return exists
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def _cache_clear(wrapped):
|
|
67
|
-
wrapped.hits = wrapped.misses = 0
|
|
68
|
-
wrapped._cache = OrderedDict()
|
|
69
|
-
wrapped.tasks = set()
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def _open(wrapped):
|
|
73
|
-
if not wrapped.closed:
|
|
74
|
-
raise RuntimeError("alru_cache is not closed")
|
|
75
|
-
|
|
76
|
-
was_closed = wrapped.hits == wrapped.misses == len(wrapped.tasks) == len(wrapped._cache) == 0
|
|
77
|
-
|
|
78
|
-
if not was_closed:
|
|
79
|
-
raise RuntimeError("alru_cache was not closed correctly")
|
|
80
|
-
|
|
81
|
-
wrapped.closed = False
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def _close(wrapped, *, cancel=False, return_exceptions=True):
|
|
85
|
-
if wrapped.closed:
|
|
86
|
-
raise RuntimeError("alru_cache is closed")
|
|
87
|
-
|
|
88
|
-
wrapped.closed = True
|
|
89
|
-
|
|
90
|
-
if cancel:
|
|
91
|
-
for task in wrapped.tasks:
|
|
92
|
-
if not task.done(): # not sure is it possible
|
|
93
|
-
task.cancel()
|
|
94
|
-
|
|
95
|
-
return _wait_closed(wrapped, return_exceptions=return_exceptions)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
async def _wait_closed(wrapped, *, return_exceptions):
|
|
99
|
-
wait_closed = asyncio.gather(*wrapped.tasks, return_exceptions=return_exceptions)
|
|
100
|
-
|
|
101
|
-
wait_closed.add_done_callback(partial(_close_waited, wrapped))
|
|
102
|
-
|
|
103
|
-
ret = await wait_closed
|
|
104
|
-
|
|
105
|
-
# hack to get _close_waited callback to be executed
|
|
106
|
-
await asyncio.sleep(0)
|
|
107
|
-
|
|
108
|
-
return ret
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def _close_waited(wrapped, _):
|
|
112
|
-
wrapped.cache_clear()
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def _cache_info(wrapped, maxsize):
|
|
116
|
-
return _CacheInfo(
|
|
117
|
-
wrapped.hits,
|
|
118
|
-
wrapped.misses,
|
|
119
|
-
maxsize,
|
|
120
|
-
len(wrapped._cache),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def __cache_touch(wrapped, key):
|
|
125
|
-
try:
|
|
126
|
-
wrapped._cache.move_to_end(key)
|
|
127
|
-
except KeyError: # not sure is it possible
|
|
128
|
-
pass
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def _cache_hit(wrapped, key):
|
|
132
|
-
wrapped.hits += 1
|
|
133
|
-
__cache_touch(wrapped, key)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def _cache_miss(wrapped, key):
|
|
137
|
-
wrapped.misses += 1
|
|
138
|
-
__cache_touch(wrapped, key)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def alru_cache(
|
|
142
|
-
fn=None,
|
|
143
|
-
maxsize=128,
|
|
144
|
-
typed=False,
|
|
145
|
-
*,
|
|
146
|
-
cache_exceptions=True,
|
|
147
|
-
):
|
|
148
|
-
def wrapper(fn):
|
|
149
|
-
_origin = unpartial(fn)
|
|
150
|
-
|
|
151
|
-
if not asyncio.iscoroutinefunction(_origin):
|
|
152
|
-
raise RuntimeError("Coroutine function is required, got {}".format(fn))
|
|
153
|
-
|
|
154
|
-
# functools.partialmethod support
|
|
155
|
-
if hasattr(fn, "_make_unbound_method"):
|
|
156
|
-
fn = fn._make_unbound_method()
|
|
157
|
-
|
|
158
|
-
@wraps(fn)
|
|
159
|
-
async def wrapped(*fn_args, **fn_kwargs):
|
|
160
|
-
if wrapped.closed:
|
|
161
|
-
raise RuntimeError("alru_cache is closed for {}".format(wrapped))
|
|
162
|
-
|
|
163
|
-
loop = asyncio.get_event_loop()
|
|
164
|
-
|
|
165
|
-
key = _make_key(fn_args, fn_kwargs, typed)
|
|
166
|
-
|
|
167
|
-
fut = wrapped._cache.get(key)
|
|
168
|
-
|
|
169
|
-
if fut is not None:
|
|
170
|
-
if not fut.done():
|
|
171
|
-
_cache_hit(wrapped, key)
|
|
172
|
-
return await asyncio.shield(fut)
|
|
173
|
-
|
|
174
|
-
exc = fut._exception
|
|
175
|
-
|
|
176
|
-
if exc is None or cache_exceptions:
|
|
177
|
-
_cache_hit(wrapped, key)
|
|
178
|
-
return fut.result()
|
|
179
|
-
|
|
180
|
-
# exception here and cache_exceptions == False
|
|
181
|
-
wrapped._cache.pop(key)
|
|
182
|
-
|
|
183
|
-
fut = loop.create_future()
|
|
184
|
-
task = loop.create_task(fn(*fn_args, **fn_kwargs))
|
|
185
|
-
task.add_done_callback(partial(_done_callback, fut))
|
|
186
|
-
|
|
187
|
-
wrapped.tasks.add(task)
|
|
188
|
-
task.add_done_callback(wrapped.tasks.remove)
|
|
189
|
-
|
|
190
|
-
wrapped._cache[key] = fut
|
|
191
|
-
|
|
192
|
-
if maxsize is not None and len(wrapped._cache) > maxsize:
|
|
193
|
-
wrapped._cache.popitem(last=False)
|
|
194
|
-
|
|
195
|
-
_cache_miss(wrapped, key)
|
|
196
|
-
return await asyncio.shield(fut)
|
|
197
|
-
|
|
198
|
-
_cache_clear(wrapped)
|
|
199
|
-
wrapped._origin = _origin
|
|
200
|
-
wrapped.closed = False
|
|
201
|
-
wrapped.cache_info = partial(_cache_info, wrapped, maxsize)
|
|
202
|
-
wrapped.cache_clear = partial(_cache_clear, wrapped)
|
|
203
|
-
wrapped.invalidate = partial(_cache_invalidate, wrapped, typed)
|
|
204
|
-
wrapped.close = partial(_close, wrapped)
|
|
205
|
-
wrapped.open = partial(_open, wrapped)
|
|
206
|
-
|
|
207
|
-
return wrapped
|
|
208
|
-
|
|
209
|
-
if fn is None:
|
|
210
|
-
return wrapper
|
|
211
|
-
|
|
212
|
-
if callable(fn) or hasattr(fn, "_make_unbound_method"):
|
|
213
|
-
return wrapper(fn)
|
|
214
|
-
|
|
215
|
-
raise NotImplementedError("{} decorating is not supported".format(fn))
|
badfish-1.0.6.dist-info/RECORD
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
badfish/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
badfish/config.py,sha256=lTkdP2mE3W7bYcnBSS7gwKvwqhcjm04_JemyQAac2iA,13
|
|
3
|
-
badfish/main.py,sha256=5YiLHSzI70wCtozRpOoXf2YJf3GTAw9j_wcuIXdVQiY,114577
|
|
4
|
-
badfish/helpers/__init__.py,sha256=PPiwRZmMOraluom_4xHo2txsWiKTp5pOb8VJkRoMtlI,73
|
|
5
|
-
badfish/helpers/async_lru.py,sha256=FFeu_ujkrzqaP1h4VmNrY4awBjC50c6z3cXcc41mS1U,5981
|
|
6
|
-
badfish/helpers/exceptions.py,sha256=00Es3q0VEkUMDiDt-FaNfEPMmXdILva4QqxAKFCLK3Y,44
|
|
7
|
-
badfish/helpers/http_client.py,sha256=Ml94tUhpHTeVIe8aFbRJ8ROuh-B4iBj3wU4z59p5zAg,9492
|
|
8
|
-
badfish/helpers/logger.py,sha256=tVGzDVgspIA88uwJ1n9Ga89ut-sEguECJUzCJRm_Vbo,8405
|
|
9
|
-
badfish/helpers/parser.py,sha256=ZId0VSA9zDnhpTjaXhBu4DS8IzdGuJGYaR3GN5EuvLI,8742
|
|
10
|
-
badfish-1.0.6.dist-info/licenses/LICENSE,sha256=WJ7YI-moTFb-uVrFjnzzhGJrnL9P2iqQe8NuED3hutI,35141
|
|
11
|
-
badfish-1.0.6.dist-info/METADATA,sha256=I-I5_-9TntxZBhp-9UxHlp1pY8woFA-A7zQ78dJkOI0,40436
|
|
12
|
-
badfish-1.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
-
badfish-1.0.6.dist-info/entry_points.txt,sha256=Fpg4ZrKAnJQfsL6KHFsFE-5z-RAUJPm-L1c0VVYPVBU,46
|
|
14
|
-
badfish-1.0.6.dist-info/top_level.txt,sha256=-OHxYfrQDO7kPx6REmjwwVzwQ5QyMozHou-imfoME28,8
|
|
15
|
-
badfish-1.0.6.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
16
|
-
badfish-1.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|