[
https://issues.apache.org/jira/browse/CLOUDSTACK-9025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254139#comment-16254139
]
ASF GitHub Bot commented on CLOUDSTACK-9025:
--------------------------------------------
rafaelweingartner commented on a change in pull request #2315: A comprehensive
solution for #CLOUDSTACK-9025.
URL: https://github.com/apache/cloudstack/pull/2315#discussion_r150219895
##########
File path:
plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java
##########
@@ -167,35 +170,61 @@ public boolean trackVmHostChange() {
@Override
public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command
cmd) {
- LOGGER.debug("getCommandHostDelegation: " + cmd.getClass());
if (cmd instanceof StorageSubSystemCommand) {
StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
c.setExecuteInSequence(true);
}
- if (cmd instanceof CopyCommand) {
- CopyCommand cpyCommand = (CopyCommand)cmd;
- DataTO srcData = cpyCommand.getSrcTO();
- DataTO destData = cpyCommand.getDestTO();
-
- if (srcData.getHypervisorType() == HypervisorType.XenServer &&
srcData.getObjectType() == DataObjectType.SNAPSHOT &&
- destData.getObjectType() == DataObjectType.TEMPLATE) {
- DataStoreTO srcStore = srcData.getDataStore();
- DataStoreTO destStore = destData.getDataStore();
- if (srcStore instanceof NfsTO && destStore instanceof NfsTO) {
- HostVO host = hostDao.findById(hostId);
- hostDao.loadDetails(host);
- String hypervisorVersion = host.getHypervisorVersion();
- String snapshotHotFixVersion =
host.getDetail(XenserverConfigs.XS620HotFix);
- if (hypervisorVersion != null &&
!hypervisorVersion.equalsIgnoreCase("6.1.0")) {
- if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") &&
- !(snapshotHotFixVersion != null &&
snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) {
- return new Pair<Boolean, Long>(Boolean.TRUE, new
Long(host.getId()));
- }
- }
- }
- }
+ boolean isCopyCommand = cmd instanceof CopyCommand;
+ Pair<Boolean, Long> defaultHostToExecuteCommands =
super.getCommandHostDelegation(hostId, cmd);
+ if (!isCopyCommand) {
+ logger.debug("We are returning the default host to execute
commands because the command is not of Copy type.");
+ return defaultHostToExecuteCommands;
+ }
+ CopyCommand copyCommand = (CopyCommand)cmd;
+ DataTO srcData = copyCommand.getSrcTO();
+ DataTO destData = copyCommand.getDestTO();
+
+ boolean isSourceDataHypervisorXenServer = srcData.getHypervisorType()
== HypervisorType.XenServer;
+ if (!isSourceDataHypervisorXenServer) {
+ logger.debug("We are returning the default host to execute
commands because the target hypervisor of the source data is not XenServer.");
+ return defaultHostToExecuteCommands;
+ }
+ DataStoreTO srcStore = srcData.getDataStore();
+ DataStoreTO destStore = destData.getDataStore();
+ boolean isSourceAndDestinationNfsObjects = srcStore instanceof NfsTO
&& destStore instanceof NfsTO;
+ if (!isSourceAndDestinationNfsObjects) {
+ logger.debug("We are returning the default host to execute
commands because the source and destination objects are not NFS type.");
+ return defaultHostToExecuteCommands;
+ }
+ boolean isSourceObjectSnapshotTypeAndDestinationObjectTemplateType =
srcData.getObjectType() == DataObjectType.SNAPSHOT
+ && destData.getObjectType() == DataObjectType.TEMPLATE;
+ if (!isSourceObjectSnapshotTypeAndDestinationObjectTemplateType) {
+ logger.debug("We are returning the default host to execute
commands because the source and destination objects are not snapshot and
template respectively.");
+ return defaultHostToExecuteCommands;
+ }
+ long snapshotId = srcData.getId();
+ HostVO hostCandidateToExecutedCommand =
hostDao.findHostConnectedToSnapshotStoragePoolToExecuteCommand(snapshotId);
+ hostDao.loadDetails(hostCandidateToExecutedCommand);
+ String hypervisorVersion =
hostCandidateToExecutedCommand.getHypervisorVersion();
+ if (StringUtils.isBlank(hypervisorVersion)) {
+ logger.debug("We are returning the default host to execute
commands because the hypervisor version is blank.");
+ return defaultHostToExecuteCommands;
+ }
+ boolean isXenServer610 = StringUtils.equals(hypervisorVersion,
"6.1.0");
+ if (isXenServer610) {
+ logger.debug("We are returning the default host to execute
commands because the hypervisor version is 6.1.0.");
+ return defaultHostToExecuteCommands;
+ }
+ String snapshotHotFixVersion =
hostCandidateToExecutedCommand.getDetail(XenserverConfigs.XS620HotFix);
+ boolean isXenServer620 = StringUtils.equals(hypervisorVersion,
"6.2.0");
+ if (isXenServer620 &&
!StringUtils.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004,
snapshotHotFixVersion)) {
Review comment:
I have no idea :)
I only re-worked the code, the logic here is the same as it was before. I
made sure everything was kept the same with test cases.
The result of this code is the same as the replaced one. The difference is
that I am not using those if/if/if/if/if.....
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Unable to deploy VM instance from template if template spin from linked clone
> snapshot
> --------------------------------------------------------------------------------------
>
> Key: CLOUDSTACK-9025
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9025
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Components: XenServer
> Affects Versions: 4.5.2
> Environment: XenServer 6.5
> Reporter: Anshul Gangwar
> Assignee: Anshul Gangwar
> Priority: Critical
> Fix For: 4.6.0
>
>
> As default, CloudStack create linked clone snapshot for VM instance . When we
> take a snapshot for the VM, and create a template based on such snapshot,
> CloudStack only download incremental VHD as template file, as a result, the
> VM instance fail to deploy as it is incomplete.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)