Skip to content

Commit 1a37925

Browse files
committed
address review comments
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent c65dfa1 commit 1a37925

10 files changed

Lines changed: 82 additions & 29 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class AssignVMCmd extends BaseCmd {
8585
"In case no security groups are provided the Instance is part of the default security group.")
8686
private List<Long> securityGroupIdList;
8787

88+
// Internal flag to allow assignment without adding a network
8889
private boolean skipNetwork = false;
8990

9091
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/DeployVMCmdByAdmin.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public class DeployVMCmdByAdmin extends DeployVMCmd implements AdminCmd {
4141
@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")
4242
private Long clusterId;
4343

44+
@Parameter(name = ApiConstants.BLANK_INSTANCE,
45+
type = CommandType.BOOLEAN,
46+
description = "Whether to create a blank instance without storage and network",
47+
since = "4.23.0")
48+
private Boolean blankInstance;
49+
4450
public Long getPodId() {
4551
return podId;
4652
}
@@ -49,11 +55,20 @@ public Long getClusterId() {
4955
return clusterId;
5056
}
5157

58+
@Override
59+
public boolean isBlankInstance() {
60+
return Boolean.TRUE.equals(blankInstance);
61+
}
62+
5263
/////////////////////////////////////////////////////
5364
////////////////// Setters //////////////////////////
5465
/////////////////////////////////////////////////////
5566

5667
public void setClusterId(Long clusterId) {
5768
this.clusterId = clusterId;
5869
}
70+
71+
public void setBlankInstance(boolean blankInstance) {
72+
this.blankInstance = blankInstance;
73+
}
5974
}

api/src/main/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ public class DeployVMCmd extends BaseDeployVMCmd {
6666
@Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class, since = "4.21")
6767
private Long snapshotId;
6868

69-
@Parameter(name = "blank", type = CommandType.BOOLEAN, since = "4.23.0")
70-
private Boolean blankInstance;
71-
72-
7369
/////////////////////////////////////////////////////
7470
/////////////////// Accessors ///////////////////////
7571
/////////////////////////////////////////////////////
@@ -95,7 +91,7 @@ public boolean isVolumeOrSnapshotProvided() {
9591
}
9692

9793
public boolean isBlankInstance() {
98-
return Boolean.TRUE.equals(blankInstance);
94+
return false;
9995
}
10096

10197

@@ -191,10 +187,6 @@ public void setSnapshotId(Long snapshotId) {
191187
this.snapshotId = snapshotId;
192188
}
193189

194-
public void setBlankInstance(boolean blankInstance) {
195-
this.blankInstance = blankInstance;
196-
}
197-
198190
@Override
199191
public void execute() {
200192
UserVm result;

api/src/main/java/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd implements UserC
115115
entityType = StoragePoolResponse.class,
116116
description = "Storage pool ID to create the volume in. Cannot be used with the snapshotid parameter.",
117117
authorized = {RoleType.Admin},
118-
since = "4.23.0")
118+
since = "4.22.1")
119119
private Long storageId;
120120

121121
/////////////////////////////////////////////////////
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.apache.cloudstack.api.command.admin.vm;
2+
3+
import static org.junit.Assert.assertFalse;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertNull;
6+
import static org.junit.Assert.assertTrue;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
import org.mockito.InjectMocks;
11+
import org.mockito.junit.MockitoJUnitRunner;
12+
import org.springframework.test.util.ReflectionTestUtils;
13+
14+
@RunWith(MockitoJUnitRunner.class)
15+
public class DeployVMCmdByAdminTest {
16+
17+
@InjectMocks
18+
private DeployVMCmdByAdmin cmd;
19+
20+
@Test
21+
public void testIsBlankInstance_default() {
22+
assertFalse(cmd.isBlankInstance());
23+
}
24+
25+
@Test
26+
public void testIsBlankInstance_true() {
27+
ReflectionTestUtils.setField(cmd, "blankInstance", true);
28+
assertTrue(cmd.isBlankInstance());
29+
}
30+
31+
@Test
32+
public void testIsBlankInstance_false() {
33+
ReflectionTestUtils.setField(cmd, "blankInstance", false);
34+
assertFalse(cmd.isBlankInstance());
35+
}
36+
37+
@Test
38+
public void testSetBlankInstance_default() {
39+
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
40+
assertNull(obj);
41+
}
42+
43+
@Test
44+
public void testSetBlankInstance_true() {
45+
cmd.setBlankInstance(true);
46+
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
47+
assertNotNull(obj);
48+
assertTrue((boolean)obj);
49+
}
50+
51+
@Test
52+
public void testSetBlankInstance_false() {
53+
cmd.setBlankInstance(false);
54+
Object obj = ReflectionTestUtils.getField(cmd, "blankInstance");
55+
assertNotNull(obj);
56+
assertFalse((boolean)obj);
57+
}
58+
}

