use of com.cloud.engine.subsystem.api.storage.DataStore in project cosmic by MissionCriticalCloud.
the class SecondaryStorageManagerImpl method generateSetupCommand.
@Override
public boolean generateSetupCommand(final Long ssHostId) {
final HostVO cssHost = _hostDao.findById(ssHostId);
final Long zoneId = cssHost.getDataCenterId();
if (cssHost.getType() == Host.Type.SecondaryStorageVM) {
final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(cssHost.getName());
if (secStorageVm == null) {
logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist");
return false;
}
final List<DataStore> ssStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(zoneId));
for (final DataStore ssStore : ssStores) {
if (!(ssStore.getTO() instanceof NfsTO)) {
// only do this for Nfs
continue;
}
final String secUrl = ssStore.getUri();
final SecStorageSetupCommand setupCmd;
if (!_useSSlCopy) {
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, null);
} else {
final KeystoreManager.Certificates certs = _keystoreMgr.getCertificates(ConsoleProxyManager.CERTIFICATE_NAME);
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, certs);
}
// template/volume file upload key
final String postUploadKey = _configDao.getValue(Config.SSVMPSK.key());
setupCmd.setPostUploadKey(postUploadKey);
final Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
if (answer != null && answer.getResult()) {
final SecStorageSetupAnswer an = (SecStorageSetupAnswer) answer;
if (an.get_dir() != null) {
// update the parent path in image_store table for this image store
final ImageStoreVO svo = _imageStoreDao.findById(ssStore.getId());
svo.setParent(an.get_dir());
_imageStoreDao.update(ssStore.getId(), svo);
}
logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
} else {
logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName());
return false;
}
}
}
return true;
}
Aggregations