Search in sources :

Example 1 with RegisterIsoCmd

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);
}
Also used : Account(com.cloud.user.Account) RegisterIsoCmd(org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd) UserVO(com.cloud.user.UserVO) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) VMTemplateVO(com.cloud.storage.VMTemplateVO) AddKubernetesSupportedVersionCmd(org.apache.cloudstack.api.command.admin.kubernetes.version.AddKubernetesSupportedVersionCmd) AccountVO(com.cloud.user.AccountVO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with RegisterIsoCmd

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);
}
Also used : RegisterIsoCmd(org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd)

Aggregations

RegisterIsoCmd (org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd)2 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)1 Account (com.cloud.user.Account)1 AccountVO (com.cloud.user.AccountVO)1 UserVO (com.cloud.user.UserVO)1 AddKubernetesSupportedVersionCmd (org.apache.cloudstack.api.command.admin.kubernetes.version.AddKubernetesSupportedVersionCmd)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1