api/src/test/java/org/apache/cloudstack/api/command/user/vm/DeployVMCmdTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,5 @@ public void testSetDynamicScalingEnabled() {
623623
@Test
624624
public void testIsBlankInstance() {
625625
assertFalse(cmd.isBlankInstance());
626-
627-
cmd.setBlankInstance(true);
628-
assertTrue(cmd.isBlankInstance());
629-
630-
cmd.setBlankInstance(false);
631-
assertFalse(cmd.isBlankInstance());
632626
}
633627
}

server/src/main/java/com/cloud/projects/ProjectManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public ProjectAccount assignAccountToProject(Project project, long accountId, Pr
479479
return _projectAccountDao.persist(projectAccountVO);
480480
}
481481

482-
public ProjectAccount assignUserToProject(Project project, long userId, long accountId, Role userRole, Long projectRoleId) {
482+
public ProjectAccount assignUserToProject(Project project, long userId, long accountId, Role userRole, Long projectRoleId) {
483483
return assignAccountToProject(project, accountId, userRole, userId, projectRoleId);
484484
}
485485

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
426426

427427
private static final long GiB_TO_BYTES = 1024 * 1024 * 1024;
428428

429-
private static final String KVM_VM_DUMMY_TEMPLATE_NAME = "kvm-vm-dummy-template";
429+
private static final String KVM_BLANK_VM_TEMPLATE_NAME = "kvm-blank-vm-template";
430430

431431

432432
@Inject
@@ -10115,7 +10115,7 @@ private void setVncPasswordForKvmIfAvailable(Map<String, String> customParameter
1011510115
}
1011610116

1011710117
protected boolean isBlankInstanceDefaultTemplate(VirtualMachineTemplate template) {
10118-
return KVM_VM_DUMMY_TEMPLATE_NAME.equals(template.getUniqueName());
10118+
return KVM_BLANK_VM_TEMPLATE_NAME.equals(template.getUniqueName());
1011910119
}
1012010120

1012110121
@Override
@@ -10128,18 +10128,17 @@ public boolean isBlankInstance(VirtualMachineTemplate template) {
1012810128
}
1012910129

1013010130
VMTemplateVO getBlankInstanceTemplate() {
10131-
VMTemplateVO template = _templateDao.findByName(KVM_VM_DUMMY_TEMPLATE_NAME);
10131+
VMTemplateVO template = _templateDao.findByName(KVM_BLANK_VM_TEMPLATE_NAME);
1013210132
if (template != null) {
1013310133
return template;
1013410134
}
1013510135
template = VMTemplateVO.createSystemIso(_templateDao.getNextInSequence(Long.class, "id"),
10136-
KVM_VM_DUMMY_TEMPLATE_NAME, KVM_VM_DUMMY_TEMPLATE_NAME, true,
10136+
KVM_BLANK_VM_TEMPLATE_NAME, KVM_BLANK_VM_TEMPLATE_NAME, true,
1013710137
"", true, 64, Account.ACCOUNT_ID_SYSTEM, "",
10138-
"Dummy Template for KVM VM", false, 1);
10138+
"Blank Template for KVM VM", false, 1);
1013910139
template.setState(VirtualMachineTemplate.State.Active);
1014010140
template.setFormat(ImageFormat.QCOW2);
1014110141
template = _templateDao.persist(template);
10142-
// _templateDao.remove(template.getId());
1014310142
return template;
1014410143
}
1014510144
}

tools/apidoc/gen_toc.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@
225225
'Restore' : 'Backup and Recovery',
226226
'startBackup' : 'Backup and Recovery',
227227
'finalizeBackup' : 'Backup and Recovery',
228-
'createImageTransfer' : 'Backup and Recovery',
229-
'finalizeImageTransfer' : 'Backup and Recovery',
230-
'listImageTransfers' : 'Backup and Recovery',
231-
'listVmCheckpoints' : 'Backup and Recovery',
232-
'deleteVmCheckpoint' : 'Backup and Recovery',
233228
'ImageTransfer' : 'Backup and Recovery',
234229
'VmCheckpoint' : 'Backup and Recovery',
235230
'UnmanagedInstance': 'Virtual Machine',

ui/src/components/view/SettingsTab.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export default {
8787
}
8888
},
8989
created () {
90-
console.log('---------------', this.$route.meta.name)
9190
switch (this.$route.meta.name) {
9291
case 'account':
9392
this.scopeKey = 'accountid'

0 commit comments

Comments
 (0)