DaanHoogland commented on a change in pull request #3680: [WIP: DO NOT MERGE]
CloudStack Kubernetes Service
URL: https://github.com/apache/cloudstack/pull/3680#discussion_r367948102
##########
File path:
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java
##########
@@ -163,47 +169,15 @@ private VirtualMachineTemplate
registerKubernetesVersionIso(final String version
f.setAccessible(true);
f.set(registerIsoCmd, isoChecksum);
}
+ f = registerIsoCmd.getClass().getDeclaredField("accountName");
+ f.setAccessible(true);
+ f.set(registerIsoCmd,
accountManager.getSystemAccount().getAccountName());
+ f = registerIsoCmd.getClass().getDeclaredField("domainId");
+ f.setAccessible(true);
+ f.set(registerIsoCmd, accountManager.getSystemAccount().getDomainId());
return templateService.registerIso(registerIsoCmd);
}
- private void validateExistingTemplateForKubernetesVersionIso(final
VirtualMachineTemplate template, final Long zoneId) {
- if (!template.getFormat().equals(Storage.ImageFormat.ISO)) {
- throw new InvalidParameterValueException(String.format("%s is not
an ISO", template.getUuid()));
- }
- if (!template.isPublicTemplate()) {
- throw new InvalidParameterValueException(String.format("ISO ID: %s
is not public", template.getUuid()));
- }
- if (!template.isCrossZones() && zoneId == null) {
- throw new InvalidParameterValueException(String.format("ISO ID: %s
is not available across zones", template.getUuid()));
- }
- if (!template.isCrossZones() && zoneId != null) {
- List<VMTemplateZoneVO> templatesZoneVOs =
templateZoneDao.listByZoneTemplate(zoneId, template.getId());
- if (templatesZoneVOs.isEmpty()) {
- DataCenterVO zone = dataCenterDao.findById(zoneId);
- throw new InvalidParameterValueException(String.format("ISO
ID: %s is not available for zone ID: %s", template.getUuid(), zone.getUuid()));
- }
- }
- }
-
- private VMTemplateVO registerKubernetesVersionIsoIfNeeded(final Long
isoId, final Long zoneId, final String name, final String isoUrl, final String
isoChecksum) throws CloudRuntimeException {
- VMTemplateVO templateVO = null;
- if (isoId != null) {
- templateVO = templateDao.findById(isoId);
- }
- if (templateVO == null) {
- try {
- VirtualMachineTemplate vmTemplate =
registerKubernetesVersionIso(name, isoUrl, isoChecksum);
- templateVO = templateDao.findById(vmTemplate.getId());
- } catch (IllegalAccessException | NoSuchFieldException |
IllegalArgumentException | ResourceAllocationException ex) {
- LOGGER.error(String.format("Unable to register binaries ISO
for supported kubernetes version, %s", name), ex);
- throw new CloudRuntimeException(String.format("Unable to
register binaries ISO for supported kubernetes version, %s", name));
- }
- } else {
- validateExistingTemplateForKubernetesVersionIso(templateVO,
zoneId);
- }
- return templateVO;
- }
-
private void deleteKubernetesVersionIso(long templateId) throws
IllegalAccessException, NoSuchFieldException,
IllegalArgumentException {
DeleteIsoCmd deleteIsoCmd = new DeleteIsoCmd();
Review comment:
same here. just add the setters or the constructor to deal with this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services