Fix copyTemplateCmd.

This commit is contained in:
Min Chen 2013-04-16 16:38:14 -07:00
parent 0da2da852b
commit 1b3994e180
15 changed files with 499 additions and 395 deletions

View File

@ -147,9 +147,10 @@ public class DownloadCommand extends AbstractDownloadCommand implements Internal
this.resourceType = ResourceType.VOLUME; this.resourceType = ResourceType.VOLUME;
} }
public DownloadCommand(String secUrl, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) { public DownloadCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) {
super(template.getUniqueName(), url, template.getFormat(), template.getAccountId()); super(template.getUniqueName(), url, template.getFormat(), template.getAccountId());
this.hvm = template.isRequiresHvm(); this._store = store;
this.hvm = template.isRequiresHvm();
this.checksum = template.getChecksum(); this.checksum = template.getChecksum();
this.id = template.getId(); this.id = template.getId();
this.description = template.getDisplayText(); this.description = template.getDisplayText();

View File

@ -44,6 +44,8 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId); TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock);
TemplateDataStoreVO findByTemplate(long templateId); TemplateDataStoreVO findByTemplate(long templateId);
List<TemplateDataStoreVO> listByTemplate(long templateId); List<TemplateDataStoreVO> listByTemplate(long templateId);

View File

