CLOUDSTACK-3908: fix extract path

This commit is contained in:
Edison Su 2013-07-29 16:57:23 -07:00
parent ccec275e09
commit f486d36f88
2 changed files with 2 additions and 67 deletions

View File

@ -140,12 +140,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
if (templateName.endsWith(".ova")) {
if(new File(templateName).exists()) {
s_logger.debug("OVA files exists. succeed. ");
return templateName;
return installPath;
} else {
if (new File(templateName + ".meta").exists()) {
ovafileName = getOVAFromMetafile(templateName + ".meta");
s_logger.debug("OVA file in meta file is " + ovafileName);
return installPath;
return ovafileName;
} else {
String msg = "Unable to find ova meta or ova file to prepare template (vmware)";
s_logger.error(msg);

View File

@ -342,69 +342,4 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
return profile;
}
@Override
public TemplateProfile prepareExtractTemplate(ExtractTemplateCmd extractcmd) {
TemplateProfile profile = super.prepareExtractTemplate(extractcmd);
VMTemplateVO template = profile.getTemplate();
Long zoneId = profile.getZoneId();
Long templateId = template.getId();
// Simply return profile if non-ESX hypervisor.
if (template.getHypervisorType() == HypervisorType.VMware) {
PrepareOVAPackingCommand cmd = null;
String zoneName="";
List<DataStore> imageStores = null;
if (!template.isCrossZones()) {
if (zoneId == null) {
throw new CloudRuntimeException("ZoneId cannot be null for a template that is not available across zones");
}
// Else get the list of image stores in this zone's scope.
DataCenterVO zone = _dcDao.findById(zoneId);
zoneName = zone.getName();
imageStores = this.storeMgr.getImageStoresByScope(new ZoneScope(profile.getZoneId()));
} else {
// template is available across zones. Get a list of all image stores.
imageStores = this.storeMgr.listImageStores();
}
if (imageStores == null || imageStores.size() == 0) {
throw new CloudRuntimeException("Unable to find an image store zone when trying to download template " + profile.getTemplate());
}
s_logger.debug("Attempting to mark template host refs for template: " + template.getName() + " as destroyed in zone: " + zoneName);
// Make sure the template is downloaded to all the necessary secondary storage hosts
for (DataStore store : imageStores) {
long storeId = store.getId();
List<TemplateDataStoreVO> templateStoreVOs = _tmpltStoreDao.listByTemplateStore(templateId, storeId);
for (TemplateDataStoreVO templateStoreVO : templateStoreVOs) {
if (templateStoreVO.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
String errorMsg = "Please specify a template that is not currently being downloaded.";
s_logger.debug("Template: " + template.getName() + " is currently being downloaded to secondary storage host: " + store.getName() + ".");
throw new CloudRuntimeException(errorMsg);
}
String installPath = templateStoreVO.getInstallPath();
if (installPath != null) {
EndPoint ep = _epSelector.select(store);
if (ep == null) {
s_logger.warn("prepareOVAPacking (hyervisorTemplateAdapter): There is no secondary storage VM for secondary storage host " + store.getName());
throw new CloudRuntimeException("PrepareExtractTemplate: can't locate ssvm for SecStorage Host.");
}
cmd = new PrepareOVAPackingCommand(store.getUri(), installPath);
cmd.setContextParam("hypervisor", HypervisorType.VMware.toString());
Answer answer = ep.sendMessage(cmd);
if (answer == null || !answer.getResult()) {
s_logger.debug("Failed to create OVA for template " + templateStoreVO + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
throw new CloudRuntimeException("PrepareExtractTemplate: Failed to create OVA for template extraction. ");
}
}
}
}
}
return profile;
}
}