@Override public void purgeHostCertificate(final Host host) { if (host == null) { return; } final String privateAddress = host.getPrivateIpAddress(); final String publicAddress = host.getPublicIpAddress(); final Map<String, X509Certificate> activeCertsMap = getActiveCertificatesMap(); if (!Strings.isNullOrEmpty(privateAddress) && activeCertsMap.containsKey(privateAddress)) { activeCertsMap.remove(privateAddress); } if (!Strings.isNullOrEmpty(publicAddress) && activeCertsMap.containsKey(publicAddress)) { activeCertsMap.remove(publicAddress); } }
private void configure(Host host) { hostId = host.getId(); hostAddress = host.getPrivateIpAddress(); publicAddress = host.getPublicIpAddress(); if (Host.Type.SecondaryStorageVM == host.getType()) { String vmName = host.getName(); SecondaryStorageVmVO ssvm = vmDao.findByInstanceName(vmName); if (ssvm != null) { publicAddress = ssvm.getPublicIpAddress(); } } }
@Override @ActionEvent(eventType = EventTypes.EVENT_CA_CERTIFICATE_PROVISION, eventDescription = "provisioning certificate for host", async = true) public boolean provisionCertificate(final Host host, final Boolean reconnect, final String caProvider) { if (host == null) { throw new CloudRuntimeException("Unable to find valid host to renew certificate for"); } CallContext.current().setEventDetails("host id: " + host.getId()); CallContext.current().putContextParameter(Host.class, host.getUuid()); final String csr; try { csr = generateKeyStoreAndCsr(host, null); if (Strings.isNullOrEmpty(csr)) { return false; } final Certificate certificate = issueCertificate(csr, Arrays.asList(host.getName(), host.getPrivateIpAddress()), Arrays.asList(host.getPrivateIpAddress(), host.getPublicIpAddress(), host.getStorageIpAddress()), CAManager.CertValidityPeriod.value(), caProvider); return deployCertificate(host, certificate, reconnect, null); } catch (final AgentUnavailableException | OperationTimedoutException e) { LOG.error("Host/agent is not available or operation timed out, failed to setup keystore and generate CSR for host/agent id=" + host.getId() + ", due to: ", e); throw new CloudRuntimeException("Failed to generate keystore and get CSR from the host/agent id=" + host.getId()); } }
public HostTO(Host vo) { guid = vo.getGuid(); privateNetwork = new NetworkTO(vo.getPrivateIpAddress(), vo.getPrivateNetmask(), vo.getPrivateMacAddress()); if (vo.getPublicIpAddress() != null) { publicNetwork = new NetworkTO(vo.getPublicIpAddress(), vo.getPublicNetmask(), vo.getPublicMacAddress()); } if (vo.getStorageIpAddress() != null) { storageNetwork1 = new NetworkTO(vo.getStorageIpAddress(), vo.getStorageNetmask(), vo.getStorageMacAddress()); } if (vo.getStorageIpAddressDeux() != null) { storageNetwork2 = new NetworkTO(vo.getStorageIpAddressDeux(), vo.getStorageNetmaskDeux(), vo.getStorageMacAddressDeux()); } }
@Override public boolean deployCertificate(final Host host, final Certificate certificate, final Boolean reconnect, final Map<String, String> sshAccessDetails) throws AgentUnavailableException, OperationTimedoutException { final SetupCertificateCommand cmd = new SetupCertificateCommand(certificate); if (sshAccessDetails != null && !sshAccessDetails.isEmpty()) { cmd.setAccessDetail(sshAccessDetails); } CallContext.current().setEventDetails("deploying certificate for host id: " + host.getId()); final SetupCertificateAnswer answer = (SetupCertificateAnswer)agentManager.send(host.getId(), cmd); if (answer.getResult()) { CallContext.current().setEventDetails("successfully deployed certificate for host id: " + host.getId()); } else { CallContext.current().setEventDetails("failed to deploy certificate for host id: " + host.getId()); } if (answer.getResult()) { getActiveCertificatesMap().put(host.getPrivateIpAddress(), certificate.getClientCertificate()); if (sshAccessDetails == null && reconnect != null && reconnect) { LOG.info(String.format("Successfully setup certificate on host, reconnecting with agent with id=%d, name=%s, address=%s", host.getId(), host.getName(), host.getPublicIpAddress())); try { agentManager.reconnect(host.getId()); } catch (AgentUnavailableException | CloudRuntimeException e) { LOG.debug("Error when reconnecting to host: " + host.getUuid(), e); } } return true; } return false; }