@ -388,8 +388,7 @@ public class TemplateServiceImpl implements TemplateService {
VMTemplateVO template = _templateDao.findById(tInfo.getId()); VMTemplateVO template = _templateDao.findById(tInfo.getId());
DeleteTemplateCommand dtCommand = new DeleteTemplateCommand(store.getTO(), store.getUri(), tInfo.getInstallPath(), template.getId(), template.getAccountId()); DeleteTemplateCommand dtCommand = new DeleteTemplateCommand(store.getTO(), store.getUri(), tInfo.getInstallPath(), template.getId(), template.getAccountId());
try { try {
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); _agentMgr.sendToSecStorage(store, dtCommand, null);
_agentMgr.sendToSecStorage(ssAhost, dtCommand, null);
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
String err = "Failed to delete " + tInfo.getTemplateName() + " on secondary storage " + storeId + " which isn't in the database"; String err = "Failed to delete " + tInfo.getTemplateName() + " on secondary storage " + storeId + " which isn't in the database";
s_logger.error(err); s_logger.error(err);
@ -430,16 +429,15 @@ public class TemplateServiceImpl implements TemplateService {
} }
private Map<String, TemplateProp> listTemplate(DataStore ssHost) { private Map<String, TemplateProp> listTemplate(DataStore ssStore) {
ListTemplateCommand cmd = new ListTemplateCommand(ssHost.getUri()); ListTemplateCommand cmd = new ListTemplateCommand(ssStore.getUri());
HostVO ssAhost = _ssvmMgr.pickSsvmHost(ssHost); Answer answer = _agentMgr.sendToSecStorage(ssStore, cmd);
Answer answer = _agentMgr.sendToSecStorage(ssAhost, cmd);
if (answer != null && answer.getResult()) { if (answer != null && answer.getResult()) {
ListTemplateAnswer tanswer = (ListTemplateAnswer)answer; ListTemplateAnswer tanswer = (ListTemplateAnswer)answer;
return tanswer.getTemplateInfo(); return tanswer.getTemplateInfo();
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("can not list template for secondary storage host " + ssHost.getId()); s_logger.debug("can not list template for secondary storage host " + ssStore.getId());
} }
} }

View File

@ -24,6 +24,7 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
@ -91,12 +92,12 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
params.put("password", "password"); params.put("password", "password");
params.put("zone", String.valueOf(host.getDataCenterId())); params.put("zone", String.valueOf(host.getDataCenterId()));
params.put("pod", String.valueOf(host.getPodId())); params.put("pod", String.valueOf(host.getPodId()));
ServerResource resource = null; ServerResource resource = null;
if (host.getHypervisorType() == HypervisorType.XenServer) { if (host.getHypervisorType() == HypervisorType.XenServer) {
resource = new XcpOssResource(); resource = new XcpOssResource();
} }
try { try {
resource.configure(host.getName(), params); resource.configure(host.getName(), params);
hostResourcesMap.put(hostId, resource); hostResourcesMap.put(hostId, resource);
@ -106,7 +107,7 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
HostEnvironment env = new HostEnvironment(); HostEnvironment env = new HostEnvironment();
SetupCommand cmd = new SetupCommand(env); SetupCommand cmd = new SetupCommand(env);
cmd.setNeedSetup(true); cmd.setNeedSetup(true);
resource.executeRequest(cmd); resource.executeRequest(cmd);
} }
@ -117,11 +118,11 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
loadResource(hostId); loadResource(hostId);
resource = hostResourcesMap.get(hostId); resource = hostResourcesMap.get(hostId);
} }
if (resource == null) { if (resource == null) {
return null; return null;
} }
Answer answer = resource.executeRequest(cmd); Answer answer = resource.executeRequest(cmd);
return answer; return answer;
} }
@ -186,6 +187,19 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
return null; return null;
} }
@Override
public void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException {
// TODO Auto-generated method stub
}
@Override
public Answer sendToSecStorage(DataStore ssStore, Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) { public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -243,7 +257,7 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
@Override @Override
public void disconnectWithInvestigation(long hostId, Event event) { public void disconnectWithInvestigation(long hostId, Event event) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

View File

@ -206,6 +206,19 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
return findOneIncludingRemovedBy(sc); return findOneIncludingRemovedBy(sc);
} }
@Override
public TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock) {
SearchCriteria<TemplateDataStoreVO> sc = storeTemplateSearch.create();
sc.setParameters("store_id", storeId);
sc.setParameters("template_id", templateId);
sc.setParameters("destroyed", false);
if (!lock)
return findOneIncludingRemovedBy(sc);
else
return lockOneRandomRow(sc, true);
}
@Override @Override
public TemplateDataStoreVO findByTemplate(long templateId) { public TemplateDataStoreVO findByTemplate(long templateId) {
SearchCriteria<TemplateDataStoreVO> sc = templateSearch.create(); SearchCriteria<TemplateDataStoreVO> sc = templateSearch.create();

View File

@ -814,8 +814,7 @@ public class VolumeServiceImpl implements VolumeService {
TemplateProp vInfo = volumeInfos.get(uniqueName); TemplateProp vInfo = volumeInfos.get(uniqueName);
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getUri(), vInfo.getInstallPath()); DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getUri(), vInfo.getInstallPath());
try { try {
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); _agentMgr.sendToSecStorage(store, dtCommand, null);
_agentMgr.sendToSecStorage(ssAhost, dtCommand, null);
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
String err = "Failed to delete " + vInfo.getTemplateName() + " on image store " + storeId + " which isn't in the database"; String err = "Failed to delete " + vInfo.getTemplateName() + " on image store " + storeId + " which isn't in the database";
s_logger.error(err); s_logger.error(err);
@ -830,8 +829,7 @@ public class VolumeServiceImpl implements VolumeService {
private Map<Long, TemplateProp> listVolume(DataStore store) { private Map<Long, TemplateProp> listVolume(DataStore store) {
ListVolumeCommand cmd = new ListVolumeCommand(store.getUri()); ListVolumeCommand cmd = new ListVolumeCommand(store.getUri());
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); Answer answer = _agentMgr.sendToSecStorage(store, cmd);
Answer answer = _agentMgr.sendToSecStorage(ssAhost, cmd);
if (answer != null && answer.getResult()) { if (answer != null && answer.getResult()) {
ListVolumeAnswer tanswer = (ListVolumeAnswer)answer; ListVolumeAnswer tanswer = (ListVolumeAnswer)answer;
return tanswer.getTemplateInfo(); return tanswer.getTemplateInfo();

View File

@ -236,12 +236,11 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(templateId); List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(templateId);
// check if there is any VM using this ISO. // check if there is any VM using this ISO.
if (userVmUsingIso == null || userVmUsingIso.isEmpty()) { if (userVmUsingIso == null || userVmUsingIso.isEmpty()) {
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); // get installpath of this template on image store
// get installpath of this template on image store
TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId); TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
String installPath = tmplStore.getInstallPath(); String installPath = tmplStore.getInstallPath();
if (installPath != null) { if (installPath != null) {
Answer answer = _agentMgr.sendToSecStorage(ssAhost, new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId())); Answer answer = _agentMgr.sendToSecStorage(store, new DeleteTemplateCommand(store.getTO(), store.getUri(), installPath, template.getId(), template.getAccountId()));
if (answer == null || !answer.getResult()) { if (answer == null || !answer.getResult()) {
s_logger.debug("Failed to deleted template at store: " + store.getName()); s_logger.debug("Failed to deleted template at store: " + store.getName());

View File

@ -16,6 +16,8 @@
// under the License. // under the License.
package com.cloud.agent; package com.cloud.agent;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupCommand;
@ -44,10 +46,10 @@ public interface AgentManager extends Manager {
Del, Del,
Contains, Contains,
} }
/** /**
* easy send method that returns null if there's any errors. It handles all exceptions. * easy send method that returns null if there's any errors. It handles all exceptions.
* *
* @param hostId * @param hostId
* host id * host id
* @param cmd * @param cmd
@ -58,7 +60,7 @@ public interface AgentManager extends Manager {
/** /**
* Synchronous sending a command to the agent. * Synchronous sending a command to the agent.
* *
* @param hostId * @param hostId
* id of the agent on host * id of the agent on host
* @param cmd * @param cmd
@ -70,7 +72,7 @@ public interface AgentManager extends Manager {
/** /**
* Synchronous sending a list of commands to the agent. * Synchronous sending a list of commands to the agent.
* *
* @param hostId * @param hostId
* id of the agent on host * id of the agent on host
* @param cmds * @param cmds
@ -87,7 +89,7 @@ public interface AgentManager extends Manager {
/** /**
* Asynchronous sending of a command to the agent. * Asynchronous sending of a command to the agent.
* *
* @param hostId * @param hostId
* id of the agent on the host. * id of the agent on the host.
* @param cmds * @param cmds
@ -102,7 +104,7 @@ public interface AgentManager extends Manager {
/** /**
* Register to listen for host events. These are mostly connection and disconnection events. * Register to listen for host events. These are mostly connection and disconnection events.
* *
* @param listener * @param listener
* @param connections * @param connections
* listen for connections * listen for connections
@ -125,7 +127,7 @@ public interface AgentManager extends Manager {
/** /**
* Unregister for listening to host events. * Unregister for listening to host events.
* *
* @param id * @param id
* returned from registerForHostEvents * returned from registerForHostEvents
*/ */
@ -138,20 +140,24 @@ public interface AgentManager extends Manager {
void sendToSecStorage(HostVO ssHost, Command cmd, Listener listener) throws AgentUnavailableException; void sendToSecStorage(HostVO ssHost, Command cmd, Listener listener) throws AgentUnavailableException;
Answer sendToSecStorage(HostVO ssHost, Command cmd); Answer sendToSecStorage(HostVO ssHost, Command cmd);
void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException;
Answer sendToSecStorage(DataStore ssStore, Command cmd);
/* working as a lock while agent is being loaded */ /* working as a lock while agent is being loaded */
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action); public boolean tapLoadingAgents(Long hostId, TapAgentsAction action);
public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException; public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId); public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId);
public AgentAttache findAttache(long hostId); public AgentAttache findAttache(long hostId);
void disconnectWithoutInvestigation(long hostId, Status.Event event); void disconnectWithoutInvestigation(long hostId, Status.Event event);
public void pullAgentToMaintenance(long hostId); public void pullAgentToMaintenance(long hostId);
public void pullAgentOutMaintenance(long hostId); public void pullAgentOutMaintenance(long hostId);
boolean reconnect(long hostId); boolean reconnect(long hostId);

View File

@ -39,6 +39,7 @@ import javax.ejb.Local;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -380,6 +381,18 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
return attache; return attache;
} }
@Override
public Answer sendToSecStorage(DataStore ssStore, Command cmd) {
HostVO ssAhost = _ssvmMgr.pickSsvmHost(ssStore);
return easySend(ssAhost.getId(), cmd);
}
@Override
public void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException {
HostVO ssAhost = _ssvmMgr.pickSsvmHost(ssStore);
send(ssAhost.getId(), new Commands(cmd), listener);
}
@Override @Override
public Answer sendToSecStorage(HostVO ssHost, Command cmd) { public Answer sendToSecStorage(HostVO ssHost, Command cmd) {
if( ssHost.getType() == Host.Type.LocalSecondaryStorage ) { if( ssHost.getType() == Host.Type.LocalSecondaryStorage ) {
@ -406,6 +419,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
} }
} }
private void sendToSSVM(final long dcId, final Command cmd, final Listener listener) throws AgentUnavailableException { private void sendToSSVM(final long dcId, final Command cmd, final Listener listener) throws AgentUnavailableException {
List<HostVO> ssAHosts = _ssvmMgr.listUpAndConnectingSecondaryStorageVmHost(dcId); List<HostVO> ssAHosts = _ssvmMgr.listUpAndConnectingSecondaryStorageVmHost(dcId);
if (ssAHosts == null || ssAHosts.isEmpty() ) { if (ssAHosts == null || ssAHosts.isEmpty() ) {

View File

@ -1266,11 +1266,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
String installPath = destroyedTemplateStoreVO String installPath = destroyedTemplateStoreVO
.getInstallPath(); .getInstallPath();
HostVO ssAhost = this._ssvmMgr.pickSsvmHost(store);
if (installPath != null) { if (installPath != null) {
Answer answer = _agentMgr.sendToSecStorage( Answer answer = _agentMgr.sendToSecStorage(store,
ssAhost,
new DeleteTemplateCommand( new DeleteTemplateCommand(
store.getTO(), store.getTO(),
store.getUri(), store.getUri(),

View File

@ -22,7 +22,6 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import com.cloud.exception.StorageUnavailableException; import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.HostVO;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
@ -38,7 +37,7 @@ public interface DownloadMonitor extends Manager{
public void cancelAllDownloads(Long templateId); public void cancelAllDownloads(Long templateId);
public boolean copyTemplate(VMTemplateVO template, HostVO sourceServer, HostVO destServer) public boolean copyTemplate(VMTemplateVO template, DataStore sourceStore, DataStore Store)
throws StorageUnavailableException; throws StorageUnavailableException;
//void addSystemVMTemplatesToHost(HostVO host, Map<String, TemplateProp> templateInfos); //void addSystemVMTemplatesToHost(HostVO host, Map<String, TemplateProp> templateInfos);

View File

@ -106,10 +106,9 @@ import com.cloud.vm.dao.UserVmDao;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
@Component @Component
@Local(value={DownloadMonitor.class}) @Local(value = { DownloadMonitor.class })
public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor { public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor {
static final Logger s_logger = Logger.getLogger(DownloadMonitorImpl.class); static final Logger s_logger = Logger.getLogger(DownloadMonitorImpl.class);
@Inject @Inject
@ -119,7 +118,7 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
@Inject @Inject
VMTemplateZoneDao _vmTemplateZoneDao; VMTemplateZoneDao _vmTemplateZoneDao;
@Inject @Inject
VMTemplatePoolDao _vmTemplatePoolDao; VMTemplatePoolDao _vmTemplatePoolDao;
@Inject @Inject
VMTemplateSwiftDao _vmTemplateSwiftlDao; VMTemplateSwiftDao _vmTemplateSwiftlDao;
@Inject @Inject
@ -139,27 +138,27 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
@Inject @Inject
SecondaryStorageVmManager _ssvmMgr; SecondaryStorageVmManager _ssvmMgr;
@Inject @Inject
StorageManager _storageMgr ; StorageManager _storageMgr;
@Inject @Inject
private final DataCenterDao _dcDao = null; private final DataCenterDao _dcDao = null;
@Inject @Inject
VMTemplateDao _templateDao = null; VMTemplateDao _templateDao = null;
@Inject @Inject
private AgentManager _agentMgr; private AgentManager _agentMgr;
@Inject SecondaryStorageVmManager _secMgr; @Inject
SecondaryStorageVmManager _secMgr;
@Inject @Inject
ConfigurationDao _configDao; ConfigurationDao _configDao;
@Inject @Inject
UserVmManager _vmMgr; UserVmManager _vmMgr;
@Inject TemplateManager templateMgr; @Inject
TemplateManager templateMgr;
@Inject @Inject
private UsageEventDao _usageEventDao; private UsageEventDao _usageEventDao;
@Inject @Inject
private ClusterDao _clusterDao; private ClusterDao _clusterDao;
@Inject @Inject
@ -175,34 +174,34 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
@Inject @Inject
protected AccountManager _accountMgr; protected AccountManager _accountMgr;
private Boolean _sslCopy = new Boolean(false); private Boolean _sslCopy = new Boolean(false);
private String _copyAuthPasswd; private String _copyAuthPasswd;
private String _proxy = null; private String _proxy = null;
protected SearchBuilder<TemplateDataStoreVO> ReadyTemplateStatesSearch; protected SearchBuilder<TemplateDataStoreVO> ReadyTemplateStatesSearch;
Timer _timer; Timer _timer;
@Inject DataStoreManager storeMgr; @Inject
DataStoreManager storeMgr;
final Map<TemplateDataStoreVO, DownloadListener> _listenerTemplateMap = new ConcurrentHashMap<TemplateDataStoreVO, DownloadListener>(); final Map<TemplateDataStoreVO, DownloadListener> _listenerTemplateMap = new ConcurrentHashMap<TemplateDataStoreVO, DownloadListener>();
final Map<VMTemplateHostVO, DownloadListener> _listenerMap = new ConcurrentHashMap<VMTemplateHostVO, DownloadListener>(); final Map<VMTemplateHostVO, DownloadListener> _listenerMap = new ConcurrentHashMap<VMTemplateHostVO, DownloadListener>();
final Map<VolumeHostVO, DownloadListener> _listenerVolumeMap = new ConcurrentHashMap<VolumeHostVO, DownloadListener>(); final Map<VolumeHostVO, DownloadListener> _listenerVolumeMap = new ConcurrentHashMap<VolumeHostVO, DownloadListener>();
final Map<VolumeDataStoreVO, DownloadListener> _listenerVolMap = new ConcurrentHashMap<VolumeDataStoreVO, DownloadListener>(); final Map<VolumeDataStoreVO, DownloadListener> _listenerVolMap = new ConcurrentHashMap<VolumeDataStoreVO, DownloadListener>();
public void send(Long hostId, Command cmd, Listener listener) throws AgentUnavailableException {
_agentMgr.send(hostId, new Commands(cmd), listener);
}
public void send(Long hostId, Command cmd, Listener listener) throws AgentUnavailableException { @Override
_agentMgr.send(hostId, new Commands(cmd), listener); public boolean configure(String name, Map<String, Object> params) {
}
@Override
public boolean configure(String name, Map<String, Object> params) {
final Map<String, String> configs = _configDao.getConfiguration("ManagementServer", params); final Map<String, String> configs = _configDao.getConfiguration("ManagementServer", params);
_sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy")); _sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy"));
_proxy = configs.get(Config.SecStorageProxy.key()); _proxy = configs.get(Config.SecStorageProxy.key());
String cert = configs.get("secstorage.ssl.cert.domain"); String cert = configs.get("secstorage.ssl.cert.domain");
if (!"realhostip.com".equalsIgnoreCase(cert)) { if (!"realhostip.com".equalsIgnoreCase(cert)) {
s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs"); s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
} }
_copyAuthPasswd = configs.get("secstorage.copy.password"); _copyAuthPasswd = configs.get("secstorage.copy.password");
@ -222,382 +221,387 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
TemplatesWithNoChecksumSearch.done(); TemplatesWithNoChecksumSearch.done();
ReadyTemplateStatesSearch.done(); ReadyTemplateStatesSearch.done();
return true; return true;
} }
@Override @Override
public boolean start() { public boolean start() {
_timer = new Timer(); _timer = new Timer();
return true; return true;
} }
@Override @Override
public boolean stop() { public boolean stop() {
return true; return true;
} }
public boolean isTemplateUpdateable(Long templateId, Long storeId) { public boolean isTemplateUpdateable(Long templateId, Long storeId) {
List<TemplateDataStoreVO> downloadsInProgress = List<TemplateDataStoreVO> downloadsInProgress = _vmTemplateStoreDao.listByTemplateStoreDownloadStatus(templateId, storeId,
_vmTemplateStoreDao.listByTemplateStoreDownloadStatus(templateId, storeId, Status.DOWNLOAD_IN_PROGRESS, Status.DOWNLOADED ); Status.DOWNLOAD_IN_PROGRESS, Status.DOWNLOADED);
return (downloadsInProgress.size() == 0); return (downloadsInProgress.size() == 0);
} }
@Override // TODO: consider using dataMotionStrategy later
public boolean copyTemplate(VMTemplateVO template, HostVO sourceServer, HostVO destServer) throws StorageUnavailableException{ @Override
public boolean copyTemplate(VMTemplateVO template, DataStore sourceStore, DataStore destStore) throws StorageUnavailableException {
boolean downloadJobExists = false; boolean downloadJobExists = false;
VMTemplateHostVO destTmpltHost = null; TemplateDataStoreVO destTmpltStore = null;
VMTemplateHostVO srcTmpltHost = null; TemplateDataStoreVO srcTmpltStore = null;
srcTmpltHost = _vmTemplateHostDao.findByHostTemplate(sourceServer.getId(), template.getId()); srcTmpltStore = this._vmTemplateStoreDao.findByStoreTemplate(sourceStore.getId(), template.getId());
if (srcTmpltHost == null) { if (srcTmpltStore == null) {
throw new InvalidParameterValueException("Template " + template.getName() + " not associated with " + sourceServer.getName()); throw new InvalidParameterValueException("Template " + template.getName() + " not associated with " + sourceStore.getName());
} }
String url = generateCopyUrl(sourceServer, srcTmpltHost); // generate a storage url on ssvm to copy from
if (url == null) { String url = generateCopyUrl(sourceStore, srcTmpltStore);
s_logger.warn("Unable to start/resume copy of template " + template.getUniqueName() + " to " + destServer.getName() + ", no secondary storage vm in running state in source zone"); if (url == null) {
throw new CloudRuntimeException("No secondary VM in running state in zone " + sourceServer.getDataCenterId()); s_logger.warn("Unable to start/resume copy of template " + template.getUniqueName() + " to " + destStore.getName()
} + ", no secondary storage vm in running state in source zone");
destTmpltHost = _vmTemplateHostDao.findByHostTemplate(destServer.getId(), template.getId()); throw new CloudRuntimeException("No secondary VM in running state in zone " + sourceStore.getScope().getScopeId());
if (destTmpltHost == null) { }
destTmpltHost = new VMTemplateHostVO(destServer.getId(), template.getId(), new Date(), 0, VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, "jobid0000", null, url); destTmpltStore = _vmTemplateStoreDao.findByStoreTemplate(destStore.getId(), template.getId());
destTmpltHost.setCopy(true); if (destTmpltStore == null) {
destTmpltHost.setPhysicalSize(srcTmpltHost.getPhysicalSize()); destTmpltStore = new TemplateDataStoreVO(destStore.getId(), template.getId(), new Date(), 0,
_vmTemplateHostDao.persist(destTmpltHost); VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, "jobid0000", null, url);
} else if ((destTmpltHost.getJobId() != null) && (destTmpltHost.getJobId().length() > 2)) { destTmpltStore.setCopy(true);
destTmpltStore.setPhysicalSize(srcTmpltStore.getPhysicalSize());
_vmTemplateStoreDao.persist(destTmpltStore);
} else if ((destTmpltStore.getJobId() != null) && (destTmpltStore.getJobId().length() > 2)) {
downloadJobExists = true; downloadJobExists = true;
} }
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
if (srcTmpltHost.getSize() > maxTemplateSizeInBytes){ if (srcTmpltStore.getSize() > maxTemplateSizeInBytes) {
throw new CloudRuntimeException("Cant copy the template as the template's size " +srcTmpltHost.getSize()+ throw new CloudRuntimeException("Cant copy the template as the template's size " + srcTmpltStore.getSize()
" is greater than max.template.iso.size " + maxTemplateSizeInBytes); + " is greater than max.template.iso.size " + maxTemplateSizeInBytes);
} }
if(destTmpltHost != null) { if (destTmpltStore != null) {
start(); start();
String sourceChecksum = this.templateMgr.getChecksum(srcTmpltHost.getHostId(), srcTmpltHost.getInstallPath()); String sourceChecksum = this.templateMgr.getChecksum(sourceStore, srcTmpltStore.getInstallPath());
DownloadCommand dcmd = DownloadCommand dcmd = new DownloadCommand(destStore.getTO(), destStore.getUri(), url, template,
new DownloadCommand(destServer.getStorageUrl(), url, template, TemplateConstants.DEFAULT_HTTP_AUTH_USER, _copyAuthPasswd, maxTemplateSizeInBytes); TemplateConstants.DEFAULT_HTTP_AUTH_USER, _copyAuthPasswd, maxTemplateSizeInBytes);
dcmd.setProxy(getHttpProxy()); dcmd.setProxy(getHttpProxy());
if (downloadJobExists) {
dcmd = new DownloadProgressCommand(dcmd, destTmpltHost.getJobId(), RequestType.GET_OR_RESTART);
}
dcmd.setChecksum(sourceChecksum); // We need to set the checksum as the source template might be a compressed url and have cksum for compressed image. Bug #10775
HostVO ssAhost = _ssvmMgr.pickSsvmHost(destServer);
if( ssAhost == null ) {
s_logger.warn("There is no secondary storage VM for secondary storage host " + destServer.getName());
return false;
}
DownloadListener dl = new DownloadListener(ssAhost, destServer, template, _timer, _vmTemplateHostDao, destTmpltHost.getId(), this, dcmd, _templateDao, _resourceLimitMgr, _alertMgr, _accountMgr);
if (downloadJobExists) { if (downloadJobExists) {
dl.setCurrState(destTmpltHost.getDownloadState()); dcmd = new DownloadProgressCommand(dcmd, destTmpltStore.getJobId(), RequestType.GET_OR_RESTART);
}
dcmd.setChecksum(sourceChecksum); // We need to set the checksum as
// the source template might be a
// compressed url and have cksum
// for compressed image. Bug
// #10775
HostVO ssAhost = _ssvmMgr.pickSsvmHost(destStore);
if (ssAhost == null) {
s_logger.warn("There is no secondary storage VM for secondary storage host " + destStore.getName());
return false;
}
DownloadListener dl = new DownloadListener(ssAhost, destStore, template, _timer, _vmTemplateStoreDao, destTmpltStore.getId(), this, dcmd,
_templateDao, _resourceLimitMgr, _alertMgr, _accountMgr, null);
if (downloadJobExists) {
dl.setCurrState(destTmpltStore.getDownloadState());
}
DownloadListener old = null;
synchronized (_listenerTemplateMap) {
old = _listenerTemplateMap.put(destTmpltStore, dl);
}
if (old != null) {
old.abandon();
} }
DownloadListener old = null;
synchronized (_listenerMap) {
old = _listenerMap.put(destTmpltHost, dl);
}
if( old != null ) {
old.abandon();
}
try { try {
send(ssAhost.getId(), dcmd, dl); send(ssAhost.getId(), dcmd, dl);
return true; return true;
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.warn("Unable to start /resume COPY of template " + template.getUniqueName() + " to " + destServer.getName(), e); s_logger.warn("Unable to start /resume COPY of template " + template.getUniqueName() + " to " + destStore.getName(), e);
dl.setDisconnected(); dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART); dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
e.printStackTrace(); e.printStackTrace();
} }
} }
return false; return false;
} }
private String generateCopyUrl(String ipAddress, String dir, String path){ private String generateCopyUrl(String ipAddress, String dir, String path) {
String hostname = ipAddress; String hostname = ipAddress;
String scheme = "http"; String scheme = "http";
if (_sslCopy) { if (_sslCopy) {
hostname = ipAddress.replace(".", "-"); hostname = ipAddress.replace(".", "-");
hostname = hostname + ".realhostip.com"; hostname = hostname + ".realhostip.com";
scheme = "https"; scheme = "https";
} }
return scheme + "://" + hostname + "/copy/SecStorage/" + dir + "/" + path; return scheme + "://" + hostname + "/copy/SecStorage/" + dir + "/" + path;
} }
private String generateCopyUrl(HostVO sourceServer, VMTemplateHostVO srcTmpltHost) { private String generateCopyUrl(DataStore sourceServer, TemplateDataStoreVO srcTmpltStore) {
List<SecondaryStorageVmVO> ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, sourceServer.getDataCenterId(), State.Running); List<SecondaryStorageVmVO> ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, sourceServer
if (ssVms.size() > 0) { .getScope().getScopeId(), State.Running);
SecondaryStorageVmVO ssVm = ssVms.get(0); if (ssVms.size() > 0) {
if (ssVm.getPublicIpAddress() == null) { SecondaryStorageVmVO ssVm = ssVms.get(0);
s_logger.warn("A running secondary storage vm has a null public ip?"); if (ssVm.getPublicIpAddress() == null) {
return null; s_logger.warn("A running secondary storage vm has a null public ip?");
} return null;
return generateCopyUrl(ssVm.getPublicIpAddress(), sourceServer.getParent(), srcTmpltHost.getInstallPath()); }
} //TODO: how to handle parent field from hostVO in image_store? and how we can populate that column?
// return generateCopyUrl(ssVm.getPublicIpAddress(), sourceServer.getParent(), srcTmpltStore.getInstallPath());
return generateCopyUrl(ssVm.getPublicIpAddress(), null, srcTmpltStore.getInstallPath());
}
VMTemplateVO tmplt = _templateDao.findById(srcTmpltHost.getTemplateId()); VMTemplateVO tmplt = _templateDao.findById(srcTmpltStore.getTemplateId());
HypervisorType hyperType = tmplt.getHypervisorType(); HypervisorType hyperType = tmplt.getHypervisorType();
/*No secondary storage vm yet*/ /*No secondary storage vm yet*/
if (hyperType != null && hyperType == HypervisorType.KVM) { if (hyperType != null && hyperType == HypervisorType.KVM) {
return "file://" + sourceServer.getParent() + "/" + srcTmpltHost.getInstallPath(); //return "file://" + sourceServer.getParent() + "/" + srcTmpltStore.getInstallPath();
} return "file://" + "/" + srcTmpltStore.getInstallPath();
return null; }
} return null;
}
private void initiateTemplateDownload(VMTemplateVO template, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback) { private void initiateTemplateDownload(VMTemplateVO template, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback) {
boolean downloadJobExists = false; boolean downloadJobExists = false;
TemplateDataStoreVO vmTemplateStore = null; TemplateDataStoreVO vmTemplateStore = null;
vmTemplateStore = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId()); vmTemplateStore = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId());
if (vmTemplateStore == null) { if (vmTemplateStore == null) {
// This method can be invoked other places, for example, handleTemplateSync, in that case, vmTemplateStore may be null // This method can be invoked other places, for example,
vmTemplateStore = new TemplateDataStoreVO(store.getId(), template.getId(), new Date(), 0, VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, "jobid0000", null, template.getUrl()); // handleTemplateSync, in that case, vmTemplateStore may be null
vmTemplateStore = new TemplateDataStoreVO(store.getId(), template.getId(), new Date(), 0,
VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, "jobid0000", null, template.getUrl());
_vmTemplateStoreDao.persist(vmTemplateStore); _vmTemplateStoreDao.persist(vmTemplateStore);
} else } else if ((vmTemplateStore.getJobId() != null) && (vmTemplateStore.getJobId().length() > 2)) {
if ((vmTemplateStore.getJobId() != null) && (vmTemplateStore.getJobId().length() > 2)) {
downloadJobExists = true; downloadJobExists = true;
} }
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes(); Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
String secUrl = store.getUri(); String secUrl = store.getUri();
if(vmTemplateStore != null) { if (vmTemplateStore != null) {
start(); start();
DownloadCommand dcmd = DownloadCommand dcmd = new DownloadCommand(store.getTO(), secUrl, template, maxTemplateSizeInBytes);
new DownloadCommand(store.getTO(), secUrl, template, maxTemplateSizeInBytes); dcmd.setProxy(getHttpProxy());
dcmd.setProxy(getHttpProxy()); if (downloadJobExists) {
if (downloadJobExists) { dcmd = new DownloadProgressCommand(dcmd, vmTemplateStore.getJobId(), RequestType.GET_OR_RESTART);
dcmd = new DownloadProgressCommand(dcmd, vmTemplateStore.getJobId(), RequestType.GET_OR_RESTART); }
} if (vmTemplateStore.isCopy()) {
if (vmTemplateStore.isCopy()) { dcmd.setCreds(TemplateConstants.DEFAULT_HTTP_AUTH_USER, _copyAuthPasswd);
dcmd.setCreds(TemplateConstants.DEFAULT_HTTP_AUTH_USER, _copyAuthPasswd); }
} HostVO ssAhost = _ssvmMgr.pickSsvmHost(store);
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); if (ssAhost == null) {
if( ssAhost == null ) { s_logger.warn("There is no secondary storage VM for downloading template to image store " + store.getName());
s_logger.warn("There is no secondary storage VM for downloading template to image store " + store.getName()); return;
return; }
} DownloadListener dl = new DownloadListener(ssAhost, store, template, _timer, _vmTemplateStoreDao, vmTemplateStore.getId(), this, dcmd,
DownloadListener dl = new DownloadListener(ssAhost, store, template, _timer, _vmTemplateStoreDao, vmTemplateStore.getId(), this, dcmd, _templateDao, _resourceLimitMgr, _alertMgr, _accountMgr, callback); _templateDao, _resourceLimitMgr, _alertMgr, _accountMgr, callback);
if (downloadJobExists) { if (downloadJobExists) {
// due to handling existing download job issues, we still keep downloadState in template_store_ref to avoid big change in DownloadListener to use // due to handling existing download job issues, we still keep
// new ObjectInDataStore.State transition. TODO: fix this later to be able to remove downloadState from template_store_ref. // downloadState in template_store_ref to avoid big change in
dl.setCurrState(vmTemplateStore.getDownloadState()); // DownloadListener to use
} // new ObjectInDataStore.State transition. TODO: fix this later
// to be able to remove downloadState from template_store_ref.
dl.setCurrState(vmTemplateStore.getDownloadState());
}
DownloadListener old = null; DownloadListener old = null;
synchronized (_listenerTemplateMap) { synchronized (_listenerTemplateMap) {
old = _listenerTemplateMap.put(vmTemplateStore, dl); old = _listenerTemplateMap.put(vmTemplateStore, dl);
} }
if( old != null ) { if (old != null) {
old.abandon(); old.abandon();
} }
try { try {
send(ssAhost.getId(), dcmd, dl); send(ssAhost.getId(), dcmd, dl);
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.warn("Unable to start /resume download of template " + template.getUniqueName() + " to " + store.getName(), e); s_logger.warn("Unable to start /resume download of template " + template.getUniqueName() + " to " + store.getName(), e);
dl.setDisconnected(); dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART); dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
} }
} }
} }
@Override
public void downloadTemplateToStorage(VMTemplateVO template, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback) {
@Override
public void downloadTemplateToStorage(VMTemplateVO template, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback) {
long templateId = template.getId(); long templateId = template.getId();
if (isTemplateUpdateable(templateId, store.getId())) { if (isTemplateUpdateable(templateId, store.getId())) {
if ( template != null && template.getUrl() != null ){ if (template != null && template.getUrl() != null) {
initiateTemplateDownload(template, store, callback); initiateTemplateDownload(template, store, callback);
} }
} }
} }
@Override
@Override public void downloadVolumeToStorage(VolumeVO volume, DataStore store, String url, String checkSum, ImageFormat format,
public void downloadVolumeToStorage(VolumeVO volume, DataStore store, String url, String checkSum, ImageFormat format, AsyncCompletionCallback<CreateCmdResult> callback) { AsyncCompletionCallback<CreateCmdResult> callback) {
boolean downloadJobExists = false; boolean downloadJobExists = false;
VolumeDataStoreVO volumeHost = null; VolumeDataStoreVO volumeHost = null;
volumeHost = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId()); volumeHost = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId());
if (volumeHost == null) { if (volumeHost == null) {
volumeHost = new VolumeDataStoreVO(store.getId(), volume.getId(), new Date(), 0, VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED, null, null, volumeHost = new VolumeDataStoreVO(store.getId(), volume.getId(), new Date(), 0, VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED,
"jobid0000", null, url, checkSum, format); null, null, "jobid0000", null, url, checkSum, format);
_volumeStoreDao.persist(volumeHost); _volumeStoreDao.persist(volumeHost);
} else if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) { } else if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) {
downloadJobExists = true; downloadJobExists = true;
} }
Long maxVolumeSizeInBytes = getMaxVolumeSizeInBytes(); Long maxVolumeSizeInBytes = getMaxVolumeSizeInBytes();
String secUrl = store.getUri(); String secUrl = store.getUri();
if(volumeHost != null) { if (volumeHost != null) {
start(); start();
DownloadCommand dcmd = new DownloadCommand(secUrl, volume, maxVolumeSizeInBytes, checkSum, url, format); DownloadCommand dcmd = new DownloadCommand(secUrl, volume, maxVolumeSizeInBytes, checkSum, url, format);
dcmd.setProxy(getHttpProxy()); dcmd.setProxy(getHttpProxy());
if (downloadJobExists) { if (downloadJobExists) {
dcmd = new DownloadProgressCommand(dcmd, volumeHost.getJobId(), RequestType.GET_OR_RESTART); dcmd = new DownloadProgressCommand(dcmd, volumeHost.getJobId(), RequestType.GET_OR_RESTART);
dcmd.setResourceType(ResourceType.VOLUME); dcmd.setResourceType(ResourceType.VOLUME);
} }
HostVO ssAhost = _ssvmMgr.pickSsvmHost(store); HostVO ssAhost = _ssvmMgr.pickSsvmHost(store);
if( ssAhost == null ) { if (ssAhost == null) {
s_logger.warn("There is no secondary storage VM for image store " + store.getName()); s_logger.warn("There is no secondary storage VM for image store " + store.getName());
return; return;
} }
DownloadListener dl = new DownloadListener(ssAhost, store, volume, _timer, _volumeStoreDao, volumeHost.getId(), DownloadListener dl = new DownloadListener(ssAhost, store, volume, _timer, _volumeStoreDao, volumeHost.getId(), this, dcmd, _volumeDao,
this, dcmd, _volumeDao, _storageMgr, _resourceLimitMgr, _alertMgr, _accountMgr, callback); _storageMgr, _resourceLimitMgr, _alertMgr, _accountMgr, callback);
if (downloadJobExists) { if (downloadJobExists) {
dl.setCurrState(volumeHost.getDownloadState()); dl.setCurrState(volumeHost.getDownloadState());
} }
DownloadListener old = null; DownloadListener old = null;
synchronized (_listenerVolMap) { synchronized (_listenerVolMap) {
old = _listenerVolMap.put(volumeHost, dl); old = _listenerVolMap.put(volumeHost, dl);
} }
if( old != null ) { if (old != null) {
old.abandon(); old.abandon();
} }
try { try {
send(ssAhost.getId(), dcmd, dl); send(ssAhost.getId(), dcmd, dl);
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.warn("Unable to start /resume download of volume " + volume.getName() + " to " + store.getName(), e); s_logger.warn("Unable to start /resume download of volume " + volume.getName() + " to " + store.getName(), e);
dl.setDisconnected(); dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART); dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
} }
} }
} }
@DB
public void handleDownloadEvent(HostVO host, VMTemplateVO template, Status dnldStatus) {
if ((dnldStatus == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) || (dnldStatus == Status.ABANDONED)) {
VMTemplateHostVO vmTemplateHost = new VMTemplateHostVO(host.getId(), template.getId());
synchronized (_listenerMap) {
_listenerMap.remove(vmTemplateHost);
}
}
@DB VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), template.getId());
public void handleDownloadEvent(HostVO host, VMTemplateVO template, Status dnldStatus) {
if ((dnldStatus == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) || (dnldStatus==Status.ABANDONED)){
VMTemplateHostVO vmTemplateHost = new VMTemplateHostVO(host.getId(), template.getId());
synchronized (_listenerMap) {
_listenerMap.remove(vmTemplateHost);
}
}
VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), template.getId()); Transaction txn = Transaction.currentTxn();
Transaction txn = Transaction.currentTxn();
txn.start(); txn.start();
if (dnldStatus == Status.DOWNLOADED) { if (dnldStatus == Status.DOWNLOADED) {
long size = -1; long size = -1;
if(vmTemplateHost!=null){ if (vmTemplateHost != null) {
size = vmTemplateHost.getPhysicalSize(); size = vmTemplateHost.getPhysicalSize();
template.setSize(size); template.setSize(size);
this._templateDao.update(template.getId(), template); this._templateDao.update(template.getId(), template);
} } else {
else{
s_logger.warn("Failed to get size for template" + template.getName()); s_logger.warn("Failed to get size for template" + template.getName());
} }
String eventType = EventTypes.EVENT_TEMPLATE_CREATE; String eventType = EventTypes.EVENT_TEMPLATE_CREATE;
if((template.getFormat()).equals(ImageFormat.ISO)){ if ((template.getFormat()).equals(ImageFormat.ISO)) {
eventType = EventTypes.EVENT_ISO_CREATE; eventType = EventTypes.EVENT_ISO_CREATE;
} }
if(template.getAccountId() != Account.ACCOUNT_ID_SYSTEM){ if (template.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
UsageEventUtils.publishUsageEvent(eventType, template.getAccountId(), host.getDataCenterId(), UsageEventUtils.publishUsageEvent(eventType, template.getAccountId(), host.getDataCenterId(), template.getId(), template.getName(),
template.getId(), template.getName(), null, template.getSourceTemplateId(), size, null, template.getSourceTemplateId(), size, template.getClass().getName(), template.getUuid());
template.getClass().getName(), template.getUuid());
} }
} }
txn.commit(); txn.commit();
} }
@DB @DB
public void handleDownloadEvent(HostVO host, VolumeVO volume, Status dnldStatus) { public void handleDownloadEvent(HostVO host, VolumeVO volume, Status dnldStatus) {
if ((dnldStatus == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) || (dnldStatus==Status.ABANDONED)){ if ((dnldStatus == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) || (dnldStatus == Status.ABANDONED)) {
VolumeHostVO volumeHost = new VolumeHostVO(host.getId(), volume.getId()); VolumeHostVO volumeHost = new VolumeHostVO(host.getId(), volume.getId());
synchronized (_listenerVolumeMap) { synchronized (_listenerVolumeMap) {
_listenerVolumeMap.remove(volumeHost); _listenerVolumeMap.remove(volumeHost);
} }
} }
VolumeHostVO volumeHost = _volumeHostDao.findByHostVolume(host.getId(), volume.getId()); VolumeHostVO volumeHost = _volumeHostDao.findByHostVolume(host.getId(), volume.getId());
Transaction txn = Transaction.currentTxn(); Transaction txn = Transaction.currentTxn();
txn.start(); txn.start();
if (dnldStatus == Status.DOWNLOADED) { if (dnldStatus == Status.DOWNLOADED) {
//Create usage event // Create usage event
long size = -1; long size = -1;
if(volumeHost!=null){ if (volumeHost != null) {
size = volumeHost.getPhysicalSize(); size = volumeHost.getPhysicalSize();
volume.setSize(size); volume.setSize(size);
this._volumeDao.update(volume.getId(), volume); this._volumeDao.update(volume.getId(), volume);
} } else {
else{
s_logger.warn("Failed to get size for volume" + volume.getName()); s_logger.warn("Failed to get size for volume" + volume.getName());
} }
String eventType = EventTypes.EVENT_VOLUME_UPLOAD; String eventType = EventTypes.EVENT_VOLUME_UPLOAD;
if(volume.getAccountId() != Account.ACCOUNT_ID_SYSTEM){ if (volume.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
UsageEventUtils.publishUsageEvent(eventType, volume.getAccountId(), host.getDataCenterId(), UsageEventUtils.publishUsageEvent(eventType, volume.getAccountId(), host.getDataCenterId(), volume.getId(), volume.getName(), null,
volume.getId(), volume.getName(), null, 0l, size, volume.getClass().getName(), volume.getUuid()); 0l, size, volume.getClass().getName(), volume.getUuid());
} }
}else if (dnldStatus == Status.DOWNLOAD_ERROR || dnldStatus == Status.ABANDONED || dnldStatus == Status.UNKNOWN){ } else if (dnldStatus == Status.DOWNLOAD_ERROR || dnldStatus == Status.ABANDONED || dnldStatus == Status.UNKNOWN) {
//Decrement the volume and secondary storage space count // Decrement the volume and secondary storage space count
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), com.cloud.configuration.Resource.ResourceType.volume);
com.cloud.configuration.Resource.ResourceType.volume);
_resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),
com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal()); com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());
} }
txn.commit(); txn.commit();
} }
/*
/*
@Override @Override
public void addSystemVMTemplatesToHost(HostVO host, Map<String, TemplateProp> templateInfos){ public void addSystemVMTemplatesToHost(HostVO host, Map<String, TemplateProp> templateInfos){
if ( templateInfos == null ) { if ( templateInfos == null ) {
return; return;
} }
Long hostId = host.getId(); Long hostId = host.getId();
List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates(); List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
for ( VMTemplateVO tmplt : rtngTmplts ) { for ( VMTemplateVO tmplt : rtngTmplts ) {
TemplateProp tmpltInfo = templateInfos.get(tmplt.getUniqueName()); TemplateProp tmpltInfo = templateInfos.get(tmplt.getUniqueName());
if ( tmpltInfo == null ) { if ( tmpltInfo == null ) {
continue; continue;
} }
VMTemplateHostVO tmpltHost = _vmTemplateHostDao.findByHostTemplate(hostId, tmplt.getId()); VMTemplateHostVO tmpltHost = _vmTemplateHostDao.findByHostTemplate(hostId, tmplt.getId());
if ( tmpltHost == null ) { if ( tmpltHost == null ) {
tmpltHost = new VMTemplateHostVO(hostId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, tmpltInfo.getInstallPath(), tmplt.getUrl()); tmpltHost = new VMTemplateHostVO(hostId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, tmpltInfo.getInstallPath(), tmplt.getUrl());
tmpltHost.setSize(tmpltInfo.getSize()); tmpltHost.setSize(tmpltInfo.getSize());
tmpltHost.setPhysicalSize(tmpltInfo.getPhysicalSize()); tmpltHost.setPhysicalSize(tmpltInfo.getPhysicalSize());
_vmTemplateHostDao.persist(tmpltHost); _vmTemplateHostDao.persist(tmpltHost);
} }
} }
} }
*/ */
@Override
public void cancelAllDownloads(Long templateId) {
List<VMTemplateHostVO> downloadsInProgress = _vmTemplateHostDao.listByTemplateStates(templateId,
VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS, VMTemplateHostVO.Status.NOT_DOWNLOADED);
if (downloadsInProgress.size() > 0) {
for (VMTemplateHostVO vmthvo : downloadsInProgress) {
DownloadListener dl = null;
synchronized (_listenerMap) {
dl = _listenerMap.remove(vmthvo);
}
if (dl != null) {
dl.abandon();
s_logger.info("Stopping download of template " + templateId + " to storage server " + vmthvo.getHostId());
}
}
}
}
/*
@Override private void checksumSync(long hostId){
public void cancelAllDownloads(Long templateId) {
List<VMTemplateHostVO> downloadsInProgress =
_vmTemplateHostDao.listByTemplateStates(templateId, VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS, VMTemplateHostVO.Status.NOT_DOWNLOADED);
if (downloadsInProgress.size() > 0){
for (VMTemplateHostVO vmthvo: downloadsInProgress) {
DownloadListener dl = null;
synchronized (_listenerMap) {
dl = _listenerMap.remove(vmthvo);
}
if (dl != null) {
dl.abandon();
s_logger.info("Stopping download of template " + templateId + " to storage server " + vmthvo.getHostId());
}
}
}
}
/*
private void checksumSync(long hostId){
SearchCriteria<TemplateDataStoreVO> sc = ReadyTemplateStatesSearch.create(); SearchCriteria<TemplateDataStoreVO> sc = ReadyTemplateStatesSearch.create();
sc.setParameters("state", ObjectInDataStoreStateMachine.State.Ready); sc.setParameters("state", ObjectInDataStoreStateMachine.State.Ready);
sc.setParameters("host_id", hostId); sc.setParameters("host_id", hostId);
@ -613,38 +617,36 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
_templateDao.update(template.getId(), template); _templateDao.update(template.getId(), template);
} }
} }
*/ */
private Long getMaxTemplateSizeInBytes() { private Long getMaxTemplateSizeInBytes() {
try { try {
return Long.parseLong(_configDao.getValue("max.template.iso.size")) * 1024L * 1024L * 1024L; return Long.parseLong(_configDao.getValue("max.template.iso.size")) * 1024L * 1024L * 1024L;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return null; return null;
} }
} }
private Long getMaxVolumeSizeInBytes() { private Long getMaxVolumeSizeInBytes() {
try { try {
return Long.parseLong(_configDao.getValue("storage.max.volume.upload.size")) * 1024L * 1024L * 1024L; return Long.parseLong(_configDao.getValue("storage.max.volume.upload.size")) * 1024L * 1024L * 1024L;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return null; return null;
} }
} }
private Proxy getHttpProxy() {
if (_proxy == null) {
return null;
}
try {
URI uri = new URI(_proxy);
Proxy prx = new Proxy(uri);
return prx;
} catch (URISyntaxException e) {
return null;
}
}
private Proxy getHttpProxy() {
if (_proxy == null) {
return null;
}
try {
URI uri = new URI(_proxy);
Proxy prx = new Proxy(uri);
return prx;
} catch (URISyntaxException e) {
return null;
}
}
} }

