Codota Logo
Host
Code IndexAdd Codota to your IDE (free)

How to use
Host
in
com.cloud.host

Best Java code snippets using com.cloud.host.Host (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Point p =
  • Codota Iconnew Point(x, y)
  • Codota Iconnew Point()
  • Codota IconMouseEvent e;e.getPoint()
  • Smart code suggestions by Codota
}
origin: apache/cloudstack

public boolean shouldAvoid(Host host) {
  if (_dcIds != null && _dcIds.contains(host.getDataCenterId())) {
    return true;
  }
  if (_podIds != null && _podIds.contains(host.getPodId())) {
    return true;
  }
  if (_clusterIds != null && _clusterIds.contains(host.getClusterId())) {
    return true;
  }
  if (_hostIds != null && _hostIds.contains(host.getId())) {
    return true;
  }
  return false;
}
origin: apache/cloudstack

@Override
public void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
  if (!(cmd instanceof StartupRoutingCommand)) {
    return;
  }
  if(s_logger.isDebugEnabled()) {
    s_logger.debug("Received startup command from hypervisor host. host id: " + agent.getId());
  }
  _syncMgr.resetHostSyncState(agent.getId());
  if (forRebalance) {
    s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process");
    return;
  }
  final Long clusterId = agent.getClusterId();
  final long agentId = agent.getId();
  if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen
    // initiate the cron job
    final ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId);
    try {
      final long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this);
      s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no);
    } catch (final AgentUnavailableException e) {
      s_logger.fatal("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e);
    }
  }
}
origin: apache/cloudstack

@Override
public String toString() {
  return String.format("[OOBM Task] Power operation:%s on Host:%d(%s)", powerOperation, host.getId(), host.getName());
}
origin: apache/cloudstack

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());
  }
}
origin: apache/cloudstack

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();
    }
  }
}
origin: apache/cloudstack

final long dstHostId = dest.getHost().getId();
final Host fromHost = _hostDao.findById(srcHostId);
if (fromHost == null) {
if (fromHost.getClusterId().longValue() != dest.getCluster().getId()) {
  s_logger.info("Source and destination host are not in same cluster, unable to migrate to host: " + dstHostId);
  throw new CloudRuntimeException("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId());
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()));
  mc.setHostGuid(dest.getHost().getGuid());
    s_logger.info("Migration was unsuccessful.  Cleaning up: " + vm);
    _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(),
        "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " +
            dest.getPod().getName(), "Migrate Command failed.  Please check logs.");
    try {
origin: apache/cloudstack

  @Override
  public void run() {
    try {
      service.executePowerOperation(host, powerOperation, null);
    } catch (Exception e) {
      LOG.warn(String.format("Out-of-band management background task operation=%s for host id=%d failed with: %s",
          powerOperation.name(), host.getId(), e.getMessage()));
    }
  }
}
origin: apache/cloudstack

@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());
  }
}
origin: apache/cloudstack

if (host == null || host.getManagementServerId() == null || host.getManagementServerId() != ManagementServerNode.getManagementServerId() || host.getStatus() != Status.Up) {
  if (host == null || (host.getManagementServerId() != null && host.getManagementServerId() != ManagementServerNode.getManagementServerId())) {
    it.remove();
final String hostDescription = String.format("host id=%d, uuid=%s, name=%s, ip=%s, zone id=%d", host.getId(), host.getUuid(), host.getName(), hostIp, host.getDataCenterId());
  certificate.checkValidity(now.plusDays(CertExpiryAlertPeriod.valueIn(host.getClusterId())).toDate());
} catch (final CertificateExpiredException | CertificateNotYetValidException e) {
  LOG.warn("Certificate is going to expire for " + hostDescription, e);
  if (AutomaticCertRenewal.valueIn(host.getClusterId())) {
    try {
      LOG.debug("Attempting certificate auto-renewal for " + hostDescription, e);
origin: apache/cloudstack

@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;
}
origin: apache/cloudstack

  @Override
  public Status isAgentAlive(Host agent) {
    LOGGER.debug("isAgentAlive: " + agent.getName());
    if (agent.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) {
      return null;
    }
    CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
    List<HostVO> neighbors = resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), Status.Up);
    for (HostVO neighbor : neighbors) {
      if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != Hypervisor.HypervisorType.Ovm3) {
        continue;
      }
      try {
        Answer answer = agentMgr.easySend(neighbor.getId(), cmd);
        if (answer != null) {
          return answer.getResult() ? Status.Down : Status.Up;
        }
      } catch (Exception e) {
        LOGGER.error("Failed to send command to host: " + neighbor.getId(), e);
      }
    }

    return null;
  }
}
origin: apache/cloudstack

@Override
public boolean checkIfHostReachMaxGuestLimit(Host host) {
  Long vmCount = _vmDao.countActiveByHostId(host.getId());
  HypervisorType hypervisorType = host.getHypervisorType();
  String hypervisorVersion = host.getHypervisorVersion();
  Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion);
  if (vmCount.longValue() >= maxGuestLimit.longValue()) {
    s_logger.info("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit: " +
      maxGuestLimit + ", Running VM count: " + vmCount.longValue());
    return true;
  }
  return false;
}
origin: apache/cloudstack

public boolean isOutOfBandManagementEnabled(final Host host) {
  return host != null && isOutOfBandManagementEnabledForZone(host.getDataCenterId())
      && isOutOfBandManagementEnabledForCluster(host.getClusterId())
      && isOutOfBandManagementEnabledForHost(host.getId());
}
origin: apache/cloudstack

