fix: preserve source talos iso for rebakes
This commit is contained in:
parent
89ba6d70ff
commit
370dd7f29c
|
|
@ -31,11 +31,16 @@ def api_request(base_url, token, method, path, data=None):
|
||||||
def ensure_image(base_url, token, node, node_address, storage, image_url, filename, network_config_path=None):
|
def ensure_image(base_url, token, node, node_address, storage, image_url, filename, network_config_path=None):
|
||||||
content_path = f"/api2/json/nodes/{node}/storage/{storage}/content"
|
content_path = f"/api2/json/nodes/{node}/storage/{storage}/content"
|
||||||
response = api_request(base_url, token, "GET", content_path)
|
response = api_request(base_url, token, "GET", content_path)
|
||||||
for item in response.get("data", []):
|
|
||||||
if item.get("volid", "").endswith(filename):
|
|
||||||
return filename, False
|
|
||||||
|
|
||||||
source_filename = filename
|
if network_config_path:
|
||||||
|
if any(item.get("volid", "").endswith(filename) for item in response.get("data", [])):
|
||||||
|
return filename, False
|
||||||
|
source_filename = f"source-{filename}"
|
||||||
|
else:
|
||||||
|
for item in response.get("data", []):
|
||||||
|
if item.get("volid", "").endswith(filename):
|
||||||
|
return filename, False
|
||||||
|
source_filename = filename
|
||||||
|
|
||||||
response = api_request(base_url, token, "GET", content_path)
|
response = api_request(base_url, token, "GET", content_path)
|
||||||
source_present = any(item.get("volid", "").endswith(source_filename) for item in response.get("data", []))
|
source_present = any(item.get("volid", "").endswith(source_filename) for item in response.get("data", []))
|
||||||
|
|
@ -47,7 +52,7 @@ def ensure_image(base_url, token, node, node_address, storage, image_url, filena
|
||||||
"url": image_url,
|
"url": image_url,
|
||||||
})
|
})
|
||||||
wait_for_task(base_url, token, node, task.get("data"))
|
wait_for_task(base_url, token, node, task.get("data"))
|
||||||
wait_for_storage_content(base_url, token, node, storage, filename)
|
wait_for_storage_content(base_url, token, node, storage, source_filename)
|
||||||
|
|
||||||
if network_config_path:
|
if network_config_path:
|
||||||
build_custom_iso(base_url, token, node_address, storage, source_filename, filename, network_config_path)
|
build_custom_iso(base_url, token, node_address, storage, source_filename, filename, network_config_path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue