@Test public void testConvertWithoutRootVolumeSizeInRequestAndDefaultIsSet() { Template template = initTemplate(); when(defaultRootVolumeSizeProvider.getForPlatform(any())).thenReturn(100); Template actual = underTest.decorate(cloudCredential, template, REGION, AVAILABILITY_ZONE, VARIANT, CdpResourceType.DATAHUB); assertEquals(100L, (long) actual.getRootVolumeSize()); }
public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) { setRootVolumeSize(template); PlatformDisks platformDisks = cloudParameterService.getDiskTypes(); CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2( extendedCloudCredentialConverter.convert(credential), region, variant, cdpResourceType, new HashMap<>()); String locationString = locationService.location(region, availabilityZone); VolumeParameterConfig config; for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) { try { config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString); } catch (NoSuchElementException ignored) { LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack"); config = VolumeParameterConfig.EMPTY; } if (config.volumeParameterType() != null) { if (volumeTemplate.getVolumeCount() == null) { volumeTemplate.setVolumeCount(config.maximumNumber()); } if (volumeTemplate.getVolumeSize() == null) { volumeTemplate.setVolumeSize(config.maximumSize()); } } } return template; }
TemplateDecorator { public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) { setRootVolumeSize(template); PlatformDisks platformDisks = cloudParameterService.getDiskTypes(); CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2( extendedCloudCredentialConverter.convert(credential), region, variant, cdpResourceType, new HashMap<>()); String locationString = locationService.location(region, availabilityZone); VolumeParameterConfig config; for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) { try { config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString); } catch (NoSuchElementException ignored) { LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack"); config = VolumeParameterConfig.EMPTY; } if (config.volumeParameterType() != null) { if (volumeTemplate.getVolumeCount() == null) { volumeTemplate.setVolumeCount(config.maximumNumber()); } if (volumeTemplate.getVolumeSize() == null) { volumeTemplate.setVolumeSize(config.maximumSize()); } } } return template; } }
TemplateDecorator { public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) { setRootVolumeSize(template); PlatformDisks platformDisks = cloudParameterService.getDiskTypes(); CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2( extendedCloudCredentialConverter.convert(credential), region, variant, cdpResourceType, new HashMap<>()); String locationString = locationService.location(region, availabilityZone); VolumeParameterConfig config; for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) { try { config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString); } catch (NoSuchElementException ignored) { LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack"); config = VolumeParameterConfig.EMPTY; } if (config.volumeParameterType() != null) { if (volumeTemplate.getVolumeCount() == null) { volumeTemplate.setVolumeCount(config.maximumNumber()); } if (volumeTemplate.getVolumeSize() == null) { volumeTemplate.setVolumeSize(config.maximumSize()); } } } return template; }  }
TemplateDecorator { public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) { setRootVolumeSize(template); PlatformDisks platformDisks = cloudParameterService.getDiskTypes(); CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2( extendedCloudCredentialConverter.convert(credential), region, variant, cdpResourceType, new HashMap<>()); String locationString = locationService.location(region, availabilityZone); VolumeParameterConfig config; for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) { try { config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString); } catch (NoSuchElementException ignored) { LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack"); config = VolumeParameterConfig.EMPTY; } if (config.volumeParameterType() != null) { if (volumeTemplate.getVolumeCount() == null) { volumeTemplate.setVolumeCount(config.maximumNumber()); } if (volumeTemplate.getVolumeSize() == null) { volumeTemplate.setVolumeSize(config.maximumSize()); } } } return template; }  Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType); }
TemplateDecorator { public Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType) { setRootVolumeSize(template); PlatformDisks platformDisks = cloudParameterService.getDiskTypes(); CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2( extendedCloudCredentialConverter.convert(credential), region, variant, cdpResourceType, new HashMap<>()); String locationString = locationService.location(region, availabilityZone); VolumeParameterConfig config; for (VolumeTemplate volumeTemplate : template.getVolumeTemplates()) { try { config = resolveVolumeParameterConfig(template, volumeTemplate, platformDisks, vmTypesV2, locationString); } catch (NoSuchElementException ignored) { LOGGER.debug("No VolumeParameterConfig found, which might be normal for platforms like OpenStack"); config = VolumeParameterConfig.EMPTY; } if (config.volumeParameterType() != null) { if (volumeTemplate.getVolumeCount() == null) { volumeTemplate.setVolumeCount(config.maximumNumber()); } if (volumeTemplate.getVolumeSize() == null) { volumeTemplate.setVolumeSize(config.maximumSize()); } } } return template; }  Template decorate(Credential credential, Template template, String region, String availabilityZone, String variant, CdpResourceType cdpResourceType);  }