Skip to content

Commit 9fc6df3

Browse files
DaanHooglandclaude
andcommitted
code style cleanups in ApiResponseHelper, Upgrade410to420, AffinityGroupServiceImpl, SystemVmTemplateRegistration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ae1fb44 commit 9fc6df3

4 files changed

Lines changed: 555 additions & 640 deletions

File tree

‎engine/schema/src/main/java/com/cloud/upgrade/SystemVmTemplateRegistration.java‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private static String fetchTemplatesPath() {
389389
}
390390

391391
protected static void cleanupStore(Long templateId, String filePath) {
392-
String destTempFolder = filePath + PARTIAL_TEMPLATE_FOLDER + String.valueOf(templateId);
392+
String destTempFolder = filePath + PARTIAL_TEMPLATE_FOLDER + templateId;
393393
try {
394394
Files.deleteIfExists(Paths.get(destTempFolder));
395395
} catch (IOException e) {
@@ -400,8 +400,8 @@ protected static void cleanupStore(Long templateId, String filePath) {
400400
protected static Pair<Long, Long> readTemplatePropertiesSizes(String path) {
401401
File tmpFile = new File(path);
402402
Long size = null;
403-
Long physicalSize = 0L;
404-
try (FileReader fr = new FileReader(tmpFile); BufferedReader brf = new BufferedReader(fr);) {
403+
long physicalSize = 0L;
404+
try (FileReader fr = new FileReader(tmpFile); BufferedReader brf = new BufferedReader(fr)) {
405405
String line = null;
406406
while ((line = brf.readLine()) != null) {
407407
if (line.startsWith("size=")) {
@@ -532,7 +532,7 @@ public static void unmountStore(String filePath) {
532532
try {
533533
Files.deleteIfExists(Paths.get(filePath));
534534
} catch (IOException e) {
535-
LOGGER.error(String.format("Failed to cleanup mounted store at: %s", filePath), e);
535+
LOGGER.error("Failed to cleanup mounted store at: {}", filePath, e);
536536
}
537537
} catch (Exception e) {
538538
String msg = String.format("Failed to unmount store mounted at %s", filePath);
@@ -586,7 +586,7 @@ private VMTemplateVO createTemplateObjectInDB(SystemVMTemplateDetails details) {
586586
Long templateId = vmTemplateDao.getNextInSequence(Long.class, "id");
587587
VMTemplateVO template = new VMTemplateVO();
588588
template.setUuid(details.getUuid());
589-
template.setUniqueName(String.format("routing-%s" , String.valueOf(templateId)));
589+
template.setUniqueName(String.format("routing-%s" , templateId));
590590
template.setName(details.getName());
591591
template.setPublicTemplate(false);
592592
template.setFeatured(false);
@@ -919,7 +919,6 @@ protected File getTemplateFile(MetadataTemplateDetails templateDetails) {
919919

920920
/**
921921
* Validate that templates for the provided hypervisor/architecture pairs which are in use and are valid.
922-
*
923922
* If a template is missing or validation fails for any required pair, a
924923
* {@link CloudRuntimeException} is thrown to abort the upgrade. If system VM Template for a hypervisor/arch is
925924
* not considered available then validation is skipped for that pair.
@@ -952,7 +951,6 @@ protected void validateTemplates(List<Pair<Hypervisor.HypervisorType, CPU.CPUArc
952951

953952
/**
954953
* Register or ensure system VM Templates are present on the NFS store for a given zone.
955-
*
956954
* Mounts the zone image store, enumerates hypervisors and architectures in the zone,
957955
* and for each template either adds an existing template to the store or registers
958956
* a new template as required.
@@ -1250,7 +1248,6 @@ public VMTemplateVO getRegisteredTemplate(String templateName, Hypervisor.Hyperv
12501248

12511249
/**
12521250
* Update or register system VM Templates based on metadata.
1253-
*
12541251
* Runs the registration logic inside a database transaction: obtains the
12551252
* set of hypervisors/architectures in use, iterates over metadata entries
12561253
* and attempts to register or update each template.

0 commit comments

Comments
 (0)