Skip to content

Commit

Permalink
Handle sandboxes using dedicated flags
Browse files Browse the repository at this point in the history
We were trying to set a sandbox using the domain flag, which is rejected
by Aquilon blocking the consumers
  • Loading branch information
DavidFair committed Jun 30, 2023
1 parent fd6215f commit a5f051e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
14 changes: 13 additions & 1 deletion OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ def delete_machine(machine_name: str) -> None:
setup_requests(url, "delete", "Delete Machine")


def _is_sandbox(image_meta: AqMetadata) -> bool:
"""
Returns True if the image is a sandbox image
we do a simple test for a '/' in the domain name
"""
return "/" in image_meta.aq_domain


def create_host(
image_meta: AqMetadata, addresses: List[OpenstackAddress], machine_name: str
) -> None:
Expand All @@ -170,13 +178,17 @@ def create_host(
params = {
"machine": machine_name,
"ip": address.addr,
"domain": image_meta.aq_domain,
"archetype": image_meta.aq_archetype,
"personality": image_meta.aq_personality,
"osname": image_meta.aq_os,
"osversion": image_meta.aq_os_version,
}

if _is_sandbox(image_meta):
params["sandbox"] = image_meta.aq_domain
else:
params["domain"] = image_meta.aq_domain

logger.debug("Attempting to create host for %s ", address.hostname)
url = config.aq_url + f"/host/{address.hostname}"
setup_requests(url, "put", "Host Create", params=params)
Expand Down
32 changes: 32 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_aq_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,38 @@ def test_aq_create_host(config, setup, openstack_address_list, image_metadata):
setup.assert_called_once_with(expected_url, "put", mock.ANY, params=expected_params)


@patch("rabbit_consumer.aq_api.setup_requests")
@patch("rabbit_consumer.aq_api.ConsumerConfig")
def test_aq_create_host_with_sandbox(
config, setup, openstack_address_list, image_metadata
):
"""
Test that aq_create_host calls the correct URL with the correct parameters
"""
machine_name = "machine_name_str"

env_config = config.return_value
env_config.aq_url = "https://example.com"

image_metadata.aq_domain = "example/sandbox"

create_host(image_metadata, openstack_address_list, machine_name)
address = openstack_address_list[0]

expected_params = {
"machine": machine_name,
"ip": address.addr,
"archetype": image_metadata.aq_archetype,
"personality": image_metadata.aq_personality,
"osname": image_metadata.aq_os,
"osversion": image_metadata.aq_os_version,
"sandbox": image_metadata.aq_domain,
}

expected_url = f"https://example.com/host/{address.hostname}"
setup.assert_called_once_with(expected_url, "put", mock.ANY, params=expected_params)


@patch("rabbit_consumer.aq_api.setup_requests")
@patch("rabbit_consumer.aq_api.ConsumerConfig")
def test_aq_delete_host(config, setup):
Expand Down
2 changes: 1 addition & 1 deletion OpenStack-Rabbit-Consumer/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.2
2.3.3
4 changes: 2 additions & 2 deletions charts/rabbit-consumer/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.4.2
version: 1.4.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2.3.2"
appVersion: "v2.3.3"

0 comments on commit a5f051e

Please sign in to comment.