From 9c62dd173ab861efcc5ba090f16f42101404e023 Mon Sep 17 00:00:00 2001 From: Darrin Husselmann Date: Mon, 9 Dec 2019 12:27:28 +0200 Subject: [PATCH] Added zone check --- .../main/java/com/cloud/template/TemplateManagerImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index b81faeb0bd27..646d2c3cd55a 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1187,6 +1187,12 @@ public boolean attachIso(long isoId, long vmId) { throw new InvalidParameterValueException("Unable to find an ISO with id " + isoId); } + long dcId = vm.getDataCenterId(); + VMTemplateZoneVO exists = _tmpltZoneDao.findByZoneTemplate(dcId, isoId); + if (null == exists) { + throw new InvalidParameterValueException("ISO is not available in the zone the VM is in."); + } + // check permissions // check if caller has access to VM and ISO // and also check if the VM's owner has access to the ISO.