use of com.cloud.legacymodel.auth.Certificates in project cosmic by MissionCriticalCloud.
the class KeystoreManagerImpl method getCertificates.
@Override
public Certificates getCertificates(final String name) {
final KeystoreVO ksVo = _ksDao.findByName(name);
if (ksVo == null) {
return null;
}
final String prvKey = ksVo.getKey();
final String prvCert = ksVo.getCertificate();
final String domainSuffix = ksVo.getDomainSuffix();
String certChain = null;
String rootCert = null;
final List<KeystoreVO> certchains = _ksDao.findCertChain(domainSuffix);
if (certchains.size() > 0) {
final ArrayList<String> chains = new ArrayList<>();
for (final KeystoreVO cert : certchains) {
if (chains.size() == 0) {
// For the first time it will be length 0
rootCert = cert.getCertificate();
}
chains.add(cert.getCertificate());
}
Collections.reverse(chains);
certChain = StringUtils.join(chains, "\n");
}
final Certificates certs = new Certificates(prvKey, prvCert, certChain, rootCert);
return certs;
}
use of com.cloud.legacymodel.auth.Certificates in project cosmic by MissionCriticalCloud.
the class SecondaryStorageManagerImpl method generateSetupCommand.
@Override
public boolean generateSetupCommand(final Long ssHostId) {
final HostVO cssHost = this._hostDao.findById(ssHostId);
final Long zoneId = cssHost.getDataCenterId();
if (cssHost.getType() == HostType.SecondaryStorageVM) {
final SecondaryStorageVmVO secStorageVm = this._secStorageVmDao.findByInstanceName(cssHost.getName());
if (secStorageVm == null) {
logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist");
return false;
}
final List<DataStore> ssStores = this._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 (!this._useSSlCopy) {
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, null);
} else {
final Certificates certs = this._keystoreMgr.getCertificates(ConsoleProxyManager.CERTIFICATE_NAME);
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, certs);
}
// template/volume file upload key
final String postUploadKey = this._configDao.getValue(Config.SSVMPSK.key());
setupCmd.setPostUploadKey(postUploadKey);
final Answer answer = this._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 = this._imageStoreDao.findById(ssStore.getId());
svo.setParent(an.get_dir());
this._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