Skip to content

Commit

Permalink
Change server prop hv id to hv name
Browse files Browse the repository at this point in the history
Server properties previously using host id as hypervisor id however this didn't match the hypervisor id
  • Loading branch information
gmatthews20 committed Dec 10, 2024
1 parent ba5773f commit ffeb1e2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/user_docs/query_docs/SERVERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from enums.query.props.server_properties import ServerProperties
| Property Enum | Type | Aliases | Description |
|--------------------------|--------------|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| FLAVOR_ID | `string` | `None` | The ID of the Flavor the Server is using |
| HYPERVISOR_ID | `string` | `None` | The ID of the Hypervisor the Server is being hosted on |
| HYPERVISOR_NAME | `string` | `None` | Name of the Hypervisor the Server is being hosted on |
| IMAGE_ID | `string` | `None` | The ID of the Image the Server is using |
| PROJECT_ID | `string` | `None` | The ID of the Project the Server is associated with |
| SERVER_CREATION_DATE | `string` (x) | "created_at" | Timestamp of when the server was created. |
Expand Down Expand Up @@ -69,7 +69,7 @@ The following shared-common properties are listed below (as well as the Query ob
| ServerProperties.PROJECT_ID | ProjectProperties.PROJECT_ID | Many-to-One | `ServerQuery` to `ProjectQuery` | [PROJECTS.md](PROJECTS.md) |
| ServerProperties.FLAVOR_ID | FlavorProperties.FLAVOR_ID | Many-to-One | `ServerQuery` to `FlavorQuery` | [FLAVORS.md](FLAVORS.md) |
| ServerProperties.IMAGE_ID | ImageProperties.IMAGE_ID | Many-to-One | `ServerQuery` to `ImageQuery` | [IMAGES.md](IMAGES.md) |
| ServerProperties.HYPERVISOR_ID | HypervisorProperties.HYPERVISOR_ID | Many-to-One | `ServerQuery` to `HypervisorQuery` | [HYPERVISORS.md](HYPERVISORS.md) |
| ServerProperties.HYPERVISOR_NAME | HypervisorProperties.HYPERVISOR_NAME | Many-to-One | `ServerQuery` to `HypervisorQuery` | [HYPERVISORS.md](HYPERVISORS.md) |



Expand Down
6 changes: 3 additions & 3 deletions openstackquery/enums/props/server_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ServerProperties(PropEnum):
"""

FLAVOR_ID = auto()
HYPERVISOR_ID = auto()
HYPERVISOR_NAME = auto()
IMAGE_ID = auto()
PROJECT_ID = auto()
SERVER_CREATION_DATE = auto()
Expand All @@ -29,7 +29,7 @@ def _get_aliases():
A method that returns all valid string alias mappings
"""
return {
ServerProperties.HYPERVISOR_ID: ["host_id", "hv_id"],
ServerProperties.HYPERVISOR_NAME: ["hv_name", "hypervisor_name"],
ServerProperties.SERVER_CREATION_DATE: ["created_at"],
ServerProperties.SERVER_DESCRIPTION: [
"description",
Expand All @@ -53,7 +53,7 @@ def get_prop_mapping(prop):
"""
mapping = {
ServerProperties.USER_ID: lambda a: a["user_id"],
ServerProperties.HYPERVISOR_ID: lambda a: a["host_id"],
ServerProperties.HYPERVISOR_NAME: lambda a: a["hypervisor_hostname"],
ServerProperties.SERVER_ID: lambda a: a["id"],
ServerProperties.SERVER_NAME: lambda a: a["name"],
ServerProperties.SERVER_DESCRIPTION: lambda a: a["description"],
Expand Down
2 changes: 1 addition & 1 deletion openstackquery/mappings/hypervisor_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_chain_mappings():
Should return a dictionary containing property pairs mapped to query mappings.
This is used to define how to chain results from this query to other possible queries
"""
return {HypervisorProperties.HYPERVISOR_ID: ServerProperties.HYPERVISOR_ID}
return {HypervisorProperties.HYPERVISOR_NAME: ServerProperties.HYPERVISOR_NAME}

@staticmethod
def get_runner_mapping() -> Type[RunnerWrapper]:
Expand Down
2 changes: 1 addition & 1 deletion openstackquery/mappings/server_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_chain_mappings():
ServerProperties.PROJECT_ID: ProjectProperties.PROJECT_ID,
ServerProperties.FLAVOR_ID: FlavorProperties.FLAVOR_ID,
ServerProperties.IMAGE_ID: ImageProperties.IMAGE_ID,
ServerProperties.HYPERVISOR_ID: HypervisorProperties.HYPERVISOR_ID,
ServerProperties.HYPERVISOR_NAME: HypervisorProperties.HYPERVISOR_NAME,
}

@staticmethod
Expand Down
7 changes: 4 additions & 3 deletions tests/enums/props/test_server_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ def test_flavor_id_serialization(val):


@pytest.mark.parametrize(
"val", ["hypervisor_id", "Hypervisor_ID", "HyPerVisor_ID", "host_id", "hv_id"]
"val",
["hypervisor_name", "Hypervisor_NAME", "HyPerVisor_NamE", "hv_name", "HV_name"],
)
def test_hypervisor_id_serialization(val):
"""
Tests that variants of HYPERVISOR_ID can be serialized
Tests that variants of HYPERVISOR_NAME can be serialized
"""
assert ServerProperties.from_string(val) is ServerProperties.HYPERVISOR_ID
assert ServerProperties.from_string(val) is ServerProperties.HYPERVISOR_NAME


@pytest.mark.parametrize("val", ["image_id", "Image_ID", "ImaGe_iD"])
Expand Down
2 changes: 1 addition & 1 deletion tests/mappings/test_hypervisor_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_get_chain_mappings():
Tests get_chain_mapping outputs correctly
"""
expected_mappings = {
HypervisorProperties.HYPERVISOR_ID: ServerProperties.HYPERVISOR_ID,
HypervisorProperties.HYPERVISOR_NAME: ServerProperties.HYPERVISOR_NAME,
}

assert HypervisorMapping.get_chain_mappings() == expected_mappings
2 changes: 1 addition & 1 deletion tests/mappings/test_server_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_get_chain_mappings():
ServerProperties.PROJECT_ID: ProjectProperties.PROJECT_ID,
ServerProperties.FLAVOR_ID: FlavorProperties.FLAVOR_ID,
ServerProperties.IMAGE_ID: ImageProperties.IMAGE_ID,
ServerProperties.HYPERVISOR_ID: HypervisorProperties.HYPERVISOR_ID,
ServerProperties.HYPERVISOR_NAME: HypervisorProperties.HYPERVISOR_NAME,
}

assert ServerMapping.get_chain_mappings() == expected_mappings

0 comments on commit ffeb1e2

Please sign in to comment.