public boolean generateSetupCommand(Long ssHostId) {
HostVO cssHost = _hostDao.findById(ssHostId);
Long zoneId = cssHost.getDataCenterId();
if( cssHost.getType() == Host.Type.SecondaryStorageVM ) {
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(cssHost.getName());
if (secStorageVm == null) {
s_logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist");
return false;
}
List<DataStore> ssStores = this._dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
for( DataStore ssStore : ssStores ) {
if (!(ssStore.getTO() instanceof NfsTO ))
{
continue; // only do this for Nfs
}
String secUrl = ssStore.getUri();
SecStorageSetupCommand setupCmd = null;
if (!_useSSlCopy) {
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, null);
} else {
Certificates certs = _keystoreMgr.getCertificates(ConsoleProxyManager.CERTIFICATE_NAME);
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, certs);
}
Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
if (answer != null && answer.getResult()) {
SecStorageSetupAnswer an = (SecStorageSetupAnswer) answer;
if (an.get_dir() != null){
// update the parent path in image_store table for this image store
ImageStoreVO svo = this._imageStoreDao.findById(ssStore.getId());
svo.setParent(an.get_dir());
_imageStoreDao.update(ssStore.getId(), svo);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
}
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
}
return false;
}
}
}