Skip to content

Commit 3f8dda0

Browse files
authored
Merge pull request #2 from Metify-io/support-dmtf-mocks
Support dmtf mocks and python 3.11
2 parents 8532dd5 + 764b671 commit 3f8dda0

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ redfish_client.egg-info
66
htmlcov
77
dist
88
build/
9+
Pipfile.lock

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ coverage:
1717
xdg-open htmlcov/index.html
1818

1919
lint:
20-
pipenv run pylint redfish_client
20+
pipenv run ruff redfish_client
2121

2222
publish:
23+
rm -f dist/*
24+
25+
pipenv --rm
26+
rm Pipfile.lock
27+
pipenv --python 3.11
28+
pipenv install --dev
2329
pipenv run python setup.py sdist bdist_wheel
30+
2431
pipenv run python -m twine upload -r metify-internal dist/*

redfish_client/connector.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,17 @@ def _session_login(self):
158158
resp = self._client.post(self._url(self._session_path), json=dict(
159159
UserName=self._username, Password=self._password,
160160
), timeout=self._timeout)
161-
if resp.status_code != 201:
161+
if resp.status_code not in [201, 204]:
162162
raise AuthException("Cannot create session: {}".format(resp.text))
163163

164-
self._set_header("x-auth-token", resp.headers["x-auth-token"])
164+
if resp.status_code == 201:
165+
# 201: Redfish standard
166+
self._set_header("x-auth-token", resp.headers["x-auth-token"])
167+
else:
168+
# 204: Redfish Mock Server standard
169+
# No auth token is returned so set to anything
170+
self._set_header("x-auth-token", resp.headers.get("location"))
171+
165172
# We combine with `or` here because the default value of the dict.get
166173
# method is eagerly evaluated, which is not what we want.
167174
sess_id = resp.headers.get("location") or resp.json()["@odata.id"]

redfish_client/resource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
import json
1515
import operator
1616
import time
1717
from functools import reduce
@@ -130,6 +130,9 @@ def dig(self, *keys):
130130
return None
131131
return resource
132132

133+
def jp(self):
134+
return json.dumps(self.raw, indent=4, sort_keys=True)
135+
133136
def find_object(self, key):
134137
""" Recursively search for a key and return key's content """
135138
if key in self._get_content().keys():

setup.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description = Redfish API client for Python
1010
long_description = file: README.rst
1111
long_description_content_type = text/x-rst
1212
license_file = LICENSE
13-
version = 0.3.10
13+
version = 0.3.12
1414
classifier =
1515
Development Status :: 3 - Alpha
1616
Environment :: Console
@@ -24,6 +24,8 @@ classifier =
2424
Programming Language :: Python :: 3.7
2525
Programming Language :: Python :: 3.8
2626
Programming Language :: Python :: 3.9
27+
Programming Language :: Python :: 3.10
28+
Programming Language :: Python :: 3.11
2729

2830
[files]
2931
packages =

0 commit comments

Comments
 (0)