mirror of https://github.com/apache/cloudstack.git
address review comments
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
c65dfa1823
commit
1a379251bc
|
|
@ -85,6 +85,7 @@ public class AssignVMCmd extends BaseCmd {
|
|||
"In case no security groups are provided the Instance is part of the default security group.")
|
||||
private List<Long> securityGroupIdList;
|
||||
|
||||
// Internal flag to allow assignment without adding a network
|
||||
private boolean skipNetwork = false;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ public class DeployVMCmdByAdmin extends DeployVMCmd implements AdminCmd {
|
|||
@Parameter(name = ApiConstants.CLUSTER_ID, type = CommandType.UUID, entityType = ClusterResponse.class, description = "Destination Cluster ID to deploy the Instance to - parameter available for root admin only", since = "4.13")
|
||||
private Long clusterId;
|
||||
|
||||
@Parameter(name = ApiConstants.BLANK_INSTANCE,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "Whether to create a blank instance without storage and network",
|
||||
since = "4.23.0")
|
||||
private Boolean blankInstance;
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
|
@ -49,6 +55,11 @@ public class DeployVMCmdByAdmin extends DeployVMCmd implements AdminCmd {
|
|||
return clusterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlankInstance() {
|
||||
return Boolean.TRUE.equals(blankInstance);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
////////////////// Setters //////////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -56,4 +67,8 @@ public class DeployVMCmdByAdmin extends DeployVMCmd implements AdminCmd {
|
|||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public void setBlankInstance(boolean blankInstance) {
|
||||
this.blankInstance = blankInstance;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,6 @@ public class DeployVMCmd extends BaseDeployVMCmd {
|
|||
@Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class, since = "4.21")
|
||||
private Long snapshotId;
|
||||
|
||||
@Parameter(name = "blank", type = CommandType.BOOLEAN, since = "4.23.0")
|
||||
private Boolean blankInstance;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -95,7 +91,7 @@ public class DeployVMCmd extends BaseDeployVMCmd {
|
|||
}
|
||||
|
||||
public boolean isBlankInstance() {
|
||||
return Boolean.TRUE.equals(blankInstance);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -191,10 +187,6 @@ public class DeployVMCmd extends BaseDeployVMCmd {
|
|||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
public void setBlankInstance(boolean blankInstance) {
|
||||
this.blankInstance = blankInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
UserVm result;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd implements UserC
|
|||
entityType = StoragePoolResponse.class,
|
||||
description = "Storage pool ID to create the volume in. Cannot be used with the snapshotid parameter.",
|
||||
authorized = {RoleType.Admin},
|
||||
since = "4.23.0")
|
||||
since = "4.22.1")
|
||||
private Long storageId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package org.apache.cloudstack.api.command.admin.vm;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class DeployVMCmdByAdminTest {
|
||||
|
||||
@InjectMocks
|
||||
private DeployVMCmdByAdmin cmd;
|
||||
|
||||
@Test
|
||||
public void testIsBlankInstance_default() {
|
||||
assertFalse(cmd.isBlankInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsBlankInstance_true() {
|
||||
ReflectionTestUtils.setField(cmd, "blankInstance", true);
|
||||
assertTrue(cmd.isBlankInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsBlankInstance_false() {
|
||||
ReflectionTestUtils.setField(cmd, "blankInstance", false);
|
||||
assertFalse(cmd.isBlankInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBlankInstance_default() {
|
||||
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
|
||||
assertNull(obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBlankInstance_true() {
|
||||
cmd.setBlankInstance(true);
|
||||
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
|
||||
assertNotNull(obj);
|
||||
assertTrue((boolean)obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetBlankInstance_false() {
|
||||
cmd.setBlankInstance(false);
|
||||
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
|
||||
assertNotNull(obj);
|
||||
assertFalse((boolean)obj);
|
||||
}
|
||||
}
|
||||
|
|
@ -623,11 +623,5 @@ public class DeployVMCmdTest {
|
|||
@Test
|
||||
public void testIsBlankInstance() {
|
||||
assertFalse(cmd.isBlankInstance());
|
||||
|
||||
cmd.setBlankInstance(true);
|
||||
assertTrue(cmd.isBlankInstance());
|
||||
|
||||
cmd.setBlankInstance(false);
|
||||
assertFalse(cmd.isBlankInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager, C
|
|||
return _projectAccountDao.persist(projectAccountVO);
|
||||
}
|
||||
|
||||
public ProjectAccount assignUserToProject(Project project, long userId, long accountId, Role userRole, Long projectRoleId) {
|
||||
public ProjectAccount assignUserToProject(Project project, long userId, long accountId, Role userRole, Long projectRoleId) {
|
||||
return assignAccountToProject(project, accountId, userRole, userId, projectRoleId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
|
||||
private static final long GiB_TO_BYTES = 1024 * 1024 * 1024;
|
||||
|
||||
private static final String KVM_VM_DUMMY_TEMPLATE_NAME = "kvm-vm-dummy-template";
|
||||
private static final String KVM_BLANK_VM_TEMPLATE_NAME = "kvm-blank-vm-template";
|
||||
|
||||
|
||||
@Inject
|
||||
|
|
@ -10115,7 +10115,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
protected boolean isBlankInstanceDefaultTemplate(VirtualMachineTemplate template) {
|
||||
return KVM_VM_DUMMY_TEMPLATE_NAME.equals(template.getUniqueName());
|
||||
return KVM_BLANK_VM_TEMPLATE_NAME.equals(template.getUniqueName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -10128,18 +10128,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
VMTemplateVO getBlankInstanceTemplate() {
|
||||
VMTemplateVO template = _templateDao.findByName(KVM_VM_DUMMY_TEMPLATE_NAME);
|
||||
VMTemplateVO template = _templateDao.findByName(KVM_BLANK_VM_TEMPLATE_NAME);
|
||||
if (template != null) {
|
||||
return template;
|
||||
}
|
||||
template = VMTemplateVO.createSystemIso(_templateDao.getNextInSequence(Long.class, "id"),
|
||||
KVM_VM_DUMMY_TEMPLATE_NAME, KVM_VM_DUMMY_TEMPLATE_NAME, true,
|
||||
KVM_BLANK_VM_TEMPLATE_NAME, KVM_BLANK_VM_TEMPLATE_NAME, true,
|
||||
"", true, 64, Account.ACCOUNT_ID_SYSTEM, "",
|
||||
"Dummy Template for KVM VM", false, 1);
|
||||
"Blank Template for KVM VM", false, 1);
|
||||
template.setState(VirtualMachineTemplate.State.Active);
|
||||
template.setFormat(ImageFormat.QCOW2);
|
||||
template = _templateDao.persist(template);
|
||||
// _templateDao.remove(template.getId());
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,11 +225,6 @@ known_categories = {
|
|||
'Restore' : 'Backup and Recovery',
|
||||
'startBackup' : 'Backup and Recovery',
|
||||
'finalizeBackup' : 'Backup and Recovery',
|
||||
'createImageTransfer' : 'Backup and Recovery',
|
||||
'finalizeImageTransfer' : 'Backup and Recovery',
|
||||
'listImageTransfers' : 'Backup and Recovery',
|
||||
'listVmCheckpoints' : 'Backup and Recovery',
|
||||
'deleteVmCheckpoint' : 'Backup and Recovery',
|
||||
'ImageTransfer' : 'Backup and Recovery',
|
||||
'VmCheckpoint' : 'Backup and Recovery',
|
||||
'UnmanagedInstance': 'Virtual Machine',
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ export default {
|
|||
}
|
||||
},
|
||||
created () {
|
||||
console.log('---------------', this.$route.meta.name)
|
||||
switch (this.$route.meta.name) {
|
||||
case 'account':
|
||||
this.scopeKey = 'accountid'
|
||||
|
|
|
|||
Loading…
Reference in New Issue