com.cloud.resource.ResourceManager.listAllUpAndEnabledHostsInOneZoneByHypervisor()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中com.cloud.resource.ResourceManager.listAllUpAndEnabledHostsInOneZoneByHypervisor方法的一些代码示例,展示了ResourceManager.listAllUpAndEnabledHostsInOneZoneByHypervisor的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager.listAllUpAndEnabledHostsInOneZoneByHypervisor方法的具体详情如下:
包路径:com.cloud.resource.ResourceManager
类名称:ResourceManager
方法名:listAllUpAndEnabledHostsInOneZoneByHypervisor

ResourceManager.listAllUpAndEnabledHostsInOneZoneByHypervisor介绍

暂无

代码示例

代码示例来源:origin: apache/cloudstack

@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) {
  dataStoreHelper.attachZone(dataStore);
  List<HostVO> xenServerHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(Hypervisor.HypervisorType.XenServer, scope.getScopeId());
  List<HostVO> vmWareServerHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(Hypervisor.HypervisorType.VMware, scope.getScopeId());
  List<HostVO> kvmHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(Hypervisor.HypervisorType.KVM, scope.getScopeId());
  List<HostVO> hosts = new ArrayList<HostVO>();
  hosts.addAll(xenServerHosts);
  hosts.addAll(vmWareServerHosts);
  hosts.addAll(kvmHosts);
  for (HostVO host : hosts) {
    try {
      _storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
    } catch (Exception e) {
      logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
    }
  }
  return true;
}

代码示例来源:origin: apache/cloudstack

@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
  List<HostVO> xenServerHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType.XenServer, scope.getScopeId());
  List<HostVO> vmWareServerHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType.VMware, scope.getScopeId());
  List<HostVO> kvmHosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType.KVM, scope.getScopeId());
  List<HostVO> hosts = new ArrayList<>();
  hosts.addAll(xenServerHosts);
  hosts.addAll(vmWareServerHosts);
  hosts.addAll(kvmHosts);
  for (HostVO host : hosts) {
    try {
      _storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
    } catch (Exception e) {
      s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
    }
  }
  _dataStoreHelper.attachZone(dataStore);
  return true;
}

代码示例来源:origin: apache/cloudstack

@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
  List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId());
  s_logger.debug("In createPool. Attaching the pool to each of the hosts.");
  List<HostVO> poolHosts = new ArrayList<HostVO>();
  for (HostVO host : hosts) {
    try {
      storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
      poolHosts.add(host);
    } catch (Exception e) {
      s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
    }
  }
  if (poolHosts.isEmpty()) {
    s_logger.warn("No host can access storage pool " + dataStore + " in this zone.");
    primaryDataStoreDao.expunge(dataStore.getId());
    throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts.");
  }
  dataStoreHelper.attachZone(dataStore, hypervisorType);
  return true;
}

代码示例来源:origin: apache/cloudstack

@Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
  List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId());
  s_logger.debug("In createPool. Attaching the pool to each of the hosts.");
  List<HostVO> poolHosts = new ArrayList<HostVO>();
  for (HostVO host : hosts) {
    try {
      storageMgr.connectHostToSharedPool(host.getId(), dataStore.getId());
      poolHosts.add(host);
    } catch (StorageConflictException se) {
        primaryDataStoreDao.expunge(dataStore.getId());
        throw new CloudRuntimeException("Storage has already been added as local storage to host: " + host.getName());
    } catch (Exception e) {
      s_logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
    }
  }
  if (poolHosts.isEmpty()) {
    s_logger.warn("No host can access storage pool " + dataStore + " in this zone.");
    primaryDataStoreDao.expunge(dataStore.getId());
    throw new CloudRuntimeException("Failed to create storage pool as it is not accessible to hosts.");
  }
  dataStoreHelper.attachZone(dataStore, hypervisorType);
  return true;
}

代码示例来源:origin: apache/cloudstack

hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
} else if (scope.equals(ScopeType.ZONE)) {
  hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, volume.getDataCenterId());

代码示例来源:origin: apache/cloudstack

hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());

代码示例来源:origin: apache/cloudstack

hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor(), pool.getDataCenterId());

相关文章