vishesh92 commented on code in PR #8475:
URL: https://github.com/apache/cloudstack/pull/8475#discussion_r1650457281
##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -5068,30 +5068,66 @@ public Pair<List<? extends HypervisorCapabilities>,
Integer> listHypervisorCapab
return new Pair<List<? extends HypervisorCapabilities>,
Integer>(result.first(), result.second());
}
+ protected HypervisorCapabilitiesVO
getHypervisorCapabilitiesForUpdate(final Long id, final String hypervisorStr,
final String hypervisorVersion) {
+ if (id == null && StringUtils.isAllEmpty(hypervisorStr,
hypervisorVersion)) {
+ throw new InvalidParameterValueException("Either ID or hypervisor
and hypervisor version must be specified");
+ }
+ if (id != null) {
+ if (!StringUtils.isAllBlank(hypervisorStr, hypervisorVersion)) {
+ throw new InvalidParameterValueException("ID can not be
specified together with hypervisor and hypervisor version");
+ }
+ HypervisorCapabilitiesVO hpvCapabilities =
_hypervisorCapabilitiesDao.findById(id, true);
+ if (hpvCapabilities == null) {
+ final InvalidParameterValueException ex = new
InvalidParameterValueException("unable to find the hypervisor capabilities for
specified id");
+ ex.addProxyObject(id.toString(), "Id");
+ throw ex;
+ }
+ return hpvCapabilities;
+ }
+ if (StringUtils.isAnyBlank(hypervisorStr, hypervisorVersion)) {
+ throw new InvalidParameterValueException("Hypervisor and
hypervisor version must be specified together");
+ }
+ HypervisorType hypervisorType = HypervisorType.getType(hypervisorStr);
+ if (hypervisorType == HypervisorType.None) {
+ throw new InvalidParameterValueException("Invalid hypervisor
specified");
+ }
+ HypervisorCapabilitiesVO hpvCapabilities =
_hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(hypervisorType,
hypervisorVersion);
+ if (hpvCapabilities == null) {
+ final InvalidParameterValueException ex = new
InvalidParameterValueException("Unable to find the hypervisor capabilities for
specified hypervisor and hypervisor version");
+ ex.addProxyObject(hypervisorStr, "hypervisor");
+ ex.addProxyObject(hypervisorVersion, "hypervisorVersion");
+ throw ex;
+ }
+ return hpvCapabilities;
+ }
+
@Override
public HypervisorCapabilities
updateHypervisorCapabilities(UpdateHypervisorCapabilitiesCmd cmd) {
final Long id = cmd.getId();
Review Comment:
```suggestion
Long id = cmd.getId();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]