Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public class ImportUnmanagedInstanceCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.CLUSTER_ID,
type = CommandType.UUID,
entityType = ClusterResponse.class,
required = true,
description = "The cluster ID")
description = "The cluster ID. Required when importing an unmanaged Instance or importing from VMware. " +
"Not used when importing a KVM Instance from an external host, local storage or shared storage")
private Long clusterId;

@Parameter(name = ApiConstants.NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ protected Cluster basicAccessChecks(Long clusterId) {
throw new PermissionDeniedException(String.format("Cannot perform this operation, caller account [%s] is not ROOT Admin.", caller.getUuid()));
}
if (clusterId == null) {
throw new InvalidParameterValueException("Cluster ID cannot be null.");
throw new InvalidParameterValueException(String.format("Cluster ID cannot be null, please specify the [%s] parameter.", ApiConstants.CLUSTER_ID));
}
final Cluster cluster = clusterDao.findById(clusterId);
if (cluster == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,24 @@ private void importFromDisk(String source, Storage.StoragePoolType poolType, Str
verify(deploymentPlanningManager).planDeployment(any(), planCaptor.capture(), any(), any());
Assert.assertEquals(poolPodId, planCaptor.getValue().getPodId());
Assert.assertEquals(poolClusterId, planCaptor.getValue().getClusterId());
// the clusterid parameter is not used, the cluster is derived from the storage pool
Mockito.verify(cmd, Mockito.never()).getClusterId();
}

@Test(expected = InvalidParameterValueException.class)
public void testImportVmFromVmwareMissingClusterId() {
ImportVmCmd cmd = Mockito.mock(ImportVmCmd.class);
when(cmd.getName()).thenReturn("testVm");
when(cmd.getImportSource()).thenReturn("vmware");
unmanagedVMsManager.importVm(cmd);
}

@Test(expected = InvalidParameterValueException.class)
public void testImportVmFromUnmanagedMissingClusterId() {
ImportVmCmd cmd = Mockito.mock(ImportVmCmd.class);
when(cmd.getName()).thenReturn("testVm");
when(cmd.getImportSource()).thenReturn("unmanaged");
unmanagedVMsManager.importVm(cmd);
}

@Test
Expand Down
Loading