mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Mount secondary storage as a datastore to implement ISO attachment
This commit is contained in:
parent
f81491d5bd
commit
72e8b767fe
@ -21,6 +21,7 @@ package com.cloud.agent.api;
|
|||||||
public class AttachIsoCommand extends Command {
|
public class AttachIsoCommand extends Command {
|
||||||
|
|
||||||
private String vmName;
|
private String vmName;
|
||||||
|
private String storeUrl;
|
||||||
private String isoPath;
|
private String isoPath;
|
||||||
private boolean attach;
|
private boolean attach;
|
||||||
|
|
||||||
@ -49,4 +50,12 @@ public class AttachIsoCommand extends Command {
|
|||||||
public boolean isAttach() {
|
public boolean isAttach() {
|
||||||
return attach;
|
return attach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStoreUrl() {
|
||||||
|
return storeUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoreUrl(String url) {
|
||||||
|
storeUrl = url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,7 @@ public interface StorageManager extends Manager {
|
|||||||
* @param datacenterId
|
* @param datacenterId
|
||||||
* @return absolute ISO path
|
* @return absolute ISO path
|
||||||
*/
|
*/
|
||||||
public String getAbsoluteIsoPath(long templateId, long dataCenterId);
|
public Pair<String, String> getAbsoluteIsoPath(long templateId, long dataCenterId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the URL of the secondary storage host
|
* Returns the URL of the secondary storage host
|
||||||
|
|||||||
@ -2399,10 +2399,11 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
UserVmVO started = null;
|
UserVmVO started = null;
|
||||||
if (isIso)
|
if (isIso)
|
||||||
{
|
{
|
||||||
String isoPath = _storageMgr.getAbsoluteIsoPath(templateId, dataCenterId);
|
Pair<String, String> isoPath = _storageMgr.getAbsoluteIsoPath(templateId, dataCenterId);
|
||||||
|
assert(isoPath != null);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
started = _vmMgr.startVirtualMachine(userId, created.getId(), password, isoPath, startEventId);
|
started = _vmMgr.startVirtualMachine(userId, created.getId(), password, isoPath.first(), startEventId);
|
||||||
}
|
}
|
||||||
catch (ExecutionException e)
|
catch (ExecutionException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1174,8 +1174,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Pair<String, String> getAbsoluteIsoPath(long templateId, long dataCenterId) {
|
||||||
public String getAbsoluteIsoPath(long templateId, long dataCenterId) {
|
|
||||||
String isoPath = null;
|
String isoPath = null;
|
||||||
|
|
||||||
List<HostVO> storageHosts = _hostDao.listBy(Host.Type.SecondaryStorage, dataCenterId);
|
List<HostVO> storageHosts = _hostDao.listBy(Host.Type.SecondaryStorage, dataCenterId);
|
||||||
@ -1184,12 +1183,12 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
VMTemplateHostVO templateHostVO = _vmTemplateHostDao.findByHostTemplate(storageHost.getId(), templateId);
|
VMTemplateHostVO templateHostVO = _vmTemplateHostDao.findByHostTemplate(storageHost.getId(), templateId);
|
||||||
if (templateHostVO != null) {
|
if (templateHostVO != null) {
|
||||||
isoPath = storageHost.getStorageUrl() + "/" + templateHostVO.getInstallPath();
|
isoPath = storageHost.getStorageUrl() + "/" + templateHostVO.getInstallPath();
|
||||||
break;
|
return new Pair<String, String>(isoPath, storageHost.getStorageUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isoPath;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -527,15 +527,18 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the path of the ISO
|
// Get the path of the ISO
|
||||||
String isoPath = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterId());
|
Pair<String, String> isoPathPair = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterId());
|
||||||
|
String isoPath;
|
||||||
String isoName = _templateDao.findById(isoId).getName();
|
String isoName = _templateDao.findById(isoId).getName();
|
||||||
|
|
||||||
if (isoPath == null) {
|
if (isoPathPair == null) {
|
||||||
// we can't send a null path to the ServerResource, so return false if we are unable to find the isoPath
|
// we can't send a null path to the ServerResource, so return false if we are unable to find the isoPath
|
||||||
if (isoName.startsWith("xs-tools"))
|
if (isoName.startsWith("xs-tools"))
|
||||||
isoPath = isoName;
|
isoPath = isoName;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
isoPath = isoPathPair.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
String vmName = vm.getInstanceName();
|
String vmName = vm.getInstanceName();
|
||||||
@ -545,6 +548,8 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
AttachIsoCommand cmd = new AttachIsoCommand(vmName, isoPath, attach);
|
AttachIsoCommand cmd = new AttachIsoCommand(vmName, isoPath, attach);
|
||||||
|
if(isoPathPair != null)
|
||||||
|
cmd.setStoreUrl(isoPathPair.second());
|
||||||
Answer a = _agentMgr.easySend(vm.getHostId(), cmd);
|
Answer a = _agentMgr.easySend(vm.getHostId(), cmd);
|
||||||
return (a != null);
|
return (a != null);
|
||||||
}
|
}
|
||||||
@ -670,7 +675,7 @@ public class UserVmManagerImpl implements UserVmManager {
|
|||||||
} else {
|
} else {
|
||||||
Long isoId = vm.getIsoId();
|
Long isoId = vm.getIsoId();
|
||||||
if (isoId != null) {
|
if (isoId != null) {
|
||||||
isoPath = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterId());
|
isoPath = _storageMgr.getAbsoluteIsoPath(isoId, vm.getDataCenterId()).first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user