Skip to content

Commit f483627

Browse files
committed
Fix-up Aq manage to handle sandboxes
Despite the fact we're not using it, lets also fix the Aq manage to respect sandboxes whilst we're here. That way if we re-use it in the future we know it will work
1 parent dfaf253 commit f483627

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ def aq_manage(addresses: List[OpenstackAddress], image_meta: AqMetadata) -> None
109109

110110
params = {
111111
"hostname": hostname,
112-
"domain": image_meta.aq_domain,
113112
"force": True,
114113
}
114+
if image_meta.aq_sandbox:
115+
params["sandbox"] = image_meta.aq_sandbox
116+
else:
117+
params["domain"] = image_meta.aq_domain
118+
115119
url = ConsumerConfig().aq_url + f"/host/{hostname}/command/manage"
116120
setup_requests(url, "post", "Manage Host", params=params)
117121

OpenStack-Rabbit-Consumer/test/test_aq_api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,30 @@ def test_aq_manage(config, setup, openstack_address_list, image_metadata):
183183
setup.assert_called_once_with(expected_url, "post", mock.ANY, params=expected_param)
184184

185185

186+
@patch("rabbit_consumer.aq_api.setup_requests")
187+
@patch("rabbit_consumer.aq_api.ConsumerConfig")
188+
def test_aq_manage_with_sandbox(config, setup, openstack_address_list, image_metadata):
189+
"""
190+
Test that aq_manage calls the correct URLs with the sandbox
191+
instead of the domain
192+
"""
193+
config.return_value.aq_url = "https://example.com"
194+
195+
image_metadata.aq_sandbox = "some_sandbox"
196+
197+
aq_manage(openstack_address_list, image_metadata)
198+
address = openstack_address_list[0]
199+
200+
expected_param = {
201+
"hostname": address.hostname,
202+
"sandbox": image_metadata.aq_sandbox,
203+
"force": True,
204+
}
205+
206+
expected_url = f"https://example.com/host/{address.hostname}/command/manage"
207+
setup.assert_called_once_with(expected_url, "post", mock.ANY, params=expected_param)
208+
209+
186210
@patch("rabbit_consumer.aq_api.ConsumerConfig")
187211
@patch("rabbit_consumer.aq_api.setup_requests")
188212
def test_aq_create_machine(setup, config, rabbit_message, vm_data):

0 commit comments

Comments
 (0)