Skip to content

Commit da6a8d2

Browse files
authored
Merge pull request #82 from stfc/Handle_sandboxes
Handle sandboxes using dedicated flags
2 parents fd6215f + a5f051e commit da6a8d2

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ def delete_machine(machine_name: str) -> None:
158158
setup_requests(url, "delete", "Delete Machine")
159159

160160

161+
def _is_sandbox(image_meta: AqMetadata) -> bool:
162+
"""
163+
Returns True if the image is a sandbox image
164+
we do a simple test for a '/' in the domain name
165+
"""
166+
return "/" in image_meta.aq_domain
167+
168+
161169
def create_host(
162170
image_meta: AqMetadata, addresses: List[OpenstackAddress], machine_name: str
163171
) -> None:
@@ -170,13 +178,17 @@ def create_host(
170178
params = {
171179
"machine": machine_name,
172180
"ip": address.addr,
173-
"domain": image_meta.aq_domain,
174181
"archetype": image_meta.aq_archetype,
175182
"personality": image_meta.aq_personality,
176183
"osname": image_meta.aq_os,
177184
"osversion": image_meta.aq_os_version,
178185
}
179186

187+
if _is_sandbox(image_meta):
188+
params["sandbox"] = image_meta.aq_domain
189+
else:
190+
params["domain"] = image_meta.aq_domain
191+
180192
logger.debug("Attempting to create host for %s ", address.hostname)
181193
url = config.aq_url + f"/host/{address.hostname}"
182194
setup_requests(url, "put", "Host Create", params=params)

OpenStack-Rabbit-Consumer/test/test_aq_api.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,38 @@ def test_aq_create_host(config, setup, openstack_address_list, image_metadata):
279279
setup.assert_called_once_with(expected_url, "put", mock.ANY, params=expected_params)
280280

281281

282+
@patch("rabbit_consumer.aq_api.setup_requests")
283+
@patch("rabbit_consumer.aq_api.ConsumerConfig")
284+
def test_aq_create_host_with_sandbox(
285+
config, setup, openstack_address_list, image_metadata
286+
):
287+
"""
288+
Test that aq_create_host calls the correct URL with the correct parameters
289+
"""
290+
machine_name = "machine_name_str"
291+
292+
env_config = config.return_value
293+
env_config.aq_url = "https://example.com"
294+
295+
image_metadata.aq_domain = "example/sandbox"
296+
297+
create_host(image_metadata, openstack_address_list, machine_name)
298+
address = openstack_address_list[0]
299+
300+
expected_params = {
301+
"machine": machine_name,
302+
"ip": address.addr,
303+
"archetype": image_metadata.aq_archetype,
304+
"personality": image_metadata.aq_personality,
305+
"osname": image_metadata.aq_os,
306+
"osversion": image_metadata.aq_os_version,
307+
"sandbox": image_metadata.aq_domain,
308+
}
309+
310+
expected_url = f"https://example.com/host/{address.hostname}"
311+
setup.assert_called_once_with(expected_url, "put", mock.ANY, params=expected_params)
312+
313+
282314
@patch("rabbit_consumer.aq_api.setup_requests")
283315
@patch("rabbit_consumer.aq_api.ConsumerConfig")
284316
def test_aq_delete_host(config, setup):

OpenStack-Rabbit-Consumer/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.2
1+
2.3.3

charts/rabbit-consumer/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ type: application
66
# This is the chart version. This version number should be incremented each time you make changes
77
# to the chart and its templates, including the app version.
88
# Versions are expected to follow Semantic Versioning (https://semver.org/)
9-
version: 1.4.2
9+
version: 1.4.3
1010

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

0 commit comments

Comments
 (0)