use of org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd in project cloudstack by apache.
the class KubernetesVersionServiceTest method addKubernetesSupportedVersionIsoUrlTest.
@Test
public void addKubernetesSupportedVersionIsoUrlTest() throws ResourceAllocationException, NoSuchFieldException {
AddKubernetesSupportedVersionCmd cmd = Mockito.mock(AddKubernetesSupportedVersionCmd.class);
AccountVO account = new AccountVO("admin", 1L, "", Account.ACCOUNT_TYPE_ADMIN, "uuid");
UserVO user = new UserVO(1, "adminuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
when(cmd.getSemanticVersion()).thenReturn(KubernetesVersionService.MIN_KUBERNETES_VERSION);
when(cmd.getUrl()).thenReturn("https://download.cloudstack.com");
when(cmd.getChecksum()).thenReturn(null);
when(cmd.getMinimumCpu()).thenReturn(KubernetesClusterService.MIN_KUBERNETES_CLUSTER_NODE_CPU);
when(cmd.getMinimumRamSize()).thenReturn(KubernetesClusterService.MIN_KUBERNETES_CLUSTER_NODE_RAM_SIZE);
Account systemAccount = new AccountVO("system", 1L, "", Account.ACCOUNT_TYPE_ADMIN, "uuid");
when(accountManager.getSystemAccount()).thenReturn(systemAccount);
PowerMockito.mockStatic(ComponentContext.class);
when(ComponentContext.inject(Mockito.any(RegisterIsoCmd.class))).thenReturn(new RegisterIsoCmd());
when(templateService.registerIso(Mockito.any(RegisterIsoCmd.class))).thenReturn(Mockito.mock(VirtualMachineTemplate.class));
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
when(templateVO.getId()).thenReturn(1L);
when(templateDao.findById(Mockito.anyLong())).thenReturn(templateVO);
kubernetesVersionService.addKubernetesSupportedVersion(cmd);
}
use of org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd in project cloudstack by apache.
the class KubernetesVersionManagerImpl method registerKubernetesVersionIso.
private VirtualMachineTemplate registerKubernetesVersionIso(final Long zoneId, final String versionName, final String isoUrl, final String isoChecksum) throws IllegalAccessException, NoSuchFieldException, IllegalArgumentException, ResourceAllocationException {
String isoName = String.format("%s-Kubernetes-Binaries-ISO", versionName);
RegisterIsoCmd registerIsoCmd = new RegisterIsoCmd();
registerIsoCmd = ComponentContext.inject(registerIsoCmd);
registerIsoCmd.setIsoName(isoName);
registerIsoCmd.setPublic(true);
if (zoneId != null) {
registerIsoCmd.setZoneId(zoneId);
}
registerIsoCmd.setDisplayText(isoName);
registerIsoCmd.setBootable(false);
registerIsoCmd.setUrl(isoUrl);
if (StringUtils.isNotEmpty(isoChecksum)) {
registerIsoCmd.setChecksum(isoChecksum);
}
registerIsoCmd.setAccountName(accountManager.getSystemAccount().getAccountName());
registerIsoCmd.setDomainId(accountManager.getSystemAccount().getDomainId());
return templateService.registerIso(registerIsoCmd);
}
Aggregations