Initial commit
This commit is contained in:
commit
1b51716d1b
72 changed files with 8204 additions and 0 deletions
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
18
tests/api/__init__.py
Normal file
18
tests/api/__init__.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"""API related tests"""
|
||||
from argparse import Namespace
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def secrets():
|
||||
"""Deprecated"""
|
||||
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||
|
||||
|
||||
def args(**kwargs):
|
||||
"""Base args for tests"""
|
||||
kwargs.update(
|
||||
{"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||
)
|
||||
return Namespace(**kwargs)
|
||||
253
tests/api/test_api.py
Normal file
253
tests/api/test_api.py
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
"""
|
||||
Tests of the api
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
import requests
|
||||
|
||||
import redfish_cli.api
|
||||
import redfish_cli.api.storage
|
||||
import redfish_cli.api.systems
|
||||
from redfish_cli.api.exceptions import (
|
||||
ResponseNotOK,
|
||||
Unauthorized,
|
||||
)
|
||||
|
||||
from ..utils import get_test_json, MockRedfishResponse, MockResponse
|
||||
|
||||
|
||||
# pylint: disable=missing-function-docstring,redefined-outer-name
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def secrets():
|
||||
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||
|
||||
|
||||
def test_chassis(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("api_chassis.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
chassis = redfish_cli.api.chassis(**secrets)
|
||||
assert chassis["Name"] == "Chassis Collection"
|
||||
|
||||
|
||||
def test_chassis_details(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("api_chassis_details.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
secrets.update({"chassis": "System.Embedded.1"})
|
||||
chassis_details = redfish_cli.api.chassis_details(**secrets)
|
||||
assert chassis_details["Name"] == "Computer System Chassis"
|
||||
|
||||
|
||||
def test_get_base_redfish(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
_ = redfish_cli.api.utils.get(secrets["server"], "")
|
||||
assert "@odata.id" in redfish_cli.api.utils.get(secrets["server"], "")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "get", lambda *args, **kwargs: MockResponse(ok=False)
|
||||
)
|
||||
with pytest.raises(ResponseNotOK):
|
||||
_ = redfish_cli.api.utils.get(secrets["server"], "")
|
||||
|
||||
|
||||
def test_invalid_json(monkeypatch, secrets):
|
||||
"""Test processing of invalid json returned from a get"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
return MockResponse(content="{'a':'invalid json'}")
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
secrets.update({"url": "/"})
|
||||
|
||||
with pytest.raises(json.decoder.JSONDecodeError):
|
||||
_ = redfish_cli.api.utils.get(**secrets)
|
||||
|
||||
|
||||
def test_post(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
_json = {"@odata.id": "dummy"}
|
||||
return MockResponse(content=json.dumps(_json))
|
||||
|
||||
monkeypatch.setattr(requests, "post", mock_get)
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
assert (
|
||||
"@odata.id"
|
||||
in redfish_cli.api.utils.post(
|
||||
secrets["server"], "", username="test", password="test"
|
||||
).json()
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||
)
|
||||
with pytest.raises(Unauthorized):
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||
)
|
||||
with pytest.raises(ResponseNotOK):
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(content="Invalid json"),
|
||||
)
|
||||
|
||||
|
||||
def test_product(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
assert (
|
||||
redfish_cli.api.product(secrets["server"])
|
||||
== "Integrated Dell Remote Access Controller"
|
||||
)
|
||||
|
||||
|
||||
def test_response_not_ok():
|
||||
try:
|
||||
raise ResponseNotOK
|
||||
except ResponseNotOK as exc:
|
||||
assert exc.response is None
|
||||
|
||||
|
||||
def test_service_tag(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
assert "JYYZY42" in redfish_cli.api.service_tag(secrets["server"])
|
||||
|
||||
def mock_get_hp(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict["Oem"] = {"HPE": {}}
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get_hp)
|
||||
with pytest.raises(redfish_cli.api.exceptions.DellOnly):
|
||||
assert "JYYZY42" in redfish_cli.api.service_tag(secrets["server"])
|
||||
|
||||
|
||||
def test_system_details(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("system_details.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
assert (
|
||||
"/redfish/v1/Systems/System.Embedded.1"
|
||||
== redfish_cli.api.systems.system_details(
|
||||
secrets["server"],
|
||||
secrets["username"],
|
||||
secrets["password"],
|
||||
"System.Embedded.1",
|
||||
)["@odata.id"]
|
||||
)
|
||||
|
||||
|
||||
def test_unauthorized(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
return MockResponse(status_code=401, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
secrets.update({"url": "/"})
|
||||
|
||||
with pytest.raises(redfish_cli.api.exceptions.Unauthorized):
|
||||
_ = redfish_cli.api.utils.get(**secrets)
|
||||
|
||||
|
||||
def test_version(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
assert redfish_cli.api.redfish_version(secrets["server"]) == "1.4.0"
|
||||
|
||||
|
||||
def test_manager(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("api_manager.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = argparse.Namespace()
|
||||
args.server = secrets["server"]
|
||||
args.username = secrets["username"]
|
||||
args.password = secrets["password"]
|
||||
args.manager = None
|
||||
|
||||
assert (
|
||||
redfish_cli.api.manager(args)["@odata.id"]
|
||||
== "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||
)
|
||||
|
||||
args = argparse.Namespace()
|
||||
args.server = secrets["server"]
|
||||
args.username = secrets["username"]
|
||||
args.password = secrets["password"]
|
||||
|
||||
assert (
|
||||
redfish_cli.api.manager(args)["@odata.id"]
|
||||
== "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||
)
|
||||
|
||||
|
||||
def test_firmware_version(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("api_manager.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = argparse.Namespace()
|
||||
args.server = secrets["server"]
|
||||
args.username = secrets["username"]
|
||||
args.password = secrets["password"]
|
||||
args.manager = None
|
||||
|
||||
assert redfish_cli.api.firmware_version(args) == 2656565
|
||||
40
tests/api/test_jobs.py
Normal file
40
tests/api/test_jobs.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"""Tests relating to the jobs api"""
|
||||
import requests
|
||||
|
||||
from redfish_cli.api import jobs
|
||||
|
||||
from tests.api import args
|
||||
|
||||
from ..utils import MockResponse, get_test_content
|
||||
|
||||
|
||||
def test_job_details(monkeypatch):
|
||||
"""Test getting job details"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content=get_test_content("api_job_details.json")
|
||||
),
|
||||
)
|
||||
|
||||
_args = args(manager="Manager.1", job_id="JOB12345xdz")
|
||||
|
||||
result = jobs.job_details(_args)
|
||||
assert result["Id"] == "JID_924369311959"
|
||||
|
||||
|
||||
def test_job_list(monkeypatch):
|
||||
"""Test getting job details"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content=get_test_content("jobs_list.json")
|
||||
),
|
||||
)
|
||||
|
||||
_args = args(manager="Manager.1")
|
||||
|
||||
result = jobs.jobs_list(_args)
|
||||
assert result["Members@odata.count"] == 5
|
||||
104
tests/api/test_power.py
Normal file
104
tests/api/test_power.py
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
"""Tests for the power related API functions"""
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from redfish_cli.api import power
|
||||
from redfish_cli.api.exceptions import FailedToSetPowerState
|
||||
from tests.api import args
|
||||
|
||||
from ..utils import get_test_json, MockRedfishResponse, MockResponse
|
||||
|
||||
|
||||
def test_power_state(monkeypatch):
|
||||
"""Test the get power_state API call"""
|
||||
|
||||
def mock_get(*aargs, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("api_power_state.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
_args = args()
|
||||
_args.system = "System.Embedded.1"
|
||||
|
||||
power_state = power.system_power_state(_args)
|
||||
assert power_state == "Off"
|
||||
|
||||
|
||||
def test_power_states_allowed(monkeypatch):
|
||||
"""Test the poert starts allowed API function"""
|
||||
|
||||
def mock_get(*aargs, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("power_states_allowed.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
_args = args()
|
||||
_args.system = "system"
|
||||
|
||||
power_states = power.system_power_states_allowed(_args)
|
||||
assert power_states == [
|
||||
"On",
|
||||
"ForceOff",
|
||||
"ForceRestart",
|
||||
"GracefulShutdown",
|
||||
"PushPowerButton",
|
||||
"Nmi",
|
||||
]
|
||||
|
||||
|
||||
def test_set_power_state(monkeypatch):
|
||||
"""Test the set power state API call"""
|
||||
|
||||
def mock_post(*aargs, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
return MockResponse(content="{}")
|
||||
|
||||
monkeypatch.setattr(requests, "post", mock_post)
|
||||
|
||||
_args = args()
|
||||
_args.system = "System.Embedded.1"
|
||||
_args.power_state = "On"
|
||||
|
||||
result = power.system_set_power_state(_args)
|
||||
assert result == "Powerstate set to On"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||
)
|
||||
with pytest.raises(FailedToSetPowerState):
|
||||
_ = power.system_set_power_state(_args)
|
||||
|
||||
|
||||
def test_system_reset(monkeypatch):
|
||||
"""Test resetting a system"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}"
|
||||
),
|
||||
)
|
||||
|
||||
_args = args(
|
||||
system="System.Embedded.1",
|
||||
)
|
||||
|
||||
result = power.system_reset(_args)
|
||||
assert result == "System reset"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False
|
||||
),
|
||||
)
|
||||
|
||||
with pytest.raises(FailedToSetPowerState):
|
||||
result = power.system_reset(_args)
|
||||
210
tests/api/test_storage.py
Normal file
210
tests/api/test_storage.py
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
"""Tests relating to the storage api"""
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
import redfish_cli
|
||||
from redfish_cli.api import storage
|
||||
from redfish_cli.api.exceptions import ResponseNotOK
|
||||
|
||||
from tests.api import args
|
||||
|
||||
from ..utils import (
|
||||
MockRedfishResponse,
|
||||
MockResponse,
|
||||
get_test_content,
|
||||
get_test_json,
|
||||
)
|
||||
|
||||
|
||||
def test_create_logical_volume(monkeypatch):
|
||||
"""Test creating a logical volume"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"Location": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||
|
||||
_args = args(
|
||||
raid_level="0",
|
||||
size=None,
|
||||
stripe_size=None,
|
||||
name="test",
|
||||
secure=None,
|
||||
disk_cache_policy=None,
|
||||
read_cache_policy=None,
|
||||
write_cache_policy=None,
|
||||
disk=["one"],
|
||||
system="System.Embedded.1",
|
||||
controller="Raid-Controller-1",
|
||||
)
|
||||
|
||||
result = storage.create_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
monkeypatch.setattr(
|
||||
redfish_cli.api, "firmware_version", lambda args: 445445445
|
||||
)
|
||||
result = storage.create_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
# Test setting size
|
||||
_args.size = 300000000
|
||||
result = storage.create_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
# Test setting stripe_size
|
||||
_args.stripe_size = 3000
|
||||
result = storage.create_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
# Test setting other parameters
|
||||
_args.secure = "Something"
|
||||
_args.disk_cache_policy = "Something"
|
||||
_args.read_cache_policy = "Something"
|
||||
_args.write_cache_policy = "Something"
|
||||
result = storage.create_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"NoLocation": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
|
||||
with pytest.raises(redfish_cli.api.exceptions.FailedToGetJobID):
|
||||
result = storage.create_logical_volume(_args)
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False, content="{}", headers={"NoLocation": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
redfish_cli.api.exceptions.LogicalVolumeCreationFailure
|
||||
):
|
||||
result = storage.create_logical_volume(_args)
|
||||
|
||||
_args.raid_level = "77"
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"NoLocation": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
|
||||
with pytest.raises(redfish_cli.api.exceptions.InvalidRaidLevel):
|
||||
result = storage.create_logical_volume(_args)
|
||||
|
||||
|
||||
def test_delete_logical_volume(monkeypatch):
|
||||
"""Test deleting a logical volume"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"Location": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
|
||||
_args = args(
|
||||
disk="disk1",
|
||||
verify=None,
|
||||
)
|
||||
|
||||
result = storage.delete_logical_volume(_args)
|
||||
assert result["job_id"] == "JOB12345"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={}
|
||||
),
|
||||
)
|
||||
with pytest.raises(redfish_cli.api.exceptions.FailedToGetJobID):
|
||||
result = storage.delete_logical_volume(_args)
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False
|
||||
),
|
||||
)
|
||||
with pytest.raises(ResponseNotOK):
|
||||
result = storage.delete_logical_volume(_args)
|
||||
|
||||
|
||||
def test_list_logical_volumes(monkeypatch):
|
||||
"""Test the list logical volumes api call"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content=get_test_content("api_list_logical_volumes.json")
|
||||
),
|
||||
)
|
||||
|
||||
_args = args(
|
||||
system="System.Embedded.1",
|
||||
controller="RAID.Slot.6-1",
|
||||
expand=True,
|
||||
)
|
||||
logical_volumes = redfish_cli.api.storage.list_logical_volumes(_args)
|
||||
assert logical_volumes["Name"] == "Volume Collection"
|
||||
|
||||
_args.controller = ""
|
||||
logical_volumes = redfish_cli.api.storage.list_logical_volumes(_args)
|
||||
assert logical_volumes["Name"] == "Volume Collection"
|
||||
|
||||
|
||||
def test_list_storage_controllers(monkeypatch):
|
||||
"""Test the list storage controllers api call"""
|
||||
|
||||
def mock_get(*aargs, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json(
|
||||
"api_list_storage_controllers.json"
|
||||
)
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
_args = args(system="System.Embedded.1")
|
||||
storage_controllers = redfish_cli.api.storage.list_storage_controllers(
|
||||
_args
|
||||
)
|
||||
assert storage_controllers["Name"] == "Storage Collection"
|
||||
|
||||
|
||||
def test_logical_volume_details(monkeypatch):
|
||||
"""Test the logical volume details API call"""
|
||||
|
||||
def mock_get(*aargs, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json(
|
||||
"api_logical_volume_details.json"
|
||||
)
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
_args = args(
|
||||
drive="Disk.Virtual.0:RAID.Slot.6-1", drive_index="0", system="system"
|
||||
)
|
||||
|
||||
logical_volume_details = redfish_cli.api.storage.logical_volume_details(
|
||||
_args
|
||||
)
|
||||
assert logical_volume_details["Name"] == "os"
|
||||
105
tests/api/test_utils.py
Normal file
105
tests/api/test_utils.py
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
"""
|
||||
Tests of the api
|
||||
"""
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
import requests
|
||||
|
||||
import redfish_cli.api
|
||||
import redfish_cli.api.storage
|
||||
import redfish_cli.api.systems
|
||||
from redfish_cli.api.exceptions import (
|
||||
ResponseNotOK,
|
||||
Unauthorized,
|
||||
)
|
||||
|
||||
from ..utils import MockResponse
|
||||
from ..api import args
|
||||
|
||||
|
||||
# pylint: disable=missing-function-docstring,redefined-outer-name
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def secrets():
|
||||
return {"server": "idrac-01", "username": "root", "password": "secrete"}
|
||||
|
||||
|
||||
def test_post(monkeypatch, secrets):
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
_json = {"@odata.id": "dummy"}
|
||||
return MockResponse(content=json.dumps(_json))
|
||||
|
||||
monkeypatch.setattr(requests, "post", mock_get)
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
assert (
|
||||
"@odata.id"
|
||||
in redfish_cli.api.utils.post(
|
||||
secrets["server"], "", username="test", password="test"
|
||||
).json()
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||
)
|
||||
with pytest.raises(Unauthorized):
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||
)
|
||||
with pytest.raises(ResponseNotOK):
|
||||
_ = redfish_cli.api.utils.post(secrets["server"], "")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(content="Invalid json"),
|
||||
)
|
||||
|
||||
|
||||
def test_delete(monkeypatch):
|
||||
"""Test getting job details"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="Mock Delete"
|
||||
),
|
||||
)
|
||||
|
||||
_args = args()
|
||||
|
||||
url = redfish_cli.api.redfish_url(
|
||||
_args.server, "Systems/System.Embedded.1/Storage/Volumes/Dummy"
|
||||
)
|
||||
|
||||
_args.url = url
|
||||
|
||||
result = redfish_cli.api.utils.delete(
|
||||
_args.server,
|
||||
_args.url,
|
||||
_args.username,
|
||||
_args.password,
|
||||
)
|
||||
assert result.content == "Mock Delete"
|
||||
|
||||
with pytest.raises(ResponseNotOK):
|
||||
# pylint: disable=line-too-long
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False
|
||||
),
|
||||
)
|
||||
|
||||
result = redfish_cli.api.utils.delete(
|
||||
_args.server,
|
||||
_args.url,
|
||||
_args.username,
|
||||
_args.password,
|
||||
)
|
||||
0
tests/cli/__init__.py
Normal file
0
tests/cli/__init__.py
Normal file
79
tests/cli/test_chassis.py
Normal file
79
tests/cli/test_chassis.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
"""Test for the cli componenets"""
|
||||
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
import redfish_cli.cli
|
||||
from redfish_cli import api
|
||||
from redfish_cli.api import storage
|
||||
|
||||
|
||||
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||
|
||||
from .test_cli import secrets
|
||||
|
||||
|
||||
def test_chassis(capsys, monkeypatch, secrets):
|
||||
"""Test the cli chassis command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("cli_chassis.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"chassis",
|
||||
"-p",
|
||||
secrets["password"],
|
||||
"-u",
|
||||
secrets["username"],
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.chassis(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["@odata.id"] == "/redfish/v1/Chassis/System.Embedded.1"
|
||||
|
||||
|
||||
def test_get_chassis_details(capsys, monkeypatch):
|
||||
"""Test the cli chassis-details command"""
|
||||
_json = get_test_json("cli_chassis_details.json")
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"chassis",
|
||||
"--username",
|
||||
"root",
|
||||
"-p",
|
||||
"password",
|
||||
"show",
|
||||
"-c",
|
||||
"System.Embedded.1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
# captured = capsys.readouterr()
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result["Name"] == "Computer System Chassis"
|
||||
307
tests/cli/test_cli.py
Normal file
307
tests/cli/test_cli.py
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
"""Test for the cli componenets"""
|
||||
import argparse
|
||||
import json
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
import redfish_cli.cli
|
||||
import redfish_cli.api
|
||||
from redfish_cli.cli.parsers.utils import EnvDefault
|
||||
|
||||
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
|
||||
################################################################################
|
||||
### Look at moving this into a shared file so we don't also define it in api
|
||||
@pytest.fixture
|
||||
def secrets():
|
||||
"""
|
||||
Secrets for use as a pytest fiixture. There aren't actually any secrets
|
||||
here because everything is mocked now, but we still need some defaults when
|
||||
testing the cli.
|
||||
"""
|
||||
with open(
|
||||
os.path.join(os.path.dirname(__file__), "../test_secrets.json"),
|
||||
encoding="utf-8",
|
||||
) as secrets_file:
|
||||
secrets = json.loads(" ".join(secrets_file.readlines()))
|
||||
return secrets
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
|
||||
def test_base_command(capsys, monkeypatch, secrets):
|
||||
"""Test the base cli command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("cli_base_command.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["Name"] == "Root Service"
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
["-s", secrets["server"], "-f", "json", "version"]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result == "1.4.0"
|
||||
|
||||
|
||||
def test_get(capsys, monkeypatch, secrets):
|
||||
"""Test the cli get command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("cli_get.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"--debug",
|
||||
"get",
|
||||
"-p",
|
||||
"password",
|
||||
"-u",
|
||||
"username",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["Name"] == "Root Service"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "get", lambda *args, **kwargs: MockResponse(status_code=401)
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"get",
|
||||
"-p",
|
||||
"password",
|
||||
"-u",
|
||||
"username",
|
||||
"--expand",
|
||||
]
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
except SystemExit:
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
assert result == "This url requires authentication\n\n"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content='"Invalid url"'
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == '"Invalid url"\n'
|
||||
|
||||
|
||||
def test_error():
|
||||
"""Test the cli error function"""
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
redfish_cli.cli.utils.error("This is an error")
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
redfish_cli.cli.utils.error("This is an error", output_format="json")
|
||||
|
||||
|
||||
def test_parser():
|
||||
"""Test the cli parse_args function"""
|
||||
args = redfish_cli.cli.parse_args(["-s", "xxxx", "version"])
|
||||
assert args.server == "xxxx"
|
||||
assert args.format == "json"
|
||||
assert args.func.__name__ == "version"
|
||||
|
||||
|
||||
def test_add_subparser():
|
||||
"""Test a subparser with no args"""
|
||||
parser = argparse.ArgumentParser(description="Test parser")
|
||||
|
||||
subparsers = parser.add_subparsers()
|
||||
redfish_cli.cli.parsers.utils.add_subparser(
|
||||
subparsers, "Dummy", arguments=None
|
||||
)
|
||||
|
||||
|
||||
def test_product(capsys, monkeypatch):
|
||||
"""Test the product cli command"""
|
||||
_json = {"Product": "Integrated Dell Remote Access Controller"}
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"product",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result == "Integrated Dell Remote Access Controller"
|
||||
|
||||
|
||||
def test_redfish():
|
||||
"""Test the base redfish command"""
|
||||
with pytest.raises(SystemExit):
|
||||
redfish_cli.cli.redfish()
|
||||
|
||||
|
||||
def test_service_tag(capsys, monkeypatch, secrets):
|
||||
"""Test the service-tag cli command"""
|
||||
_json = get_test_json("cli_service_tag.json")
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = _json
|
||||
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"service-tag",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.service_tag(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result == '"JYYZY42"\n'
|
||||
|
||||
_json["Oem"]["NotDell"] = _json["Oem"]["Dell"]
|
||||
del _json["Oem"]["Dell"]
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"service-tag",
|
||||
]
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
redfish_cli.cli.service_tag(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
|
||||
assert result == "Service tags are only available for Dell iDRACs\n"
|
||||
|
||||
|
||||
def test_version(capsys, monkeypatch, secrets):
|
||||
"""Test the version command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("cli_version.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"version",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.version(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result == '"1.4.0"\n'
|
||||
|
||||
|
||||
def test_write():
|
||||
"""Test the cli write function"""
|
||||
redfish_cli.cli.utils.write_output("This is not an error")
|
||||
|
||||
redfish_cli.cli.utils.write_output(
|
||||
"This is not an error", output_format="json"
|
||||
)
|
||||
|
||||
|
||||
def test_env_var():
|
||||
"""Test the envvar action parser action"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Interact with servers via RedFish. Only Dells supported at the moment"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--server",
|
||||
required=True,
|
||||
dest="server",
|
||||
action=EnvDefault,
|
||||
default=os.environ.get("RF_USERNAME"),
|
||||
envvar="USER",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-u",
|
||||
"--user",
|
||||
required=True,
|
||||
dest="server",
|
||||
help="Help",
|
||||
action=EnvDefault,
|
||||
envvar="USER",
|
||||
)
|
||||
204
tests/cli/test_jobs.py
Normal file
204
tests/cli/test_jobs.py
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
"""Test for the cli componenets"""
|
||||
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||
|
||||
import json
|
||||
from unittest import mock
|
||||
|
||||
import requests
|
||||
|
||||
from redfish_cli.cli import parse_args
|
||||
from redfish_cli.cli.jobs import jobs_list, job_details, watch_job
|
||||
|
||||
from ..utils import get_test_content, MockResponse, MockWatchedJobResponse
|
||||
|
||||
|
||||
def test_list_jobs(capsys, monkeypatch):
|
||||
"""Test the list jobs command"""
|
||||
# pylint: disable=fixme, unused-argument, unused-variable
|
||||
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"list",
|
||||
"--all",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content=get_test_content("jobs_list.json")
|
||||
),
|
||||
)
|
||||
|
||||
jobs_list(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert 5 == json.loads(result)["Members@odata.count"]
|
||||
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
jobs_list(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert 0 == json.loads(result)["Members@odata.count"]
|
||||
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"text",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"list",
|
||||
"--all",
|
||||
]
|
||||
)
|
||||
jobs_list(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert (
|
||||
"JID_878659984891 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||
"JID_878682850779 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||
"JID_920326518992 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||
"JID_923469653542 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||
"JID_924369311959 RAIDConfiguration 100 Config:RAID:RAID.Slot.6-1 Completed\n"
|
||||
) == result
|
||||
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"table",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"list",
|
||||
"--all",
|
||||
]
|
||||
)
|
||||
jobs_list(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
expected = get_test_content("job_list_table.txt")
|
||||
assert expected == result
|
||||
|
||||
|
||||
def test_job_details(capsys, monkeypatch):
|
||||
"""Test the list jobs command"""
|
||||
# pylint: disable=fixme, unused-argument, unused-variable
|
||||
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"show",
|
||||
"-j",
|
||||
"JID_924369311959",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content=get_test_content("api_job_details.json")
|
||||
),
|
||||
)
|
||||
|
||||
job_details(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert "2023-08-20T05:59:24" == json.loads(result)["CompletionTime"]
|
||||
|
||||
|
||||
def test_watch_jobs(capsys, monkeypatch):
|
||||
"""Test the list jobs command"""
|
||||
# pylint: disable=fixme, unused-argument, unused-variable
|
||||
|
||||
response = MockWatchedJobResponse()
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"show",
|
||||
"-j",
|
||||
"JID_924369311959",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: response,
|
||||
)
|
||||
|
||||
watch_job(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert '"PercentComplete": 100,' in result
|
||||
|
||||
response.accessed = 0
|
||||
args = parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"text",
|
||||
"jobs",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"show",
|
||||
"-j",
|
||||
"JID_924369311959",
|
||||
]
|
||||
)
|
||||
watch_job(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert "Completed 100\n" in result
|
||||
|
||||
# Test that watch jobs catches a KeyboardInterrup and exits cleanly
|
||||
with mock.patch("requests.get", side_effect=KeyboardInterrupt):
|
||||
watch_job(args=args)
|
||||
255
tests/cli/test_power.py
Normal file
255
tests/cli/test_power.py
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
"""Test for the cli componenets"""
|
||||
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
import redfish_cli.cli
|
||||
import redfish_cli.cli.power
|
||||
from redfish_cli import api
|
||||
|
||||
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||
|
||||
|
||||
def test_set_power_state(capsys, monkeypatch):
|
||||
"""Test the set-power-state cli command"""
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(content="{}", status_code=200),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"set",
|
||||
"On",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.set_power_state(args=args)
|
||||
out = capsys.readouterr().out
|
||||
result = out
|
||||
assert result == '"Powerstate set to On"\n'
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests, "post", lambda *args, **kwargs: MockResponse(ok=False)
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.power.set_power_state(args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == "Failed to set powerstate to On\n"
|
||||
|
||||
|
||||
def test_power_state(capsys, monkeypatch):
|
||||
"""Test the get power state cli command"""
|
||||
_json = {"PowerState": "Off"}
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"get",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.power_state(args=args)
|
||||
out = capsys.readouterr().out
|
||||
result = json.loads(out)
|
||||
assert result == "Off"
|
||||
|
||||
|
||||
def test_list_power_states(capsys, monkeypatch):
|
||||
"""Test the product cli command"""
|
||||
# pylint: disable=duplicate-code
|
||||
|
||||
# This code is similar to the direct api test. Disable the pylint warning.
|
||||
|
||||
_json = get_test_json("power_states_allowed.json")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.power_states(args)
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result == [
|
||||
"On",
|
||||
"ForceOff",
|
||||
"ForceRestart",
|
||||
"GracefulShutdown",
|
||||
"PushPowerButton",
|
||||
"Nmi",
|
||||
]
|
||||
|
||||
|
||||
def test_system_reset(capsys, monkeypatch):
|
||||
"""Test resetting a system"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}"
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"reset",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.reset_system(args=args)
|
||||
out = capsys.readouterr().out
|
||||
result = json.loads(out)
|
||||
assert result == "System reset"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content="Failed to set power state"
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.power.reset_system(args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == "Failed to set power state\n"
|
||||
|
||||
|
||||
def test_power_on(capsys, monkeypatch):
|
||||
"""Test resetting a system"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}"
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"on",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.power_on(args=args)
|
||||
out = capsys.readouterr().out
|
||||
result = json.loads(out)
|
||||
assert result == "System.Embedded.1 powered on"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content="Failed to power on"
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.power.power_on(args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == "Failed to power on\n"
|
||||
|
||||
|
||||
def test_power_off(capsys, monkeypatch):
|
||||
"""Test resetting a system"""
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}"
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"power",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"off",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.power.power_off(args=args)
|
||||
out = capsys.readouterr().out
|
||||
result = json.loads(out)
|
||||
assert result == "System.Embedded.1 powered off"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content="Failed to power off"
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.power.power_off(args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == "Failed to power off\n"
|
||||
631
tests/cli/test_storage.py
Normal file
631
tests/cli/test_storage.py
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
"""Test for the cli componenets"""
|
||||
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
import redfish_cli.cli
|
||||
from redfish_cli import api
|
||||
from redfish_cli.api import storage
|
||||
from redfish_cli.api.exceptions import LogicalVolumeCreationFailure
|
||||
|
||||
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||
|
||||
from .test_cli import secrets
|
||||
|
||||
|
||||
def test_create_logical_volume(capsys, monkeypatch):
|
||||
"""Test the create-logical-volume command"""
|
||||
# pylint: disable=fixme, unused-argument, unused-variable
|
||||
# TODO: Write actual tests when the create-logical-volume code is fixed
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"create",
|
||||
"-c",
|
||||
"controller",
|
||||
"-d",
|
||||
"disk",
|
||||
"-r",
|
||||
"0",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"Location": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||
|
||||
redfish_cli.cli.create_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert "JOB12345" in result
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
# pylint: disable=line-too-long
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"post",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False, content='{"msg":"and error occurred"}'
|
||||
),
|
||||
)
|
||||
redfish_cli.cli.create_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
assert "JOB12345" in result
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
args.raid_level = "zz"
|
||||
redfish_cli.cli.create_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
assert (
|
||||
"zz is not a valid raid level. Valid choices are 0,1,5,10,50"
|
||||
in result
|
||||
)
|
||||
|
||||
|
||||
def test_delete_logical_volume(capsys, monkeypatch):
|
||||
"""Test the create-logical-volume command"""
|
||||
# pylint: disable=fixme, unused-argument, unused-variable
|
||||
# TODO: Write actual tests when the create-logical-volume code is fixed
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"create",
|
||||
"-c",
|
||||
"controller",
|
||||
"-d",
|
||||
"disk",
|
||||
"-r",
|
||||
"0",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
content="{}", headers={"Location": "/JOB12345"}
|
||||
),
|
||||
)
|
||||
monkeypatch.setattr(redfish_cli.api, "firmware_version", lambda args: 2)
|
||||
|
||||
redfish_cli.cli.delete_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert "JOB12345" in result
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
# pylint: disable=line-too-long
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"delete",
|
||||
lambda args, auth=None, verify=None, data=None, headers=None, timeout=None: MockResponse(
|
||||
ok=False, content='{"msg":"and error occurred"}'
|
||||
),
|
||||
)
|
||||
redfish_cli.cli.delete_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
assert "JOB12345" in result
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
args.raid_level = "zz"
|
||||
redfish_cli.cli.create_logical_volume(args=args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.err
|
||||
assert (
|
||||
"zz is not a valid raid level. Valid choices are 0,1,5,10,50"
|
||||
in result
|
||||
)
|
||||
|
||||
|
||||
def test_show_logical_volume(capsys, monkeypatch):
|
||||
"""Test the cli logical-volume command"""
|
||||
_json = get_test_json("cli_logical_volume.json")
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"show",
|
||||
"-d",
|
||||
"Disk.Virtual.0:RAID.Slot.6-1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"show",
|
||||
]
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
redfish_cli.api.storage,
|
||||
"list_storage_controllers",
|
||||
lambda *args, **kwargs: {
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
redfish_cli.api.storage,
|
||||
"list_logical_volumes",
|
||||
lambda *args, **kwargs: {
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/"
|
||||
"Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||
"/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"show",
|
||||
"-c",
|
||||
"RAID.Slot.6-1",
|
||||
]
|
||||
)
|
||||
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result["Id"] == "Disk.Virtual.0:RAID.Slot.6-1"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content='"Invalid logical volume"'
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == '"Invalid logical volume"\n'
|
||||
|
||||
|
||||
def test_list_logical_volumes(capsys, monkeypatch):
|
||||
"""Test the cli logical-volumes command"""
|
||||
_json = get_test_json("cli_logical_volumes.json")
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
content=json.dumps(_json), status_code=200
|
||||
),
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
"172.1.0.1",
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"password123",
|
||||
"logical",
|
||||
"list",
|
||||
"-c",
|
||||
"RAID.Slot.6-1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
# err_out = capsys.readouterr().out
|
||||
result = json.loads(capsys.readouterr().out)
|
||||
assert result["Name"] == "Volume Collection"
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(ok=False, content='"Invalid"'),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == '"Invalid"\n'
|
||||
|
||||
|
||||
def test_show_phsyical_volume(capsys, monkeypatch, secrets):
|
||||
"""Test the physical_voume cli command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("physical_volume.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
monkeypatch.setattr(
|
||||
storage,
|
||||
"list_storage_controllers",
|
||||
lambda *args, **kwargs: {"Members": [{"@odata.id": ""}]},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
storage,
|
||||
"list_physical_volumes",
|
||||
lambda *args, **kwargs: [{"drive": "Dummy"}],
|
||||
)
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"physical",
|
||||
"show",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.physical_volume(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["CapacityBytes"] == 299439751168
|
||||
|
||||
|
||||
def test_list_phsyical_volumes(capsys, monkeypatch, secrets):
|
||||
"""Test the physical_voume cli command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("physical_volumes.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
monkeypatch.setattr(
|
||||
storage,
|
||||
"list_storage_controllers",
|
||||
lambda *args, **kwargs: {"Members": [{"@odata.id": ""}]},
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"physical",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.physical_volumes(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert (
|
||||
result[0]["drive"] == "Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"text",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"physical",
|
||||
"list",
|
||||
"-c",
|
||||
"Storage.Controller.1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.physical_volumes(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert (
|
||||
"System.Embedded.1 Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1\n"
|
||||
in result
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"table",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"physical",
|
||||
"list",
|
||||
"-c",
|
||||
"Storage.Controller.1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.physical_volumes(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result.startswith("+-------------------+-------------------------")
|
||||
assert "| Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1 |" in result
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-v",
|
||||
"-f",
|
||||
"table",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"physical",
|
||||
"list",
|
||||
"-c",
|
||||
"Storage.Controller.1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.physical_volumes(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result.startswith("+-------------------+-------------------------")
|
||||
assert "| System.Embedded.1 | Disk.Bay.0:Enclosure.Internal.0-" in result
|
||||
|
||||
|
||||
def test_storage_controller(capsys, monkeypatch, secrets):
|
||||
"""Test the storage-controller cli command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("storage_controller.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
monkeypatch.setattr(
|
||||
api.storage,
|
||||
"list_storage_controllers",
|
||||
lambda *args, **kwargs: {"Members": [{"@odata.id": "/"}]},
|
||||
)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"show",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controller(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["Id"] == "RAID.Slot.6-1"
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"text",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"show",
|
||||
"-c",
|
||||
"RAID.Slot.6-1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controller(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
# Currently returns JSON(ish) will need to update test later
|
||||
assert "'Id': 'RAID.Slot.6-1'" in result
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"table",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"show",
|
||||
"-c",
|
||||
"RAID.Slot.6-1",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controller(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
# Currently returns JSON(ish) will need to update test later
|
||||
assert "'Id': 'RAID.Slot.6-1'" in result
|
||||
|
||||
monkeypatch.setattr(
|
||||
requests,
|
||||
"get",
|
||||
lambda *args, **kwargs: MockResponse(
|
||||
ok=False, content='"Invalid storage controller"'
|
||||
),
|
||||
)
|
||||
try:
|
||||
redfish_cli.cli.redfish(args=args)
|
||||
except SystemExit:
|
||||
result = capsys.readouterr().err
|
||||
assert result == '"Invalid storage controller"\n'
|
||||
|
||||
|
||||
def test_list_storage_controllers(capsys, monkeypatch, secrets):
|
||||
"""Test the storage-controllers cli command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("cli_storage_controllers.json")
|
||||
return MockResponse(status_code=200, content=mock_redfish.text)
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controllers(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result == ["RAID.Slot.6-1"]
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"text",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controllers(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result == "RAID.Slot.6-1\n"
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"table",
|
||||
"storage",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"controllers",
|
||||
"list",
|
||||
]
|
||||
)
|
||||
redfish_cli.cli.storage_controllers(args)
|
||||
captured = capsys.readouterr()
|
||||
result = captured.out
|
||||
assert result == (
|
||||
"+---------------+\n| Controller |\n+===============+\n| "
|
||||
"RAID.Slot.6-1 |\n+---------------+\n"
|
||||
)
|
||||
43
tests/cli/test_system.py
Normal file
43
tests/cli/test_system.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""Test for the system cli components"""
|
||||
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
import redfish_cli.cli
|
||||
|
||||
from ..utils import get_test_json, MockResponse, MockRedfishResponse
|
||||
|
||||
from .test_cli import secrets
|
||||
|
||||
|
||||
def test_system_details(capsys, monkeypatch, secrets):
|
||||
"""Test system-details command"""
|
||||
|
||||
def mock_get(*args, **kwargs):
|
||||
# pylint: disable=unused-argument
|
||||
mock_redfish = MockRedfishResponse()
|
||||
mock_redfish.json_dict = get_test_json("system_details.json")
|
||||
return MockResponse(content=mock_redfish.text)
|
||||
|
||||
args = redfish_cli.cli.parse_args(
|
||||
[
|
||||
"-s",
|
||||
secrets["server"],
|
||||
"-f",
|
||||
"json",
|
||||
"system",
|
||||
"-u",
|
||||
"root",
|
||||
"-p",
|
||||
"dummy",
|
||||
"show",
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
redfish_cli.cli.system_details(args)
|
||||
captured = capsys.readouterr()
|
||||
result = json.loads(captured.out)
|
||||
assert result["@odata.id"] == "/redfish/v1/Systems/System.Embedded.1"
|
||||
|
||||
monkeypatch.setattr(requests, "get", mock_get)
|
||||
16
tests/redfish_json/api_chassis.json
Normal file
16
tests/redfish_json/api_chassis.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ChassisCollection.ChassisCollection",
|
||||
"@odata.id": "/redfish/v1/Chassis/",
|
||||
"@odata.type": "#ChassisCollection.ChassisCollection",
|
||||
"Description": "Collection of Chassis",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 2,
|
||||
"Name": "Chassis Collection"
|
||||
}
|
||||
111
tests/redfish_json/api_chassis_details.json
Normal file
111
tests/redfish_json/api_chassis_details.json
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||
"Actions": {
|
||||
"#Chassis.Reset": {
|
||||
"ResetType@Redfish.AllowableValues": [
|
||||
"On",
|
||||
"ForceOff"
|
||||
],
|
||||
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||
}
|
||||
},
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"AssetTag": "",
|
||||
"ChassisType": "StandAlone",
|
||||
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||
"Id": "System.Embedded.1",
|
||||
"IndicatorLED": "Off",
|
||||
"Links": {
|
||||
"ComputerSystems": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ComputerSystems@odata.count": 1,
|
||||
"Contains": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Contains@odata.count": 1,
|
||||
"CooledBy": [],
|
||||
"CooledBy@odata.count": 0,
|
||||
"Drives": [],
|
||||
"Drives@odata.count": 0,
|
||||
"ManagedBy": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ManagedBy@odata.count": 1,
|
||||
"ManagersInChassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ManagersInChassis@odata.count": 1,
|
||||
"PCIeDevices": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||
}
|
||||
],
|
||||
"PCIeDevices@odata.count": 9,
|
||||
"PoweredBy": [],
|
||||
"PoweredBy@odata.count": 0,
|
||||
"Storage": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Storage@odata.count": 1
|
||||
},
|
||||
"Manufacturer": "Dell Inc.",
|
||||
"Model": "PowerEdge T320",
|
||||
"Name": "Computer System Chassis",
|
||||
"NetworkAdapters": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||
},
|
||||
"PartNumber": "0MK701A02",
|
||||
"Power": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"
|
||||
},
|
||||
"PowerState": "Off",
|
||||
"SKU": "JYYZY42",
|
||||
"SerialNumber": "CN747515150714",
|
||||
"Status": {
|
||||
"Health": "OK",
|
||||
"HealthRollup": "OK",
|
||||
"State": "Enabled"
|
||||
},
|
||||
"Thermal": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||
}
|
||||
}
|
||||
18
tests/redfish_json/api_job_details.json
Normal file
18
tests/redfish_json/api_job_details.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_924369311959",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-08-20T05:59:24",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_924369311959",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
}
|
||||
16
tests/redfish_json/api_list_logical_volumes.json
Normal file
16
tests/redfish_json/api_list_logical_volumes.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#VolumeCollection.VolumeCollection",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes",
|
||||
"@odata.type": "#VolumeCollection.VolumeCollection",
|
||||
"Description": "Collection Of Volume",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 2,
|
||||
"Name": "Volume Collection"
|
||||
}
|
||||
13
tests/redfish_json/api_list_storage_controllers.json
Normal file
13
tests/redfish_json/api_list_storage_controllers.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#StorageCollection.StorageCollection",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage",
|
||||
"@odata.type": "#StorageCollection.StorageCollection",
|
||||
"Description": "Collection Of Storage entities",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 1,
|
||||
"Name": "Storage Collection"
|
||||
}
|
||||
54
tests/redfish_json/api_logical_volume_details.json
Normal file
54
tests/redfish_json/api_logical_volume_details.json
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"@Redfish.Settings": {
|
||||
"@odata.context": "/redfish/v1/$metadata#Settings.Settings",
|
||||
"@odata.type": "#Settings.v1_1_0.Settings",
|
||||
"SettingsObject": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Settings"
|
||||
},
|
||||
"SupportedApplyTimes": [
|
||||
"Immediate",
|
||||
"OnReset",
|
||||
"AtMaintenanceWindowStart",
|
||||
"InMaintenanceWindowOnReset"
|
||||
]
|
||||
},
|
||||
"@odata.context": "/redfish/v1/$metadata#Volume.Volume",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1",
|
||||
"@odata.type": "#Volume.v1_0_3.Volume",
|
||||
"Actions": {
|
||||
"#Volume.CheckConsistency": {
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.CheckConsistency"
|
||||
},
|
||||
"#Volume.Initialize": {
|
||||
"InitializeType@Redfish.AllowableValues": ["Fast", "Slow"],
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.Initialize"
|
||||
}
|
||||
},
|
||||
"BlockSizeBytes": 512,
|
||||
"CapacityBytes": 299439751168,
|
||||
"Description": "os",
|
||||
"Encrypted": false,
|
||||
"EncryptionTypes": ["NativeDriveEncryption"],
|
||||
"Id": "Disk.Virtual.0:RAID.Slot.6-1",
|
||||
"Identifiers": [],
|
||||
"Links": {
|
||||
"Drives": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Drives@odata.count": 2
|
||||
},
|
||||
"Name": "os",
|
||||
"Operations": [],
|
||||
"OptimumIOSizeBytes": 65536,
|
||||
"Status": {
|
||||
"Health": "OK",
|
||||
"HealthRollup": "OK",
|
||||
"State": "Enabled"
|
||||
},
|
||||
"VolumeType": "Mirrored"
|
||||
}
|
||||
217
tests/redfish_json/api_manager.json
Normal file
217
tests/redfish_json/api_manager.json
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Manager.Manager",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1",
|
||||
"@odata.type": "#Manager.v1_3_3.Manager",
|
||||
"Actions": {
|
||||
"#Manager.Reset": {
|
||||
"ResetType@Redfish.AllowableValues": [
|
||||
"GracefulRestart"
|
||||
],
|
||||
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Manager.Reset"
|
||||
},
|
||||
"Oem": {
|
||||
"OemManager.v1_1_0#OemManager.ExportSystemConfiguration": {
|
||||
"ExportFormat@Redfish.AllowableValues": [
|
||||
"XML",
|
||||
"JSON"
|
||||
],
|
||||
"ExportUse@Redfish.AllowableValues": [
|
||||
"Default",
|
||||
"Clone",
|
||||
"Replace"
|
||||
],
|
||||
"IncludeInExport@Redfish.AllowableValues": [
|
||||
"Default",
|
||||
"IncludeReadOnly",
|
||||
"IncludePasswordHashValues",
|
||||
"IncludeReadOnly,IncludePasswordHashValues"
|
||||
],
|
||||
"ShareParameters": {
|
||||
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxySupport@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"EnabledProxyDefault",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxyType@Redfish.AllowableValues": [
|
||||
"HTTP",
|
||||
"SOCKS4"
|
||||
],
|
||||
"ShareType@Redfish.AllowableValues": [
|
||||
"LOCAL",
|
||||
"NFS",
|
||||
"CIFS",
|
||||
"HTTP",
|
||||
"HTTPS"
|
||||
],
|
||||
"Target@Redfish.AllowableValues": [
|
||||
"ALL",
|
||||
"IDRAC",
|
||||
"BIOS",
|
||||
"NIC",
|
||||
"RAID"
|
||||
]
|
||||
},
|
||||
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ExportSystemConfiguration"
|
||||
},
|
||||
"OemManager.v1_1_0#OemManager.ImportSystemConfiguration": {
|
||||
"HostPowerState@Redfish.AllowableValues": [
|
||||
"On",
|
||||
"Off"
|
||||
],
|
||||
"ImportSystemConfiguration@Redfish.AllowableValues": [
|
||||
"TimeToWait",
|
||||
"ImportBuffer"
|
||||
],
|
||||
"ShareParameters": {
|
||||
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxySupport@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"EnabledProxyDefault",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxyType@Redfish.AllowableValues": [
|
||||
"HTTP",
|
||||
"SOCKS4"
|
||||
],
|
||||
"ShareType@Redfish.AllowableValues": [
|
||||
"LOCAL",
|
||||
"NFS",
|
||||
"CIFS",
|
||||
"HTTP",
|
||||
"HTTPS"
|
||||
],
|
||||
"Target@Redfish.AllowableValues": [
|
||||
"ALL",
|
||||
"IDRAC",
|
||||
"BIOS",
|
||||
"NIC",
|
||||
"RAID"
|
||||
]
|
||||
},
|
||||
"ShutdownType@Redfish.AllowableValues": [
|
||||
"Graceful",
|
||||
"Forced",
|
||||
"NoReboot"
|
||||
],
|
||||
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfiguration"
|
||||
},
|
||||
"OemManager.v1_1_0#OemManager.ImportSystemConfigurationPreview": {
|
||||
"ImportSystemConfigurationPreview@Redfish.AllowableValues": [
|
||||
"ImportBuffer"
|
||||
],
|
||||
"ShareParameters": {
|
||||
"IgnoreCertificateWarning@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxySupport@Redfish.AllowableValues": [
|
||||
"Disabled",
|
||||
"EnabledProxyDefault",
|
||||
"Enabled"
|
||||
],
|
||||
"ProxyType@Redfish.AllowableValues": [
|
||||
"HTTP",
|
||||
"SOCKS4"
|
||||
],
|
||||
"ShareType@Redfish.AllowableValues": [
|
||||
"LOCAL",
|
||||
"NFS",
|
||||
"CIFS",
|
||||
"HTTP",
|
||||
"HTTPS"
|
||||
],
|
||||
"Target@Redfish.AllowableValues": [
|
||||
"ALL"
|
||||
]
|
||||
},
|
||||
"target": "/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemConfigurationPreview"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CommandShell": {
|
||||
"ConnectTypesSupported": [
|
||||
"SSH",
|
||||
"Telnet",
|
||||
"IPMI"
|
||||
],
|
||||
"ConnectTypesSupported@odata.count": 3,
|
||||
"MaxConcurrentSessions": 5,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"DateTime": "2023-08-24T10:23:53-05:00",
|
||||
"DateTimeLocalOffset": "-05:00",
|
||||
"Description": "BMC",
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces"
|
||||
},
|
||||
"FirmwareVersion": "2.65.65.65",
|
||||
"GraphicalConsole": {
|
||||
"ConnectTypesSupported": [
|
||||
"KVMIP"
|
||||
],
|
||||
"ConnectTypesSupported@odata.count": 1,
|
||||
"MaxConcurrentSessions": 6,
|
||||
"ServiceEnabled": true
|
||||
},
|
||||
"HostInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/HostInterfaces"
|
||||
},
|
||||
"Id": "iDRAC.Embedded.1",
|
||||
"Links": {
|
||||
"ManagerForChassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ManagerForChassis@odata.count": 1,
|
||||
"ManagerForServers": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ManagerForServers@odata.count": 1,
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellManager.v1_0_0.DellManager",
|
||||
"Jobs": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"LogServices": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/LogServices"
|
||||
},
|
||||
"ManagerType": "BMC",
|
||||
"Model": "12G Monolithic",
|
||||
"Name": "Manager",
|
||||
"NetworkProtocol": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/NetworkProtocol"
|
||||
},
|
||||
"Redundancy": [],
|
||||
"Redundancy@odata.count": 0,
|
||||
"SerialConsole": {
|
||||
"ConnectTypesSupported": [],
|
||||
"ConnectTypesSupported@odata.count": 0,
|
||||
"MaxConcurrentSessions": 0,
|
||||
"ServiceEnabled": false
|
||||
},
|
||||
"SerialInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/SerialInterfaces"
|
||||
},
|
||||
"Status": {
|
||||
"Health": "OK",
|
||||
"State": "Enabled"
|
||||
},
|
||||
"UUID": "3234594f-c0b7-5180-4a10-00334c4c4544",
|
||||
"VirtualMedia": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia"
|
||||
}
|
||||
}
|
||||
1
tests/redfish_json/api_power_state.json
Normal file
1
tests/redfish_json/api_power_state.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"PowerState":"Off"}
|
||||
43
tests/redfish_json/cli_base_command.json
Normal file
43
tests/redfish_json/cli_base_command.json
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||
"@odata.id": "/redfish/v1",
|
||||
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||
"AccountService": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||
},
|
||||
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Description": "Root Service",
|
||||
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||
"Id": "RootService",
|
||||
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||
"Name": "Root Service",
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||
"IsBranded": 0,
|
||||
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||
"ServiceTag": "JYYZY42"
|
||||
}
|
||||
},
|
||||
"Product": "Integrated Dell Remote Access Controller",
|
||||
"ProtocolFeaturesSupported": {
|
||||
"ExpandQuery": {
|
||||
"ExpandAll": true,
|
||||
"Levels": true,
|
||||
"Links": true,
|
||||
"MaxLevels": 1,
|
||||
"NoLinks": true
|
||||
},
|
||||
"FilterQuery": true,
|
||||
"SelectQuery": true
|
||||
},
|
||||
"RedfishVersion": "1.4.0",
|
||||
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||
}
|
||||
106
tests/redfish_json/cli_chassis.json
Normal file
106
tests/redfish_json/cli_chassis.json
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||
"Actions": {
|
||||
"#Chassis.Reset": {
|
||||
"ResetType@Redfish.AllowableValues": ["On", "ForceOff"],
|
||||
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||
}
|
||||
},
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"AssetTag": "",
|
||||
"ChassisType": "StandAlone",
|
||||
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||
"Id": "System.Embedded.1",
|
||||
"IndicatorLED": "Off",
|
||||
"Links": {
|
||||
"ComputerSystems": [
|
||||
{"@odata.id": "/redfish/v1/Systems/System.Embedded.1"}
|
||||
],
|
||||
"ComputerSystems@odata.count": 1,
|
||||
"Contains": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Contains@odata.count": 1,
|
||||
"CooledBy": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.Sys%201"
|
||||
}
|
||||
],
|
||||
"CooledBy@odata.count": 1,
|
||||
"Drives": [],
|
||||
"Drives@odata.count": 0,
|
||||
"ManagedBy": [
|
||||
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||
],
|
||||
"ManagedBy@odata.count": 1,
|
||||
"ManagersInChassis": [
|
||||
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||
],
|
||||
"ManagersInChassis@odata.count": 1,
|
||||
"PCIeDevices": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||
}
|
||||
],
|
||||
"PCIeDevices@odata.count": 9,
|
||||
"PoweredBy": [],
|
||||
"PoweredBy@odata.count": 0,
|
||||
"Storage": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Storage@odata.count": 1
|
||||
},
|
||||
"Manufacturer": "Dell Inc.",
|
||||
"Model": "PowerEdge T320",
|
||||
"Name": "Computer System Chassis",
|
||||
"NetworkAdapters": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||
},
|
||||
"PartNumber": "0MK701A02",
|
||||
"Power": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"
|
||||
},
|
||||
"PowerState": "On",
|
||||
"SKU": "JYYZY42",
|
||||
"SerialNumber": "CN747515150714",
|
||||
"Status": {
|
||||
"Health": "Warning",
|
||||
"HealthRollup": "Warning",
|
||||
"State": "Enabled"
|
||||
},
|
||||
"Thermal": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||
}
|
||||
}
|
||||
104
tests/redfish_json/cli_chassis_details.json
Normal file
104
tests/redfish_json/cli_chassis_details.json
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Chassis.Chassis",
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1",
|
||||
"@odata.type": "#Chassis.v1_6_0.Chassis",
|
||||
"Actions": {
|
||||
"#Chassis.Reset": {
|
||||
"ResetType@Redfish.AllowableValues": ["On", "ForceOff"],
|
||||
"target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset"
|
||||
}
|
||||
},
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"AssetTag": "",
|
||||
"ChassisType": "StandAlone",
|
||||
"Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.",
|
||||
"Id": "System.Embedded.1",
|
||||
"IndicatorLED": "Off",
|
||||
"Links": {
|
||||
"ComputerSystems": [
|
||||
{"@odata.id": "/redfish/v1/Systems/System.Embedded.1"}
|
||||
],
|
||||
"ComputerSystems@odata.count": 1,
|
||||
"Contains": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Contains@odata.count": 1,
|
||||
"CooledBy": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.Sys%201"
|
||||
}
|
||||
],
|
||||
"CooledBy@odata.count": 1,
|
||||
"Drives": [],
|
||||
"Drives@odata.count": 0,
|
||||
"ManagedBy": [
|
||||
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||
],
|
||||
"ManagedBy@odata.count": 1,
|
||||
"ManagersInChassis": [
|
||||
{"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"}
|
||||
],
|
||||
"ManagersInChassis@odata.count": 1,
|
||||
"PCIeDevices": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||
}
|
||||
],
|
||||
"PCIeDevices@odata.count": 9,
|
||||
"PoweredBy": [],
|
||||
"PoweredBy@odata.count": 0,
|
||||
"Storage": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Storage@odata.count": 1
|
||||
},
|
||||
"Manufacturer": "Dell Inc.",
|
||||
"Model": "PowerEdge T320",
|
||||
"Name": "Computer System Chassis",
|
||||
"NetworkAdapters": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters"
|
||||
},
|
||||
"PartNumber": "0MK701A02",
|
||||
"Power": {"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power"},
|
||||
"PowerState": "On",
|
||||
"SKU": "JYYZY42",
|
||||
"SerialNumber": "CN747515150714",
|
||||
"Status": {
|
||||
"Health": "Warning",
|
||||
"HealthRollup": "Warning",
|
||||
"State": "Enabled"
|
||||
},
|
||||
"Thermal": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal"
|
||||
}
|
||||
}
|
||||
43
tests/redfish_json/cli_get.json
Normal file
43
tests/redfish_json/cli_get.json
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||
"@odata.id": "/redfish/v1",
|
||||
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||
"AccountService": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||
},
|
||||
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Description": "Root Service",
|
||||
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||
"Id": "RootService",
|
||||
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||
"Name": "Root Service",
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||
"IsBranded": 0,
|
||||
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||
"ServiceTag": "JYYZY42"
|
||||
}
|
||||
},
|
||||
"Product": "Integrated Dell Remote Access Controller",
|
||||
"ProtocolFeaturesSupported": {
|
||||
"ExpandQuery": {
|
||||
"ExpandAll": true,
|
||||
"Levels": true,
|
||||
"Links": true,
|
||||
"MaxLevels": 1,
|
||||
"NoLinks": true
|
||||
},
|
||||
"FilterQuery": true,
|
||||
"SelectQuery": true
|
||||
},
|
||||
"RedfishVersion": "1.4.0",
|
||||
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||
}
|
||||
50
tests/redfish_json/cli_logical_volume.json
Normal file
50
tests/redfish_json/cli_logical_volume.json
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"@Redfish.Settings": {
|
||||
"@odata.context": "/redfish/v1/$metadata#Settings.Settings",
|
||||
"@odata.type": "#Settings.v1_1_0.Settings",
|
||||
"SettingsObject": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Settings"
|
||||
},
|
||||
"SupportedApplyTimes": [
|
||||
"Immediate",
|
||||
"OnReset",
|
||||
"AtMaintenanceWindowStart",
|
||||
"InMaintenanceWindowOnReset"
|
||||
]
|
||||
},
|
||||
"@odata.context": "/redfish/v1/$metadata#Volume.Volume",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1",
|
||||
"@odata.type": "#Volume.v1_0_3.Volume",
|
||||
"Actions": {
|
||||
"#Volume.CheckConsistency": {
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.CheckConsistency"
|
||||
},
|
||||
"#Volume.Initialize": {
|
||||
"InitializeType@Redfish.AllowableValues": ["Fast", "Slow"],
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1/Actions/Volume.Initialize"
|
||||
}
|
||||
},
|
||||
"BlockSizeBytes": 512,
|
||||
"CapacityBytes": 299439751168,
|
||||
"Description": "os",
|
||||
"Encrypted": false,
|
||||
"EncryptionTypes": ["NativeDriveEncryption"],
|
||||
"Id": "Disk.Virtual.0:RAID.Slot.6-1",
|
||||
"Identifiers": [],
|
||||
"Links": {
|
||||
"Drives": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Drives@odata.count": 2
|
||||
},
|
||||
"Name": "os",
|
||||
"Operations": [],
|
||||
"OptimumIOSizeBytes": 65536,
|
||||
"Status": {"Health": "OK", "HealthRollup": "OK", "State": "Enabled"},
|
||||
"VolumeType": "Mirrored"
|
||||
}
|
||||
16
tests/redfish_json/cli_logical_volumes.json
Normal file
16
tests/redfish_json/cli_logical_volumes.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#VolumeCollection.VolumeCollection",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes",
|
||||
"@odata.type": "#VolumeCollection.VolumeCollection",
|
||||
"Description": "Collection Of Volume",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 2,
|
||||
"Name": "Volume Collection"
|
||||
}
|
||||
43
tests/redfish_json/cli_service_tag.json
Normal file
43
tests/redfish_json/cli_service_tag.json
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||
"@odata.id": "/redfish/v1",
|
||||
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||
"AccountService": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||
},
|
||||
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Description": "Root Service",
|
||||
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||
"Id": "RootService",
|
||||
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||
"Name": "Root Service",
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||
"IsBranded": 0,
|
||||
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||
"ServiceTag": "JYYZY42"
|
||||
}
|
||||
},
|
||||
"Product": "Integrated Dell Remote Access Controller",
|
||||
"ProtocolFeaturesSupported": {
|
||||
"ExpandQuery": {
|
||||
"ExpandAll": true,
|
||||
"Levels": true,
|
||||
"Links": true,
|
||||
"MaxLevels": 1,
|
||||
"NoLinks": true
|
||||
},
|
||||
"FilterQuery": true,
|
||||
"SelectQuery": true
|
||||
},
|
||||
"RedfishVersion": "1.4.0",
|
||||
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||
}
|
||||
13
tests/redfish_json/cli_storage_controllers.json
Normal file
13
tests/redfish_json/cli_storage_controllers.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#StorageCollection.StorageCollection",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage",
|
||||
"@odata.type": "#StorageCollection.StorageCollection",
|
||||
"Description": "Collection Of Storage entities",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 1,
|
||||
"Name": "Storage Collection"
|
||||
}
|
||||
43
tests/redfish_json/cli_version.json
Normal file
43
tests/redfish_json/cli_version.json
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||
"@odata.id": "/redfish/v1",
|
||||
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||
"AccountService": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||
},
|
||||
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Description": "Root Service",
|
||||
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||
"Id": "RootService",
|
||||
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||
"Name": "Root Service",
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||
"IsBranded": 0,
|
||||
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||
"ServiceTag": "JYYZY42"
|
||||
}
|
||||
},
|
||||
"Product": "Integrated Dell Remote Access Controller",
|
||||
"ProtocolFeaturesSupported": {
|
||||
"ExpandQuery": {
|
||||
"ExpandAll": true,
|
||||
"Levels": true,
|
||||
"Links": true,
|
||||
"MaxLevels": 1,
|
||||
"NoLinks": true
|
||||
},
|
||||
"FilterQuery": true,
|
||||
"SelectQuery": true
|
||||
},
|
||||
"RedfishVersion": "1.4.0",
|
||||
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"}
|
||||
}
|
||||
9
tests/redfish_json/job_list_table.txt
Normal file
9
tests/redfish_json/job_list_table.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
+------------------+-------------------+-----------------+---------------------------+-----------+
|
||||
| Job ID | Job Type | Pcnt Complete | Name | State |
|
||||
+==================+===================+=================+===========================+===========+
|
||||
| JID_878659984891 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||
| JID_878682850779 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||
| JID_920326518992 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||
| JID_923469653542 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||
| JID_924369311959 | RAIDConfiguration | 100 | Config:RAID:RAID.Slot.6-1 | Completed |
|
||||
+------------------+-------------------+-----------------+---------------------------+-----------+
|
||||
101
tests/redfish_json/jobs_list.json
Normal file
101
tests/redfish_json/jobs_list.json
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJobCollection.DellJobCollection",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs",
|
||||
"@odata.type": "#DellJobCollection.DellJobCollection",
|
||||
"Description": "Collection of Job Instances",
|
||||
"Id": "JobQueue",
|
||||
"Members": [
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_878659984891",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-06-27T06:53:33",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_878659984891",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
},
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_878682850779",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-06-27T07:26:19",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_878682850779",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
},
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_920326518992",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-08-14T12:14:58",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_920326518992",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
},
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_923469653542",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-08-18T03:42:19",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_923469653542",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
},
|
||||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_924369311959",
|
||||
"@odata.type": "#DellJob.v1_0_1.DellJob",
|
||||
"CompletionTime": "2023-08-20T05:59:24",
|
||||
"Description": "Job Instance",
|
||||
"EndTime": "TIME_NA",
|
||||
"Id": "JID_924369311959",
|
||||
"JobState": "Completed",
|
||||
"JobType": "RAIDConfiguration",
|
||||
"Message": "Job completed successfully.",
|
||||
"MessageArgs": [],
|
||||
"MessageId": "PR19",
|
||||
"Name": "Config:RAID:RAID.Slot.6-1",
|
||||
"PercentComplete": 100,
|
||||
"StartTime": "TIME_NOW",
|
||||
"TargetSettingsURI": null
|
||||
}
|
||||
],
|
||||
"Members@odata.count": 5,
|
||||
"Name": "JobQueue"
|
||||
}
|
||||
9
tests/redfish_json/list_power_states.json
Normal file
9
tests/redfish_json/list_power_states.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
"On",
|
||||
"ForceOff",
|
||||
"ForceRestart",
|
||||
"GracefulShutdown",
|
||||
"PushPowerButton",
|
||||
"Nmi"
|
||||
]
|
||||
|
||||
57
tests/redfish_json/physical_volume.json
Normal file
57
tests/redfish_json/physical_volume.json
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Drive.Drive",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1",
|
||||
"@odata.type": "#Drive.v1_3_0.Drive",
|
||||
"Actions": {
|
||||
"#Drive.SecureErase": {
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1/Actions/Drive.SecureErase"
|
||||
}
|
||||
},
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"BlockSizeBytes": 512,
|
||||
"CapableSpeedGbs": 3,
|
||||
"CapacityBytes": 299439751168,
|
||||
"Description": "Physical Disk 0:1:0",
|
||||
"EncryptionAbility": "None",
|
||||
"EncryptionStatus": "Unencrypted",
|
||||
"FailurePredicted": false,
|
||||
"HotspareType": "None",
|
||||
"Id": "Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1",
|
||||
"Identifiers": [
|
||||
{
|
||||
"DurableName": "5000C50008F49F95",
|
||||
"DurableNameFormat": "NAA"
|
||||
}
|
||||
],
|
||||
"Links": {
|
||||
"Chassis": {
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
"Volumes": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Volumes/Disk.Virtual.0:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Volumes@odata.count": 1
|
||||
},
|
||||
"Location": [],
|
||||
"Manufacturer": "SEAGATE",
|
||||
"MediaType": "HDD",
|
||||
"Model": "ST3300655SS",
|
||||
"Name": "Physical Disk 0:1:0",
|
||||
"NegotiatedSpeedGbs": 3,
|
||||
"Operations": [],
|
||||
"PartNumber": "SG0HT9531253182B03FPA00",
|
||||
"PredictedMediaLifeLeftPercent": null,
|
||||
"Protocol": "SAS",
|
||||
"Revision": "S527",
|
||||
"RotationSpeedRPM": 0,
|
||||
"SerialNumber": "3LM3M070",
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
}
|
||||
}
|
||||
82
tests/redfish_json/physical_volumes.json
Normal file
82
tests/redfish_json/physical_volumes.json
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Storage.Storage",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1",
|
||||
"@odata.type": "#Storage.v1_4_0.Storage",
|
||||
"Description": "PERC H710 Adapter",
|
||||
"Drives": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.2:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.3:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.4:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.5:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Drives@odata.count": 6,
|
||||
"Id": "RAID.Slot.6-1",
|
||||
"Links": {
|
||||
"Enclosures": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"Enclosures@odata.count": 2
|
||||
},
|
||||
"Name": "PERC H710 Adapter",
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
},
|
||||
"StorageControllers": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/StorageControllers/RAID.Slot.6-1",
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"FirmwareVersion": "21.3.0-0009",
|
||||
"Identifiers": [
|
||||
{
|
||||
"DurableName": "544A842004DB1500",
|
||||
"DurableNameFormat": "NAA"
|
||||
}
|
||||
],
|
||||
"Links": {},
|
||||
"Manufacturer": "DELL",
|
||||
"MemberId": "RAID.Slot.6-1",
|
||||
"Model": "PERC H710 Adapter",
|
||||
"Name": "PERC H710 Adapter",
|
||||
"SpeedGbps": 6,
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
},
|
||||
"SupportedControllerProtocols": [
|
||||
"PCIe"
|
||||
],
|
||||
"SupportedDeviceProtocols": [
|
||||
"SAS",
|
||||
"SATA"
|
||||
]
|
||||
}
|
||||
],
|
||||
"StorageControllers@odata.count": 1,
|
||||
"Volumes": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes"
|
||||
}
|
||||
}
|
||||
9
tests/redfish_json/power_states_allowed.json
Normal file
9
tests/redfish_json/power_states_allowed.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Actions":{
|
||||
"#ComputerSystem.Reset":{
|
||||
"ResetType@Redfish.AllowableValues":[
|
||||
"On", "ForceOff", "ForceRestart", "GracefulShutdown", "PushPowerButton", "Nmi"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
82
tests/redfish_json/storage_controller.json
Normal file
82
tests/redfish_json/storage_controller.json
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#Storage.Storage",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1",
|
||||
"@odata.type": "#Storage.v1_4_0.Storage",
|
||||
"Description": "PERC H710 Adapter",
|
||||
"Drives": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.2:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.3:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.4:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/Drives/Disk.Bay.5:Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
}
|
||||
],
|
||||
"Drives@odata.count": 6,
|
||||
"Id": "RAID.Slot.6-1",
|
||||
"Links": {
|
||||
"Enclosures": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Slot.6-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"Enclosures@odata.count": 2
|
||||
},
|
||||
"Name": "PERC H710 Adapter",
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
},
|
||||
"StorageControllers": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/StorageControllers/RAID.Slot.6-1",
|
||||
"Assembly": {
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly"
|
||||
},
|
||||
"FirmwareVersion": "21.3.0-0009",
|
||||
"Identifiers": [
|
||||
{
|
||||
"DurableName": "544A842004DB1500",
|
||||
"DurableNameFormat": "NAA"
|
||||
}
|
||||
],
|
||||
"Links": {},
|
||||
"Manufacturer": "DELL",
|
||||
"MemberId": "RAID.Slot.6-1",
|
||||
"Model": "PERC H710 Adapter",
|
||||
"Name": "PERC H710 Adapter",
|
||||
"SpeedGbps": 6,
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
},
|
||||
"SupportedControllerProtocols": [
|
||||
"PCIe"
|
||||
],
|
||||
"SupportedDeviceProtocols": [
|
||||
"SAS",
|
||||
"SATA"
|
||||
]
|
||||
}
|
||||
],
|
||||
"StorageControllers@odata.count": 1,
|
||||
"Volumes": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Slot.6-1/Volumes"
|
||||
}
|
||||
}
|
||||
220
tests/redfish_json/system_details.json
Normal file
220
tests/redfish_json/system_details.json
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
{
|
||||
"@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1",
|
||||
"@odata.type": "#ComputerSystem.v1_5_0.ComputerSystem",
|
||||
"Actions": {
|
||||
"#ComputerSystem.Reset": {
|
||||
"ResetType@Redfish.AllowableValues": [
|
||||
"On",
|
||||
"ForceOff",
|
||||
"ForceRestart",
|
||||
"GracefulShutdown",
|
||||
"PushPowerButton",
|
||||
"Nmi"
|
||||
],
|
||||
"target": "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"
|
||||
}
|
||||
},
|
||||
"AssetTag": "",
|
||||
"Bios": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios"
|
||||
},
|
||||
"BiosVersion": "2.4.2",
|
||||
"Boot": {
|
||||
"BootOptions": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions"
|
||||
},
|
||||
"BootOrder": [
|
||||
"Optical.SATAEmbedded.E-1",
|
||||
"NIC.Embedded.1-1-1",
|
||||
"HardDisk.List.1-1"
|
||||
],
|
||||
"BootOrder@odata.count": 3,
|
||||
"BootSourceOverrideEnabled": "Once",
|
||||
"BootSourceOverrideMode": "UEFI",
|
||||
"BootSourceOverrideTarget": "None",
|
||||
"BootSourceOverrideTarget@Redfish.AllowableValues": [
|
||||
"None",
|
||||
"Pxe",
|
||||
"Cd",
|
||||
"Floppy",
|
||||
"Hdd",
|
||||
"BiosSetup",
|
||||
"Utilities",
|
||||
"UefiTarget",
|
||||
"SDCard",
|
||||
"UefiHttp"
|
||||
]
|
||||
},
|
||||
"Description": "Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.",
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces"
|
||||
},
|
||||
"HostName": "JCHV02",
|
||||
"HostWatchdogTimer": {
|
||||
"FunctionEnabled": false,
|
||||
"Status": {
|
||||
"State": "Disabled"
|
||||
},
|
||||
"TimeoutAction": "None"
|
||||
},
|
||||
"Id": "System.Embedded.1",
|
||||
"IndicatorLED": "Off",
|
||||
"Links": {
|
||||
"Chassis": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1"
|
||||
}
|
||||
],
|
||||
"Chassis@odata.count": 1,
|
||||
"CooledBy": [],
|
||||
"CooledBy@odata.count": 0,
|
||||
"ManagedBy": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1"
|
||||
}
|
||||
],
|
||||
"ManagedBy@odata.count": 1,
|
||||
"Oem": {
|
||||
"DELL": {
|
||||
"@odata.type": "#DellComputerSystem.v1_0_0.DellComputerSystem",
|
||||
"BootOrder": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources"
|
||||
}
|
||||
}
|
||||
},
|
||||
"PoweredBy": [],
|
||||
"PoweredBy@odata.count": 0
|
||||
},
|
||||
"Manufacturer": "Dell Inc.",
|
||||
"Memory": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory"
|
||||
},
|
||||
"MemorySummary": {
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
},
|
||||
"TotalSystemMemoryGiB": 89.407008
|
||||
},
|
||||
"Model": "PowerEdge T320",
|
||||
"Name": "System",
|
||||
"NetworkInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces"
|
||||
},
|
||||
"PCIeDevices": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/6-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/1-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-29"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/8-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-26"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-3"
|
||||
}
|
||||
],
|
||||
"PCIeDevices@odata.count": 10,
|
||||
"PCIeFunctions": [
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/6-0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/1-0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-29-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-2"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-1-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-1-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-4"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/8-0-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/1-0-1"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-26-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-3-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-0"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-6"
|
||||
},
|
||||
{
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-7"
|
||||
}
|
||||
],
|
||||
"PCIeFunctions@odata.count": 16,
|
||||
"PartNumber": "0MK701A02",
|
||||
"PowerState": "Off",
|
||||
"ProcessorSummary": {
|
||||
"Count": 1,
|
||||
"LogicalProcessorCount": 4,
|
||||
"Model": "Intel(R) Xeon(R) CPU E5-2407 v2 @ 2.40GHz",
|
||||
"Status": {
|
||||
"Health": null,
|
||||
"HealthRollup": null,
|
||||
"State": "Enabled"
|
||||
}
|
||||
},
|
||||
"Processors": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors"
|
||||
},
|
||||
"SKU": "JYYZY42",
|
||||
"SerialNumber": "CN747515150714",
|
||||
"SimpleStorage": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers"
|
||||
},
|
||||
"Status": {
|
||||
"Health": "OK",
|
||||
"HealthRollup": "OK",
|
||||
"State": "StandbyOffline"
|
||||
},
|
||||
"Storage": {
|
||||
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage"
|
||||
},
|
||||
"SystemType": "Physical",
|
||||
"UUID": "4c4c4544-0059-5910-805a-cac04f593432"
|
||||
}
|
||||
5
tests/test_secrets.json
Normal file
5
tests/test_secrets.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"server": "idrac-73jqy42",
|
||||
"password": "ht6a!nce",
|
||||
"username": "root"
|
||||
}
|
||||
148
tests/utils.py
Normal file
148
tests/utils.py
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
"""Shared things for the tests"""
|
||||
|
||||
import json
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def redfish_json_path(file_name):
|
||||
"""
|
||||
Get the path to a json file based on the location of this test file -
|
||||
basicaly ./redfish_json/file.json
|
||||
"""
|
||||
return (
|
||||
Path(os.path.dirname(os.path.realpath(__file__)))
|
||||
/ "redfish_json"
|
||||
/ file_name
|
||||
)
|
||||
|
||||
|
||||
def get_test_content(file_name):
|
||||
"""Load json from a file"""
|
||||
with open(redfish_json_path(file_name), encoding="utf-8") as json_file:
|
||||
_data = json_file.read()
|
||||
|
||||
return _data
|
||||
|
||||
|
||||
def get_test_json(file_name):
|
||||
"""Load json from a file"""
|
||||
with open(redfish_json_path(file_name), encoding="utf-8") as json_file:
|
||||
_data = json_file.read()
|
||||
_json = json.loads(_data)
|
||||
|
||||
return _json
|
||||
|
||||
|
||||
class MockRedfishResponse:
|
||||
"""Mock a RedFish response"""
|
||||
|
||||
json_dict: dict = {
|
||||
"@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot",
|
||||
"@odata.id": "/redfish/v1",
|
||||
"@odata.type": "#ServiceRoot.v1_3_0.ServiceRoot",
|
||||
"AccountService": {
|
||||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService"
|
||||
},
|
||||
"Chassis": {"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Description": "Root Service",
|
||||
"EventService": {"@odata.id": "/redfish/v1/EventService"},
|
||||
"Fabrics": {"@odata.id": "/redfish/v1/Fabrics"},
|
||||
"Id": "RootService",
|
||||
"JsonSchemas": {"@odata.id": "/redfish/v1/JSONSchemas"},
|
||||
"Links": {"Sessions": {"@odata.id": "/redfish/v1/Sessions"}},
|
||||
"Managers": {"@odata.id": "/redfish/v1/Managers"},
|
||||
"Name": "Root Service",
|
||||
"Oem": {
|
||||
"Dell": {
|
||||
"@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary",
|
||||
"IsBranded": 0,
|
||||
"ManagerMACAddress": "54:9F:35:1A:0D:D8",
|
||||
"ServiceTag": "JYYZY42",
|
||||
}
|
||||
},
|
||||
"Product": "Integrated Dell Remote Access Controller",
|
||||
"ProtocolFeaturesSupported": {
|
||||
"ExpandQuery": {
|
||||
"ExpandAll": True,
|
||||
"Levels": True,
|
||||
"Links": True,
|
||||
"MaxLevels": 1,
|
||||
"NoLinks": True,
|
||||
},
|
||||
"FilterQuery": True,
|
||||
"SelectQuery": True,
|
||||
},
|
||||
"RedfishVersion": "1.4.0",
|
||||
"Registries": {"@odata.id": "/redfish/v1/Registries"},
|
||||
"SessionService": {"@odata.id": "/redfish/v1/SessionService"},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
"Tasks": {"@odata.id": "/redfish/v1/TaskService"},
|
||||
"UpdateService": {"@odata.id": "/redfish/v1/UpdateService"},
|
||||
}
|
||||
status_code = 200
|
||||
|
||||
def __init__(self, status_code=200, json_dict=None):
|
||||
self.status_code = status_code
|
||||
if json_dict is not None:
|
||||
self.json_dict = json
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
"""Return self.json_dict as a json string"""
|
||||
return json.dumps(self.json_dict)
|
||||
|
||||
def update(self, update_dict):
|
||||
"""Update self.json_dict with the specified dict"""
|
||||
self.json_dict.update(update_dict)
|
||||
|
||||
|
||||
class MockResponse:
|
||||
"""A Mocked requests reponse"""
|
||||
|
||||
# pylint: disable=invalid-name,too-few-public-methods
|
||||
|
||||
def __init__(self, status_code=200, ok=True, content="", headers=None):
|
||||
self.status_code = status_code
|
||||
self._ok = ok
|
||||
self.content = content
|
||||
self._headers = headers
|
||||
|
||||
def json(self):
|
||||
"""return json from the mocked response"""
|
||||
return json.loads(self.content)
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
"""return text from the mocked response"""
|
||||
return self.content
|
||||
|
||||
@property
|
||||
def ok(self):
|
||||
"""return the OK flag."""
|
||||
return self._ok
|
||||
|
||||
@property
|
||||
def headers(self):
|
||||
"""Return the headers dict"""
|
||||
return self._headers
|
||||
|
||||
|
||||
class MockWatchedJobResponse:
|
||||
"""Special class for testing watching a job"""
|
||||
|
||||
# pylint: disable=too-few-public-methods, invalid-name
|
||||
|
||||
def __init__(self):
|
||||
self.accessed = 0
|
||||
self._json = get_test_json("api_job_details.json")
|
||||
self.status_code = 200
|
||||
self.ok = True
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
"""Return json, increment % complete each time"""
|
||||
self._json["PercentComplete"] = self.accessed * 20
|
||||
self.accessed += 1
|
||||
return json.dumps(self._json)
|
||||
Loading…
Add table
Add a link
Reference in a new issue