public StartCommand(VirtualMachineTO vm, Host host, boolean executeInSequence) { this.vm = vm; this.hostIp = host.getPrivateIpAddress(); this.executeInSequence = executeInSequence; this.secondaryStorage = null; }
@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); } }
public FenceCommand(VirtualMachine vm, Host host) { super(); vmName = vm.getInstanceName(); hostGuid = host.getGuid(); hostIp = host.getPrivateIpAddress(); inSeq = false; }
s_logger.debug("sending ping from (" + hostId + ") to agent's host ip address (" + agent.getPrivateIpAddress() + ")"); Status hostState = testIpAddress(hostId, agent.getPrivateIpAddress()); assert hostState != null; s_logger.debug("ping from (" + hostId + ") to agent's host ip address (" + agent.getPrivateIpAddress() + ") successful, returning that agent is disconnected");
public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLoadBalancer) { Map<String, String> lbDetails = _hostDetailDao.findDetails(externalLoadBalancer.getId()); ExternalLoadBalancerResponse response = new ExternalLoadBalancerResponse(); response.setId(externalLoadBalancer.getUuid()); response.setIpAddress(externalLoadBalancer.getPrivateIpAddress()); response.setUsername(lbDetails.get("username")); response.setPublicInterface(lbDetails.get("publicInterface")); response.setPrivateInterface(lbDetails.get("privateInterface")); response.setNumRetries(lbDetails.get("numRetries")); return response; }
public ExternalFirewallResponse createExternalFirewallResponse(Host externalFirewall) { Map<String, String> fwDetails = _hostDetailDao.findDetails(externalFirewall.getId()); ExternalFirewallResponse response = new ExternalFirewallResponse(); response.setId(externalFirewall.getUuid()); response.setIpAddress(externalFirewall.getPrivateIpAddress()); response.setUsername(fwDetails.get("username")); response.setPublicInterface(fwDetails.get("publicInterface")); response.setUsageInterface(fwDetails.get("usageInterface")); response.setPrivateInterface(fwDetails.get("privateInterface")); response.setPublicZone(fwDetails.get("publicZone")); response.setPrivateZone(fwDetails.get("privateZone")); response.setNumRetries(fwDetails.get("numRetries")); response.setTimeout(fwDetails.get("timeout")); return response; }
@Override public TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor) { Map<String, String> tmDetails = ApiDBUtils.findHostDetailsById(trafficMonitor.getId()); TrafficMonitorResponse response = new TrafficMonitorResponse(); response.setId(trafficMonitor.getUuid()); response.setIpAddress(trafficMonitor.getPrivateIpAddress()); response.setNumRetries(tmDetails.get("numRetries")); response.setTimeout(tmDetails.get("timeout")); return response; }
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()); } }
private Answer migrateVmWithVolumes(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, Host destHost, Map<VolumeInfo, DataStore> volumeToPool) throws AgentUnavailableException { // Initiate migration of a virtual machine with it's volumes. try { List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<Pair<VolumeTO, StorageFilerTO>>(); for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) { VolumeInfo volume = entry.getKey(); VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId())); StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue()); volumeToFilerto.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo)); } MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto, destHost.getPrivateIpAddress()); MigrateWithStorageAnswer answer = (MigrateWithStorageAnswer) agentMgr.send(srcHost.getId(), command); if (answer == null) { s_logger.error("Migration with storage of vm " + vm + " failed."); throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost); } else if (!answer.getResult()) { s_logger.error("Migration with storage of vm " + vm+ " failed. Details: " + answer.getDetails()); throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost + ". " + answer.getDetails()); } else { // Update the volume details after migration. updateVolumePathsAfterMigration(volumeToPool, answer.getVolumeTos()); } return answer; } catch (OperationTimedoutException e) { s_logger.error("Error while migrating vm " + vm + " to host " + destHost, e); throw new AgentUnavailableException("Operation timed out on storage motion for " + vm, destHost.getId()); } }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { super.reserve(nic, network, vm, dest, context); //get physical network id Long physicalNetworkId = network.getPhysicalNetworkId(); List<OpenDaylightControllerVO> devices = openDaylightControllerMappingDao.listByPhysicalNetwork(physicalNetworkId); if (devices.isEmpty()) { s_logger.error("No Controller on physical network " + physicalNetworkId); throw new InsufficientVirtualNetworkCapacityException("No OpenDaylight Controller configured for this network", dest.getPod().getId()); } OpenDaylightControllerVO controller = devices.get(0); AddHypervisorCommand addCmd = new AddHypervisorCommand(dest.getHost().getUuid(), dest.getHost().getPrivateIpAddress()); AddHypervisorAnswer addAnswer = (AddHypervisorAnswer)agentManager.easySend(controller.getHostId(), addCmd); if (addAnswer == null || !addAnswer.getResult()) { s_logger.error("Failed to add " + dest.getHost().getName() + " as a node to the controller"); throw new InsufficientVirtualNetworkCapacityException("Failed to add destination hypervisor to the OpenDaylight Controller", dest.getPod().getId()); } ConfigurePortCommand cmd = new ConfigurePortCommand(UUID.fromString(nic.getUuid()), UUID.fromString(BroadcastDomainType.getValue(network.getBroadcastUri())), context .getAccount().getAccountName(), nic.getMacAddress()); ConfigurePortAnswer answer = (ConfigurePortAnswer)agentManager.easySend(controller.getHostId(), cmd); if (answer == null || !answer.getResult()) { s_logger.error("ConfigureNetworkCommand failed"); throw new InsufficientVirtualNetworkCapacityException("Failed to configure the port on the OpenDaylight Controller", dest.getPod().getId()); } }
SspClient.TenantPort sspPort = client.updateTenantVifBinding(tenantPortUuid, dest.getHost().getPrivateIpAddress()); if (sspPort != null) { if (sspPort.vlanId != null) {
@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; }
String lbIP = lbHost.getPrivateIpAddress(); DestroyLoadBalancerApplianceCommand lbDeleteCmd = new DestroyLoadBalancerApplianceCommand(lbIP); DestroyLoadBalancerApplianceAnswer answer = null; _dcDao.releasePrivateIpAddress(lbHost.getPrivateIpAddress(), guestConfig.getDataCenterId(), null);
@Override public PaloAltoFirewallResponse createPaloAltoFirewallResponse(ExternalFirewallDeviceVO fwDeviceVO) { PaloAltoFirewallResponse response = new PaloAltoFirewallResponse(); Map<String, String> fwDetails = _hostDetailDao.findDetails(fwDeviceVO.getHostId()); Host fwHost = _hostDao.findById(fwDeviceVO.getHostId()); response.setId(fwDeviceVO.getUuid()); PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(fwDeviceVO.getPhysicalNetworkId()); if (pnw != null) { response.setPhysicalNetworkId(pnw.getUuid()); } response.setDeviceName(fwDeviceVO.getDeviceName()); if (fwDeviceVO.getCapacity() == 0) { long defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50); response.setDeviceCapacity(defaultFwCapacity); } else { response.setDeviceCapacity(fwDeviceVO.getCapacity()); } response.setProvider(fwDeviceVO.getProviderName()); response.setDeviceState(fwDeviceVO.getDeviceState().name()); response.setIpAddress(fwHost.getPrivateIpAddress()); response.setPublicInterface(fwDetails.get("publicInterface")); response.setUsageInterface(fwDetails.get("usageInterface")); response.setPrivateInterface(fwDetails.get("privateInterface")); response.setPublicZone(fwDetails.get("publicZone")); response.setPrivateZone(fwDetails.get("privateZone")); response.setNumRetries(fwDetails.get("numRetries")); response.setTimeout(fwDetails.get("timeout")); response.setObjectName("paloaltofirewall"); return response; }
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()); } }
Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId()); response.setId(lbDeviceVO.getUuid()); response.setIpAddress(lbHost.getPrivateIpAddress()); PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(lbDeviceVO.getPhysicalNetworkId()); if (pnw != null) {
try { final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); final MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows, to, getExecuteInSequence(vm.getHypervisorType()));
boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); MigrateCommand migrateCommand = new MigrateCommand(vmTO.getName(), destHost.getPrivateIpAddress(), isWindows, vmTO, true);
try { final boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); final MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows, to, getExecuteInSequence(vm.getHypervisorType()));