-
Notifications
You must be signed in to change notification settings - Fork 1.3k
api,server: allow updating hypervisor capabilities with hypervisor and version #8475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
308819c
1e39514
96c662d
98cbf5f
1a85d32
a381322
ff9a5f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5068,31 +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(); | ||
|
vishesh92 marked this conversation as resolved.
Outdated
|
||
| final String hypervisorStr = cmd.getHypervisor(); | ||
| final String hypervisorVersion = cmd.getHypervisorVersion(); | ||
| final Boolean securityGroupEnabled = cmd.getSecurityGroupEnabled(); | ||
| final Long maxGuestsLimit = cmd.getMaxGuestsLimit(); | ||
| final Integer maxDataVolumesLimit = cmd.getMaxDataVolumesLimit(); | ||
| final Boolean storageMotionSupported = cmd.getStorageMotionSupported(); | ||
| final Integer maxHostsPerClusterLimit = cmd.getMaxHostsPerClusterLimit(); | ||
| final Boolean vmSnapshotEnabled = cmd.getVmSnapshotEnabled(); | ||
| 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; | ||
| } | ||
| HypervisorCapabilitiesVO hpvCapabilities = getHypervisorCapabilitiesForUpdate(id, hypervisorStr, hypervisorVersion); | ||
|
|
||
| final boolean updateNeeded = securityGroupEnabled != null || maxGuestsLimit != null || | ||
| maxDataVolumesLimit != null || storageMotionSupported != null || maxHostsPerClusterLimit != null || | ||
| vmSnapshotEnabled != null; | ||
| if (!updateNeeded) { | ||
| return hpvCapabilities; | ||
| } | ||
| if (StringUtils.isNotBlank(hypervisorVersion) && !hpvCapabilities.getHypervisorVersion().equals(hypervisorVersion)) { | ||
|
JoaoJandre marked this conversation as resolved.
|
||
| s_logger.debug("Hypervisor capabilities for hypervisor: %s and version: %s does not exist, creating a copy from the parent version: %s for update"); | ||
|
shwstppr marked this conversation as resolved.
Outdated
|
||
| HypervisorCapabilitiesVO copy = new HypervisorCapabilitiesVO(hpvCapabilities); | ||
| copy.setHypervisorVersion(hypervisorVersion); | ||
| hpvCapabilities = _hypervisorCapabilitiesDao.persist(copy); | ||
| } | ||
|
|
||
| hpvCapabilities = _hypervisorCapabilitiesDao.createForUpdate(id); | ||
| hpvCapabilities = _hypervisorCapabilitiesDao.createForUpdate(hpvCapabilities.getId()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to set Executing this for the first time creates an entry which is a duplicate of the parent hypervisor. And subsequent command just fails.
shwstppr marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (securityGroupEnabled != null) { | ||
| hpvCapabilities.setSecurityGroupEnabled(securityGroupEnabled); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.