Skip to content

Commit 32399f6

Browse files
committed
Add hypervisor uptime property
Add uptime to hypervisor properties Update Hypervisor Query docs Update tests
1 parent 6c2f608 commit 32399f6

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

docs/user_docs/query_docs/HYPERVISORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ from enums.query.props.hypervisor_properties import HypervisorProperties
4343
| HYPERVISOR_VCPUS | `int` | "vcpus" | The number of vCPUs on this hypervisor. |
4444
| HYPERVISOR_VCPUS_USED | `int` | "vcpus_used" | The number of vCPUs currently being used on this hypervisor. |
4545
| HYPERVISOR_DISABLED_REASON | `string` | "disabled_reason" | Comment of why the hypervisor is disabled, None if not disabled |
46+
| HYPERVISOR_UPTIME | `string` | "uptime" | The total uptime of the hypervisor and info about average load |
4647

4748

4849
Any of these properties can be used for any of the API methods that takes a property - like `select`, `where`, `sort_by` etc

openstackquery/enums/props/hypervisor_properties.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class HypervisorProperties(PropEnum):
2828
HYPERVISOR_VCPUS = auto()
2929
HYPERVISOR_VCPUS_USED = auto()
3030
HYPERVISOR_DISABLED_REASON = auto()
31+
HYPERVISOR_UPTIME = auto()
3132

3233
@staticmethod
3334
def _get_aliases() -> Dict:
@@ -63,6 +64,7 @@ def _get_aliases() -> Dict:
6364
HypervisorProperties.HYPERVISOR_VCPUS: ["vcpus"],
6465
HypervisorProperties.HYPERVISOR_VCPUS_USED: ["vcpus_used"],
6566
HypervisorProperties.HYPERVISOR_DISABLED_REASON: ["disabled_reason"],
67+
HypervisorProperties.HYPERVISOR_UPTIME: ["uptime"],
6668
}
6769

6870
@staticmethod
@@ -110,6 +112,7 @@ def get_prop_mapping(prop) -> Optional[PropFunc]:
110112
HypervisorProperties.HYPERVISOR_DISABLED_REASON: lambda a: a["service"][
111113
"disabled_reason"
112114
],
115+
HypervisorProperties.HYPERVISOR_UPTIME: lambda a: a["uptime"],
113116
}
114117
try:
115118
return mapping[prop]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="openstackquery",
10-
version="0.1.2",
10+
version="0.1.3",
1111
author="Anish Mudaraddi",
1212
author_email="<anish.mudaraddi@stfc.ac.uk>",
1313
description=DESCRIPTION,

tests/enums/props/test_hypervisor_properties.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,20 @@ def test_hypervisor_disabled_reason_serialization(val):
280280
HypervisorProperties.from_string(val)
281281
is HypervisorProperties.HYPERVISOR_DISABLED_REASON
282282
)
283+
284+
285+
@pytest.mark.parametrize(
286+
"val",
287+
[
288+
"hypervisor_uptime",
289+
"Hypervisor_Uptime",
290+
"HyPeRvIsOr_UpTiMe",
291+
],
292+
)
293+
def test_hypervisor_uptime_serialization(val):
294+
"""
295+
Tests that variants of HYPERVISOR_UPTIME can be serialized
296+
"""
297+
assert (
298+
HypervisorProperties.from_string(val) is HypervisorProperties.HYPERVISOR_UPTIME
299+
)

0 commit comments

Comments
 (0)