View File

@ -55,15 +55,14 @@ public interface TemplateManager extends TemplateApiService{
* Copies a template from its current secondary storage server to the secondary storage server in the specified zone. * Copies a template from its current secondary storage server to the secondary storage server in the specified zone.
* *
* @param template * @param template
* @param srcSecHost * @param srcSecStore
* @param srcZone
* @param destZone * @param destZone
* @return true if success * @return true if success
* @throws InternalErrorException * @throws InternalErrorException
* @throws StorageUnavailableException * @throws StorageUnavailableException
* @throws ResourceAllocationException * @throws ResourceAllocationException
*/ */
boolean copy(long userId, VMTemplateVO template, HostVO srcSecHost, DataCenterVO srcZone, DataCenterVO dstZone) throws StorageUnavailableException, ResourceAllocationException; boolean copy(long userId, VMTemplateVO template, DataStore srcSecStore, DataCenterVO dstZone) throws StorageUnavailableException, ResourceAllocationException;
/** /**
* Deletes a template from secondary storage servers * Deletes a template from secondary storage servers
@ -107,6 +106,8 @@ public interface TemplateManager extends TemplateApiService{
HostVO getSecondaryStorageHost(long zoneId, long tmpltId); HostVO getSecondaryStorageHost(long zoneId, long tmpltId);
DataStore getImageStore(long zoneId, long tmpltId);
VMTemplateHostVO getTemplateHostRef(long zoneId, long tmpltId, VMTemplateHostVO getTemplateHostRef(long zoneId, long tmpltId,
boolean readyOnly); boolean readyOnly);
@ -120,6 +121,8 @@ public interface TemplateManager extends TemplateApiService{
String getChecksum(Long hostId, String templatePath); String getChecksum(Long hostId, String templatePath);
String getChecksum(DataStore store, String templatePath);
List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId); List<DataStore> getImageStoreByTemplate(long templateId, Long zoneId);
} }

View File

@ -125,6 +125,7 @@ import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.StorageManager; import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StoragePoolHostVO;
@ -838,6 +839,20 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
return null; return null;
} }
@Override
public String getChecksum(DataStore store, String templatePath) {
String secUrl = store.getUri();
Answer answer;
answer = _agentMgr.sendToSecStorage(store, new ComputeChecksumCommand(
secUrl, templatePath));
if (answer != null && answer.getResult()) {
return answer.getDetails();
}
return null;
}
@Override @Override
@DB @DB
public VMTemplateHostVO prepareISOForCreate(VMTemplateVO template, StoragePool pool) { public VMTemplateHostVO prepareISOForCreate(VMTemplateVO template, StoragePool pool) {
@ -897,18 +912,20 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
@Override @Override
@DB @DB
public boolean copy(long userId, VMTemplateVO template, HostVO srcSecHost, DataCenterVO srcZone, DataCenterVO dstZone) throws StorageUnavailableException, ResourceAllocationException { public boolean copy(long userId, VMTemplateVO template, DataStore srcSecStore, DataCenterVO dstZone) throws StorageUnavailableException, ResourceAllocationException {
List<HostVO> dstSecHosts = _ssvmMgr.listSecondaryStorageHostsInOneZone(dstZone.getId());
long tmpltId = template.getId(); long tmpltId = template.getId();
long dstZoneId = dstZone.getId(); long dstZoneId = dstZone.getId();
if (dstSecHosts == null || dstSecHosts.isEmpty() ) { // find all eligible image stores for the destination zone
throw new StorageUnavailableException("Destination zone is not ready", DataCenter.class, dstZone.getId()); List<DataStore> dstSecStores = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(dstZoneId));
if (dstSecStores == null || dstSecStores.isEmpty() ) {
throw new StorageUnavailableException("Destination zone is not ready, no image store associated", DataCenter.class, dstZone.getId());
} }
AccountVO account = _accountDao.findById(template.getAccountId()); AccountVO account = _accountDao.findById(template.getAccountId());
VMTemplateHostVO srcTmpltHost = _tmpltHostDao.findByHostTemplate(srcSecHost.getId(), tmpltId); // find the size of the template to be copied
TemplateDataStoreVO srcTmpltStore = this._tmplStoreDao.findByStoreTemplate(srcSecStore.getId(), tmpltId);
_resourceLimitMgr.checkResourceLimit(account, ResourceType.template); _resourceLimitMgr.checkResourceLimit(account, ResourceType.template);
_resourceLimitMgr.checkResourceLimit(account, ResourceType.secondary_storage, new Long(srcTmpltHost.getSize())); _resourceLimitMgr.checkResourceLimit(account, ResourceType.secondary_storage, new Long(srcTmpltStore.getSize()));
// Event details // Event details
String copyEventType; String copyEventType;
@ -924,30 +941,31 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
Transaction txn = Transaction.currentTxn(); Transaction txn = Transaction.currentTxn();
txn.start(); txn.start();
for ( HostVO dstSecHost : dstSecHosts ) { //Copy will just find one eligible image store for the destination zone and copy template there, not propagate to all image stores
VMTemplateHostVO dstTmpltHost = null; // for that zone
for ( DataStore dstSecStore : dstSecStores ) {
TemplateDataStoreVO dstTmpltStore = null;
try { try {
dstTmpltHost = _tmpltHostDao.findByHostTemplate(dstSecHost.getId(), tmpltId, true); dstTmpltStore = this._tmplStoreDao.findByStoreTemplate(dstSecStore.getId(), tmpltId, true);
if (dstTmpltHost != null) { if (dstTmpltStore != null) {
dstTmpltHost = _tmpltHostDao.lockRow(dstTmpltHost.getId(), true); dstTmpltStore = _tmplStoreDao.lockRow(dstTmpltStore.getId(), true);
if (dstTmpltHost != null && dstTmpltHost.getDownloadState() == Status.DOWNLOADED) { if (dstTmpltStore != null && dstTmpltStore.getDownloadState() == Status.DOWNLOADED) {
if (dstTmpltHost.getDestroyed() == false) { if (dstTmpltStore.getDestroyed() == false) {
return true; return true; // already downloaded on this image store
} else { } else {
dstTmpltHost.setDestroyed(false); dstTmpltStore.setDestroyed(false);
_tmpltHostDao.update(dstTmpltHost.getId(), dstTmpltHost); _tmplStoreDao.update(dstTmpltStore.getId(), dstTmpltStore);
return true; return true;
} }
} else if (dstTmpltHost != null && dstTmpltHost.getDownloadState() == Status.DOWNLOAD_ERROR){ } else if (dstTmpltStore != null && dstTmpltStore.getDownloadState() == Status.DOWNLOAD_ERROR){
if (dstTmpltHost.getDestroyed() == true) { if (dstTmpltStore.getDestroyed() == true) {
dstTmpltHost.setDestroyed(false); dstTmpltStore.setDestroyed(false);
dstTmpltHost.setDownloadState(Status.NOT_DOWNLOADED); dstTmpltStore.setDownloadState(Status.NOT_DOWNLOADED);
dstTmpltHost.setDownloadPercent(0); dstTmpltStore.setDownloadPercent(0);
dstTmpltHost.setCopy(true); dstTmpltStore.setCopy(true);
dstTmpltHost.setErrorString(""); dstTmpltStore.setErrorString("");
dstTmpltHost.setJobId(null); dstTmpltStore.setJobId(null);
_tmpltHostDao.update(dstTmpltHost.getId(), dstTmpltHost); _tmplStoreDao.update(dstTmpltStore.getId(), dstTmpltStore);
} }
} }
} }
@ -955,11 +973,11 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
txn.commit(); txn.commit();
} }
if(_downloadMonitor.copyTemplate(template, srcSecHost, dstSecHost) ) { if(_downloadMonitor.copyTemplate(template, srcSecStore, dstSecStore) ) {
_tmpltDao.addTemplateToZone(template, dstZoneId); _tmpltDao.addTemplateToZone(template, dstZoneId);
if(account.getId() != Account.ACCOUNT_ID_SYSTEM){ if(account.getId() != Account.ACCOUNT_ID_SYSTEM){
UsageEventUtils.publishUsageEvent(copyEventType, account.getId(), dstZoneId, tmpltId, null, null, null, srcTmpltHost.getSize(), UsageEventUtils.publishUsageEvent(copyEventType, account.getId(), dstZoneId, tmpltId, null, null, null, srcTmpltStore.getSize(),
template.getClass().getName(), template.getUuid()); template.getClass().getName(), template.getUuid());
} }
return true; return true;
@ -969,6 +987,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
} }
@Override @Override
@ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_COPY, eventDescription = "copying template", async = true) @ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_COPY, eventDescription = "copying template", async = true)
public VirtualMachineTemplate copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException, ResourceAllocationException { public VirtualMachineTemplate copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException, ResourceAllocationException {
@ -978,6 +998,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
Long destZoneId = cmd.getDestinationZoneId(); Long destZoneId = cmd.getDestinationZoneId();
Account caller = UserContext.current().getCaller(); Account caller = UserContext.current().getCaller();
/*
if (_swiftMgr.isSwiftEnabled()) { if (_swiftMgr.isSwiftEnabled()) {
throw new CloudRuntimeException("copytemplate API is disabled in Swift setup, templates in Swift can be accessed by all Zones"); throw new CloudRuntimeException("copytemplate API is disabled in Swift setup, templates in Swift can be accessed by all Zones");
} }
@ -986,6 +1007,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw new CloudRuntimeException( throw new CloudRuntimeException(
"copytemplate API is disabled in S3 setup -- S3 templates are accessible in all zones."); "copytemplate API is disabled in S3 setup -- S3 templates are accessible in all zones.");
} }
*/
//Verify parameters //Verify parameters
if (sourceZoneId == destZoneId) { if (sourceZoneId == destZoneId) {
@ -1007,20 +1029,24 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw new InvalidParameterValueException("Unable to find template with id"); throw new InvalidParameterValueException("Unable to find template with id");
} }
HostVO dstSecHost = getSecondaryStorageHost(destZoneId, templateId); DataStore dstSecStore = getImageStore(destZoneId, templateId);
if ( dstSecHost != null ) { if ( dstSecStore != null ) {
s_logger.debug("There is template " + templateId + " in secondary storage " + dstSecHost.getId() + " in zone " + destZoneId + " , don't need to copy"); s_logger.debug("There is template " + templateId + " in secondary storage " + dstSecStore.getName() + " in zone " + destZoneId + " , don't need to copy");
return template; return template;
} }
HostVO srcSecHost = getSecondaryStorageHost(sourceZoneId, templateId); DataStore srcSecStore = getImageStore(sourceZoneId, templateId);
if ( srcSecHost == null ) { if ( srcSecStore == null ) {
throw new InvalidParameterValueException("There is no template " + templateId + " in zone " + sourceZoneId ); throw new InvalidParameterValueException("There is no template " + templateId + " in zone " + sourceZoneId );
} }
if ( srcSecStore.getScope().getScopeType() == ScopeType.REGION){
s_logger.debug("Template " + templateId + " is in region-wide secondary storage " + dstSecStore.getName() + " , don't need to copy");
return template;
}
_accountMgr.checkAccess(caller, AccessType.ModifyEntry, true, template); _accountMgr.checkAccess(caller, AccessType.ModifyEntry, true, template);
boolean success = copy(userId, template, srcSecHost, sourceZone, dstZone); boolean success = copy(userId, template, srcSecStore, dstZone);
if (success){ if (success){
return template; return template;
@ -2073,6 +2099,23 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
return secondaryStorageHost.getStorageUrl(); return secondaryStorageHost.getStorageUrl();
} }
// get the image store where a template in a given zone is downloaded to, just pick one is enough.
@Override
public DataStore getImageStore(long zoneId, long tmpltId) {
List<DataStore> stores = this.dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
if (stores == null || stores.size() == 0) {
return null;
}
for (DataStore host : stores) {
List<TemplateDataStoreVO> tmpltStore = this._tmplStoreDao.listByTemplateStoreDownloadStatus(
tmpltId, host.getId(), VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
if ( tmpltStore != null && tmpltStore.size() > 0 ){
return host;
}
}
return null;
}
@Override @Override
public HostVO getSecondaryStorageHost(long zoneId, long tmpltId) { public HostVO getSecondaryStorageHost(long zoneId, long tmpltId) {
List<HostVO> hosts = _ssvmMgr List<HostVO> hosts = _ssvmMgr

View File

@ -21,6 +21,7 @@ import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
@ -140,6 +141,19 @@ public class MockAgentManagerImpl extends ManagerBase implements AgentManager {
return null; return null;
} }
@Override
public void sendToSecStorage(DataStore ssStore, Command cmd, Listener listener) throws AgentUnavailableException {
// TODO Auto-generated method stub
}
@Override
public Answer sendToSecStorage(DataStore ssStore, Command cmd) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) { public boolean tapLoadingAgents(Long hostId, TapAgentsAction action) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -191,7 +205,7 @@ public class MockAgentManagerImpl extends ManagerBase implements AgentManager {
@Override @Override
public void disconnectWithInvestigation(long hostId, Event event) { public void disconnectWithInvestigation(long hostId, Event event) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }