Skip to content

Commit affd3d8

Browse files
committed
address config comment, refactor, add arch to sysvm, routers
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 11d5ba9 commit affd3d8

File tree

17 files changed

+94
-28
lines changed

17 files changed

+94
-28
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
2322
import org.apache.cloudstack.api.APICommand;
2423
import org.apache.cloudstack.api.ApiConstants;
2524
import org.apache.cloudstack.api.BaseListCmd;
@@ -28,7 +27,9 @@
2827
import org.apache.cloudstack.api.response.ListResponse;
2928
import org.apache.cloudstack.api.response.PodResponse;
3029
import org.apache.cloudstack.api.response.ZoneResponse;
30+
import org.apache.commons.lang3.StringUtils;
3131

32+
import com.cloud.cpu.CPU;
3233
import com.cloud.org.Cluster;
3334
import com.cloud.utils.Pair;
3435

@@ -117,8 +118,8 @@ public Boolean getShowCapacities() {
117118
return showCapacities;
118119
}
119120

120-
public String getArch() {
121-
return arch;
121+
public CPU.CPUArch getArch() {
122+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
122123
}
123124

124125
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
2524
import org.apache.cloudstack.api.APICommand;
2625
import org.apache.cloudstack.api.ApiCommandResourceType;
2726
import org.apache.cloudstack.api.ApiConstants;
@@ -34,7 +33,9 @@
3433
import org.apache.cloudstack.api.response.PodResponse;
3534
import org.apache.cloudstack.api.response.UserVmResponse;
3635
import org.apache.cloudstack.api.response.ZoneResponse;
36+
import org.apache.commons.lang3.StringUtils;
3737

38+
import com.cloud.cpu.CPU;
3839
import com.cloud.exception.InvalidParameterValueException;
3940
import com.cloud.host.Host;
4041
import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -192,8 +193,8 @@ public String getHostOutOfBandManagementPowerState() {
192193
return outOfBandManagementPowerState;
193194
}
194195

195-
public String getArch() {
196-
return arch;
196+
public CPU.CPUArch getArch() {
197+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
197198
}
198199

199200
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.router;
1818

19-
import org.apache.commons.lang.BooleanUtils;
20-
2119
import org.apache.cloudstack.api.APICommand;
2220
import org.apache.cloudstack.api.ApiCommandResourceType;
2321
import org.apache.cloudstack.api.ApiConstants;
@@ -32,7 +30,10 @@
3230
import org.apache.cloudstack.api.response.UserVmResponse;
3331
import org.apache.cloudstack.api.response.VpcResponse;
3432
import org.apache.cloudstack.api.response.ZoneResponse;
33+
import org.apache.commons.lang.BooleanUtils;
34+
import org.apache.commons.lang3.StringUtils;
3535

36+
import com.cloud.cpu.CPU;
3637
import com.cloud.network.router.VirtualRouter.Role;
3738
import com.cloud.vm.VirtualMachine;
3839

@@ -86,6 +87,11 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
8687
description = "if true is passed for this parameter, also fetch last executed health check results for the router. Default is false")
8788
private Boolean fetchHealthCheckResults;
8889

90+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
91+
description = "CPU arch of the router",
92+
since = "4.20.1")
93+
private String arch;
94+
8995
/////////////////////////////////////////////////////
9096
/////////////////// Accessors ///////////////////////
9197
/////////////////////////////////////////////////////
@@ -146,6 +152,10 @@ public boolean shouldFetchHealthCheckResults() {
146152
return BooleanUtils.isTrue(fetchHealthCheckResults);
147153
}
148154

155+
public CPU.CPUArch getArch() {
156+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
157+
}
158+
149159

150160
/////////////////////////////////////////////////////
151161
/////////////// API Implementation///////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22-
2322
import org.apache.cloudstack.api.APICommand;
2423
import org.apache.cloudstack.api.ApiCommandResourceType;
2524
import org.apache.cloudstack.api.ApiConstants;
@@ -31,7 +30,9 @@
3130
import org.apache.cloudstack.api.response.StoragePoolResponse;
3231
import org.apache.cloudstack.api.response.SystemVmResponse;
3332
import org.apache.cloudstack.api.response.ZoneResponse;
33+
import org.apache.commons.lang3.StringUtils;
3434

35+
import com.cloud.cpu.CPU;
3536
import com.cloud.utils.Pair;
3637
import com.cloud.vm.VirtualMachine;
3738

@@ -74,6 +75,11 @@ public class ListSystemVMsCmd extends BaseListCmd {
7475
since = "3.0.1")
7576
private Long storageId;
7677

78+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
79+
description = "CPU arch of the system VM",
80+
since = "4.20.1")
81+
private String arch;
82+
7783
/////////////////////////////////////////////////////
7884
/////////////////// Accessors ///////////////////////
7985
/////////////////////////////////////////////////////
@@ -110,6 +116,10 @@ public Long getStorageId() {
110116
return storageId;
111117
}
112118

119+
public CPU.CPUArch getArch() {
120+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
121+
}
122+
113123
/////////////////////////////////////////////////////
114124
/////////////// API Implementation///////////////////
115125
/////////////////////////////////////////////////////

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
import org.apache.cloudstack.api.response.UserVmResponse;
4747
import org.apache.cloudstack.api.response.VpcResponse;
4848
import org.apache.cloudstack.api.response.ZoneResponse;
49-
import org.apache.commons.lang3.BooleanUtils;
5049
import org.apache.commons.collections.CollectionUtils;
50+
import org.apache.commons.lang3.BooleanUtils;
51+
import org.apache.commons.lang3.StringUtils;
5152

53+
import com.cloud.cpu.CPU;
5254
import com.cloud.exception.InvalidParameterValueException;
5355
import com.cloud.server.ResourceIcon;
5456
import com.cloud.server.ResourceTag;
@@ -297,8 +299,8 @@ public Boolean getVnf() {
297299
return isVnf;
298300
}
299301

300-
public String getArch() {
301-
return arch;
302+
public CPU.CPUArch getArch() {
303+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
302304
}
303305

304306
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ public class DomainRouterResponse extends BaseResponseWithAnnotations implements
245245
@Param(description = "the version of the code / software in the router")
246246
private String softwareVersion;
247247

248+
@SerializedName(ApiConstants.ARCH)
249+
@Param(description = "CPU arch of the router", since = "4.20.1")
250+
private String arch;
251+
248252
public DomainRouterResponse() {
249253
nics = new LinkedHashSet<NicResponse>();
250254
}
@@ -518,4 +522,8 @@ public String getSoftwareVersion() {
518522
public void setSoftwareVersion(String softwareVersion) {
519523
this.softwareVersion = softwareVersion;
520524
}
525+
526+
public void setArch(String arch) {
527+
this.arch = arch;
528+
}
521529
}

api/src/main/java/org/apache/cloudstack/api/response/SystemVmResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
186186
@Param(description = "the name of the service offering of the system virtual machine.")
187187
private String serviceOfferingName;
188188

189+
@SerializedName(ApiConstants.ARCH)
190+
@Param(description = "CPU arch of the system VM", since = "4.20.1")
191+
private String arch;
192+
189193
@Override
190194
public String getObjectId() {
191195
return this.getId();
@@ -490,4 +494,8 @@ public String getServiceOfferingName() {
490494
public void setServiceOfferingName(String serviceOfferingName) {
491495
this.serviceOfferingName = serviceOfferingName;
492496
}
497+
498+
public void setArch(String arch) {
499+
this.arch = arch;
500+
}
493501
}

engine/schema/src/main/resources/META-INF/db/views/cloud.domain_router_view.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ select
5858
host.resource_state host_resource_state,
5959
vm_template.id template_id,
6060
vm_template.uuid template_uuid,
61+
vm_template.arch arch,
6162
service_offering.id service_offering_id,
6263
service_offering.uuid service_offering_uuid,
6364
service_offering.name service_offering_name,

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
17181718
if (template != null) {
17191719
vmResponse.setTemplateId(template.getUuid());
17201720
vmResponse.setTemplateName(template.getName());
1721+
vmResponse.setArch(template.getArch().getType());
17211722
}
17221723
vmResponse.setCreated(vm.getCreated());
17231724
vmResponse.setHypervisor(vm.getHypervisorType().getHypervisorDisplayName());

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
12981298
Long userId = cmd.getUserId();
12991299
Long userdataId = cmd.getUserdataId();
13001300
Map<String, String> tags = cmd.getTags();
1301-
final String arch = cmd.getArch();
1301+
final CPU.CPUArch arch = cmd.getArch();
13021302

13031303
boolean isAdmin = false;
13041304
boolean isRootAdmin = false;
@@ -1526,7 +1526,7 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
15261526
}
15271527

15281528
Boolean isVnf = cmd.getVnf();
1529-
boolean templateJoinNeeded = isVnf != null || StringUtils.isNoneBlank(arch);
1529+
boolean templateJoinNeeded = isVnf != null || arch != null;
15301530
if (templateJoinNeeded) {
15311531
SearchBuilder<VMTemplateVO> templateSearch = _templateDao.createSearchBuilder();
15321532
templateSearch.and("templateArch", templateSearch.entity().getArch(), Op.EQ);
@@ -1658,7 +1658,7 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
16581658
userVmSearchCriteria.setJoinParameters("vmTemplate", "templateTypeNEQ", TemplateType.VNF);
16591659
}
16601660
}
1661-
if (StringUtils.isNotBlank(arch)) {
1661+
if (arch != null) {
16621662
userVmSearchCriteria.setJoinParameters("vmTemplate", "templateArch", arch);
16631663
}
16641664

@@ -2361,7 +2361,7 @@ public Pair<List<Long>, Integer> searchForServerIdsAndCount(ListHostsCmd cmd) {
23612361
Long startIndex = cmd.getStartIndex();
23622362
Long pageSize = cmd.getPageSizeVal();
23632363
Hypervisor.HypervisorType hypervisorType = cmd.getHypervisor();
2364-
String arch = cmd.getArch();
2364+
final CPU.CPUArch arch = cmd.getArch();
23652365

23662366
Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
23672367

@@ -2458,7 +2458,7 @@ public Pair<List<Long>, Integer> searchForServerIdsAndCount(ListHostsCmd cmd) {
24582458
sc.setParameters("hypervisor_type", hypervisorType);
24592459
}
24602460

2461-
if (StringUtils.isNotBlank(arch)) {
2461+
if (arch != null) {
24622462
sc.setParameters("arch", arch);
24632463
}
24642464

0 commit comments

Comments
 (0)