for (Volume vol : volumesOrderBySizeDesc) {
  haveEnoughSpace = false;
  s_logger.debug("Checking if host: " + potentialHost.getId() + " can access any suitable storage pool for volume: " + vol.getVolumeType());
  List<StoragePool> volumePoolList = suitableVolumeStoragePools.get(vol);
  hostCanAccessPool = false;
          !_storageMgr.storagePoolHasEnoughSpace(requestVolumes, potentialSPool, potentialHost.getClusterId()))
          continue;
        volumeAllocationMap.put(potentialSPool, requestVolumes);
if (hostCanAccessPool && haveEnoughSpace && hostAffinityCheck && checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired)) {
  s_logger.debug("Found a potential host " + "id: " + potentialHost.getId() + " name: " + potentialHost.getName() +
      " and associated storage pools for this VM");
  return new Pair<Host, Map<Volume, StoragePool>>(potentialHost, storage);
} else {
  avoid.addHost(potentialHost.getId());
origin: apache/cloudstack

  @Override
  public void doInTransactionWithoutResult(TransactionStatus status) {
    CapacityVO capacity =
      new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId(), usedMemoryFinal, host.getTotalMemory(),
        Capacity.CAPACITY_TYPE_MEMORY);
    capacity.setReservedCapacity(reservedMemoryFinal);
    capacity.setCapacityState(capacityState);
    _capacityDao.persist(capacity);
    capacity =
      new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId(), usedCpuFinal, host.getCpus().longValue() *
        host.getSpeed().longValue(), Capacity.CAPACITY_TYPE_CPU);
    capacity.setReservedCapacity(reservedCpuFinal);
    capacity.setCapacityState(capacityState);
    _capacityDao.persist(capacity);
  }
});
origin: apache/cloudstack

private boolean isVMActivtyOnHost(Host agent, DateTime suspectTime) throws StorageUnavailableException {
  if (agent.getHypervisorType() != Hypervisor.HypervisorType.KVM && agent.getHypervisorType() != Hypervisor.HypervisorType.LXC) {
    throw new IllegalStateException("Calling KVM investigator for non KVM Host of type " + agent.getHypervisorType());
  }
  boolean activityStatus = true;
  HashMap<StoragePool, List<Volume>> poolVolMap = getVolumeUuidOnHost(agent);
  for (StoragePool pool : poolVolMap.keySet()) {
    //for each storage pool find activity
    List<Volume> volume_list = poolVolMap.get(pool);
    final CheckVMActivityOnStoragePoolCommand cmd = new CheckVMActivityOnStoragePoolCommand(agent, pool, volume_list, suspectTime);
    //send the command to appropriate storage pool
    Answer answer = storageManager.sendToPool(pool, getNeighbors(agent), cmd);
    if (answer != null) {
      activityStatus = ! answer.getResult();
    } else {
      throw new IllegalStateException("Did not get a valid response for VM activity check for host " + agent.getId());
    }
  }
  if (LOG.isDebugEnabled()){
    LOG.debug("Resource active = " + activityStatus);
  }
  return activityStatus;
}
origin: apache/cloudstack

protected AgentAttache createAttacheForDirectConnect(final Host host, final ServerResource resource) throws ConnectionException {
  s_logger.debug("create DirectAgentAttache for " + host.getId());
  final DirectAgentAttache attache = new DirectAgentAttache(this, host.getId(), host.getName(), resource, host.isInMaintenanceStates());
  AgentAttache old = null;
  synchronized (_agents) {
    old = _agents.put(host.getId(), attache);
  }
  if (old != null) {
    old.disconnect(Status.Removed);
  }
  return attache;
}
origin: apache/cloudstack

if (srcHost.getHypervisorType() != HypervisorType.KVM) {
  throw new CloudRuntimeException("Invalid hypervisor type (only KVM supported for this operation at the time being)");
  Answer pfma = _agentMgr.send(destHost.getId(), pfmc);
    String msg = "Unable to prepare for migration due to the following: " + details;
    throw new AgentUnavailableException(msg, destHost.getId());
  throw new AgentUnavailableException("Operation timed out", destHost.getId());
boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
MigrateCommand migrateCommand = new MigrateCommand(vmTO.getName(), destHost.getPrivateIpAddress(), isWindows, vmTO, true);
MigrateAnswer migrateAnswer = (MigrateAnswer)_agentMgr.send(srcHost.getId(), migrateCommand);
origin: apache/cloudstack

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());
  }
}
origin: apache/cloudstack

@Override
public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
  if (cmd instanceof StartupRoutingCommand) {
    List<HypervisorType> hypers = _resourceMgr.listAvailHypervisorInZone(agent.getId(), agent.getDataCenterId());
    HypervisorType hostHyper = agent.getHypervisorType();
    if (hypers.contains(hostHyper)) {
      return;
    _imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
    _imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
      List<DataStore> imageStores = _storeMgr.getImageStoresByScope(new ZoneScope(agent.getDataCenterId()));
      for (DataStore store : imageStores) {
        _volumeSrv.handleVolumeSync(store);
com.cloud.hostHost

Javadoc

Host represents one particular host server.

Most used methods

  • getId
  • getHypervisorType
  • getName
  • getPrivateIpAddress
  • getClusterId
  • getType
  • getUuid
  • getDataCenterId
  • getStatus
  • getGuid
  • getPodId
  • getPublicIpAddress
  • getPodId,
  • getPublicIpAddress,
  • getManagementServerId,
  • getPrivateMacAddress,
  • getRemoved,
  • getStorageIpAddress,
  • isInMaintenanceStates,
  • getCapabilities,
  • getCpuSockets,
  • getCpus

Popular in Java

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • orElseThrow (Optional)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now