mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11096: ExtractTemplate - For private template choose the correct sec storage host id since its not present in all the sec storage now.
This commit is contained in:
parent
12a49668d7
commit
f1d13729af
@ -25,12 +25,14 @@ public class DeleteEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
private String path;
|
||||
private String extractUrl;
|
||||
private Upload.Type type;
|
||||
private String parentPath;
|
||||
|
||||
public DeleteEntityDownloadURLCommand(String path, Upload.Type type, String url) {
|
||||
public DeleteEntityDownloadURLCommand(String path, Upload.Type type, String url, String parentPath) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.extractUrl = url;
|
||||
this.parentPath = parentPath;
|
||||
}
|
||||
|
||||
public DeleteEntityDownloadURLCommand() {
|
||||
@ -61,4 +63,12 @@ public class DeleteEntityDownloadURLCommand extends AbstractDownloadCommand {
|
||||
this.extractUrl = extractUrl;
|
||||
}
|
||||
|
||||
public String getParentPath() {
|
||||
return parentPath;
|
||||
}
|
||||
|
||||
public void setParentPath(String parentPath) {
|
||||
this.parentPath = parentPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ public class UploadManagerImpl implements UploadManager {
|
||||
if(cmd.getType() == Upload.Type.VOLUME){
|
||||
command = new Script("/bin/bash", s_logger);
|
||||
command.add("-c");
|
||||
command.add("rm -f " + parentDir +File.separator+ path);
|
||||
command.add("rm -f /mnt/SecStorage/" + cmd.getParentPath() +File.separator+ path);
|
||||
s_logger.warn(" " +parentDir +File.separator+ path);
|
||||
result = command.execute();
|
||||
if (result != null) {
|
||||
|
||||
@ -194,26 +194,13 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
|
||||
String errorString = "";
|
||||
boolean success = false;
|
||||
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
|
||||
if(storageServers == null || storageServers.size() == 0) {
|
||||
throw new CloudRuntimeException("No Storage Server found at the datacenter - " +dataCenterId);
|
||||
}
|
||||
|
||||
Host secStorage = ApiDBUtils.findHostById(vmTemplateHost.getHostId());
|
||||
Type type = (template.getFormat() == ImageFormat.ISO) ? Type.ISO : Type.TEMPLATE ;
|
||||
|
||||
List<HostVO> storageServerVMs = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorageVM, dataCenterId);
|
||||
//Check if one ssvm is up
|
||||
boolean no_vm_up = true;
|
||||
HostVO use_ssvm = null;
|
||||
for (HostVO ssvm: storageServerVMs){
|
||||
if(ssvm.getStatus() == com.cloud.host.Status.Up){
|
||||
no_vm_up = false;
|
||||
use_ssvm = ssvm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(no_vm_up){
|
||||
throw new CloudRuntimeException("Couldnt create extract link - Secondary Storage Vm is not up");
|
||||
//Check if ssvm is up
|
||||
HostVO ssvm = _agentMgr.getSSAgent(ApiDBUtils.findHostById(vmTemplateHost.getHostId()));
|
||||
if( ssvm == null ) {
|
||||
throw new CloudRuntimeException("There is no secondary storage VM for secondary storage host " + secStorage.getId());
|
||||
}
|
||||
|
||||
//Check if it already exists.
|
||||
@ -223,7 +210,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
}
|
||||
|
||||
// It doesn't exist so create a DB entry.
|
||||
UploadVO uploadTemplateObj = new UploadVO(use_ssvm.getId(), template.getId(), new Date(),
|
||||
UploadVO uploadTemplateObj = new UploadVO(vmTemplateHost.getHostId(), template.getId(), new Date(),
|
||||
Status.DOWNLOAD_URL_NOT_CREATED, 0, type, Mode.HTTP_DOWNLOAD);
|
||||
uploadTemplateObj.setInstallPath(vmTemplateHost.getInstallPath());
|
||||
_uploadDao.persist(uploadTemplateObj);
|
||||
@ -231,8 +218,8 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
// Create Symlink at ssvm
|
||||
String path = vmTemplateHost.getInstallPath();
|
||||
String uuid = UUID.randomUUID().toString() + path.substring(path.length() - 4) ; // last 4 characters of the path specify the format like .vhd
|
||||
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(storageServers.get(0).getParent(), path, uuid);
|
||||
long result = send(use_ssvm.getId(), cmd, null);
|
||||
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(secStorage.getParent(), path, uuid);
|
||||
long result = send(ssvm.getId(), cmd, null);
|
||||
if (result == -1){
|
||||
errorString = "Unable to create a link for " +type+ " id:"+template.getId();
|
||||
s_logger.error(errorString);
|
||||
@ -474,10 +461,11 @@ public class UploadMonitorImpl implements UploadMonitor {
|
||||
for (UploadVO extractJob : extractJobs){
|
||||
if( getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS ){
|
||||
String path = extractJob.getInstallPath();
|
||||
HostVO secStorage = ApiDBUtils.findHostById(extractJob.getHostId());
|
||||
s_logger.debug("Sending deletion of extract URL "+extractJob.getUploadUrl());
|
||||
// Would delete the symlink for the Type and if Type == VOLUME then also the volume
|
||||
DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(),extractJob.getUploadUrl());
|
||||
HostVO ssvm = _agentMgr.getSSAgent(ApiDBUtils.findHostById(extractJob.getHostId()));
|
||||
DeleteEntityDownloadURLCommand cmd = new DeleteEntityDownloadURLCommand(path, extractJob.getType(),extractJob.getUploadUrl(), secStorage.getParent());
|
||||
HostVO ssvm = _agentMgr.getSSAgent(secStorage);
|
||||
if( ssvm == null ) {
|
||||
s_logger.warn("There is no secondary storage VM for secondary storage host " + extractJob.getHostId());
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user