sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #05106
[Merge] ~jorge-merlino/maas:fix_lp2003980 into maas:master
Jorge Merlino has proposed merging ~jorge-merlino/maas:fix_lp2003980 into maas:master.
Commit message:
Add timestamp to custom images uploaded with the same name as an existing image. The duplicate name generates problems as MAAS thinks that the new image is already synced with the rack controllers because it has the same name. This patch prevents duplicate names.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~jorge-merlino/maas/+git/maas/+merge/437352
--
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/api/boot_resources.py b/src/maasserver/api/boot_resources.py
index 770fdf1..47b895c 100644
--- a/src/maasserver/api/boot_resources.py
+++ b/src/maasserver/api/boot_resources.py
@@ -218,6 +218,24 @@ class BootResourcesHandler(OperationsHandler):
data = {}
if "filetype" not in data:
data["filetype"] = "tgz"
+
+ finished = False
+ while not finished:
+ exists = BootResource.objects.filter(
+ name=data["name"], rtype=BOOT_RESOURCE_TYPE.UPLOADED
+ )
+ if exists:
+ timestamp = datetime.today().strftime("%y%m%d_%H%M")
+ maaslog.info(
+ "Adding timestamp tag {} to image {}".format(
+ timestamp, data["name"]
+ )
+ )
+ data["name"] = data["name"] + "_" + timestamp
+ request.data = data
+ else:
+ finished = True
+
file_content = get_content_parameter(request)
if file_content is not None:
content = SimpleUploadedFile(
Follow ups