mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
fix suffix for extratemplate for kvm
This commit is contained in:
parent
4e4112fcec
commit
8f6eb26e38
@ -3440,33 +3440,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
extractMode = mode.equals(Upload.Mode.FTP_UPLOAD.toString()) ? Upload.Mode.FTP_UPLOAD : Upload.Mode.HTTP_DOWNLOAD;
|
||||
}
|
||||
|
||||
// If mode is upload perform extra checks on url and also see if there
|
||||
// is an ongoing upload on the same.
|
||||
if (extractMode == Upload.Mode.FTP_UPLOAD) {
|
||||
URI uri = new URI(url);
|
||||
if ((uri.getScheme() == null) || (!uri.getScheme().equalsIgnoreCase("ftp"))) {
|
||||
throw new IllegalArgumentException("Unsupported scheme for url: " + url);
|
||||
}
|
||||
|
||||
String host = uri.getHost();
|
||||
try {
|
||||
InetAddress hostAddr = InetAddress.getByName(host);
|
||||
if (hostAddr.isAnyLocalAddress() || hostAddr.isLinkLocalAddress() || hostAddr.isLoopbackAddress() || hostAddr.isMulticastAddress()) {
|
||||
throw new IllegalArgumentException("Illegal host specified in url");
|
||||
}
|
||||
if (hostAddr instanceof Inet6Address) {
|
||||
throw new IllegalArgumentException("IPV6 addresses not supported (" + hostAddr.getHostAddress() + ")");
|
||||
}
|
||||
} catch (UnknownHostException uhe) {
|
||||
throw new IllegalArgumentException("Unable to resolve " + host);
|
||||
}
|
||||
|
||||
if (_uploadMonitor.isTypeUploadInProgress(volumeId, Upload.Type.VOLUME)) {
|
||||
throw new IllegalArgumentException(volume.getName()
|
||||
+ " upload is in progress. Please wait for some time to schedule another upload for the same");
|
||||
}
|
||||
}
|
||||
|
||||
long accountId = volume.getAccountId();
|
||||
StoragePool srcPool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
|
||||
DataStore secStore = this.dataStoreMgr.getImageStore(zoneId);
|
||||
@ -3526,7 +3499,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
throw new CloudRuntimeException(errorString);
|
||||
}
|
||||
|
||||
String volumeLocalPath = "volumes/" + volume.getId() + "/" + cvAnswer.getVolumePath() + "." + getFormatForPool(srcPool);
|
||||
String volumeLocalPath = "volumes/" + volume.getId() + "/" + cvAnswer.getVolumePath() + "." + volume.getFormat().toString().toLowerCase();
|
||||
//Fang: volss, handle the ova special case;
|
||||
if (getFormatForPool(srcPool) == "ova") {
|
||||
CreateVolumeOVACommand cvOVACmd = new CreateVolumeOVACommand(secondaryStorageURL, volumeLocalPath, cvAnswer.getVolumePath(), srcPool, copyvolumewait);
|
||||
@ -3546,18 +3519,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
uploadJob.setInstallPath(volumeLocalPath);
|
||||
_uploadDao.update(uploadJob.getId(), uploadJob);
|
||||
|
||||
if (extractMode == Mode.FTP_UPLOAD) { // Now that the volume is
|
||||
// copied perform the actual
|
||||
// uploading
|
||||
_uploadMonitor.extractVolume(uploadJob, secStore, volume, url, zoneId, volumeLocalPath, cmd.getStartEventId(), job.getId(), _asyncMgr);
|
||||
return uploadJob.getId();
|
||||
} else { // Volume is copied now make it visible under apache and
|
||||
// create a URL.
|
||||
_uploadMonitor.createVolumeDownloadURL(volumeId, volumeLocalPath, Upload.Type.VOLUME, zoneId, uploadJob.getId());
|
||||
_uploadMonitor.createVolumeDownloadURL(volumeId, volumeLocalPath, Upload.Type.VOLUME, zoneId, uploadJob.getId(), volume.getFormat());
|
||||
return uploadJob.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getFormatForPool(StoragePool pool) {
|
||||
ClusterVO cluster = ApiDBUtils.findClusterById(pool.getClusterId());
|
||||
|
||||
@ -22,6 +22,7 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Upload.Mode;
|
||||
import com.cloud.storage.Upload.Status;
|
||||
import com.cloud.storage.Upload.Type;
|
||||
@ -57,6 +58,6 @@ public interface UploadMonitor extends Manager{
|
||||
TemplateDataStoreVO vmTemplateStore, Long dataCenterId, long eventId);
|
||||
|
||||
void createVolumeDownloadURL(Long entityId, String path, Type type,
|
||||
Long dataCenterId, Long uploadId);
|
||||
Long dataCenterId, Long uploadId, ImageFormat format);
|
||||
|
||||
}
|
||||
@ -260,7 +260,7 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createVolumeDownloadURL(Long entityId, String path, Type type, Long dataCenterId, Long uploadId) {
|
||||
public void createVolumeDownloadURL(Long entityId, String path, Type type, Long dataCenterId, Long uploadId, ImageFormat format) {
|
||||
|
||||
String errorString = "";
|
||||
boolean success = false;
|
||||
@ -278,7 +278,7 @@ public class UploadMonitorImpl extends ManagerBase implements UploadMonitor {
|
||||
_uploadDao.update(uploadJob.getId(), uploadJob);
|
||||
|
||||
// Create Symlink at ssvm
|
||||
String uuid = UUID.randomUUID().toString() + path.substring(path.length() - 4) ; // last 4 characters of the path specify the format like .vhd
|
||||
String uuid = UUID.randomUUID().toString() + "." + format.toString().toLowerCase() ;
|
||||
DataStore secStore = this.storeMgr.getDataStore(ApiDBUtils.findUploadById(uploadId).getDataStoreId(), DataStoreRole.Image);
|
||||
EndPoint ep = _epSelector.select(secStore);
|
||||
if( ep == null ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user