diff --git a/OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py b/OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py index ad8e116b..8c9eae85 100644 --- a/OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py +++ b/OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py @@ -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: @@ -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) diff --git a/OpenStack-Rabbit-Consumer/test/test_aq_api.py b/OpenStack-Rabbit-Consumer/test/test_aq_api.py index f92670b9..8735d85d 100644 --- a/OpenStack-Rabbit-Consumer/test/test_aq_api.py +++ b/OpenStack-Rabbit-Consumer/test/test_aq_api.py @@ -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): diff --git a/OpenStack-Rabbit-Consumer/version.txt b/OpenStack-Rabbit-Consumer/version.txt index f90b1afc..0bee604d 100644 --- a/OpenStack-Rabbit-Consumer/version.txt +++ b/OpenStack-Rabbit-Consumer/version.txt @@ -1 +1 @@ -2.3.2 +2.3.3 diff --git a/charts/rabbit-consumer/Chart.yaml b/charts/rabbit-consumer/Chart.yaml index fb40422b..2f48d305 100644 --- a/charts/rabbit-consumer/Chart.yaml +++ b/charts/rabbit-consumer/Chart.yaml @@ -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"