gpt4 book ai didi

org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope.getScopeId()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:04:49 27 4
gpt4 key购买 nike

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

ZoneScope.getScopeId介绍

暂无

代码示例

代码示例来源: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 List<ImageStoreVO> findImageCacheByScope(ZoneScope scope) {
  SearchCriteria<ImageStoreVO> sc = createSearchCriteria();
  sc.addAnd("role", SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
  if (scope.getScopeId() != null) {
    sc.addAnd("scope", SearchCriteria.Op.EQ, ScopeType.ZONE);
    sc.addAnd("dcId", SearchCriteria.Op.EQ, scope.getScopeId());
  }
  return listBy(sc);
}

代码示例来源: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 List<ImageStoreVO> findByScope(ZoneScope scope) {
  SearchCriteria<ImageStoreVO> sc = createSearchCriteria();
  sc.addAnd("role", SearchCriteria.Op.EQ, DataStoreRole.Image);
  if (scope.getScopeId() != null) {
    SearchCriteria<ImageStoreVO> scc = createSearchCriteria();
    scc.addOr("scope", SearchCriteria.Op.EQ, ScopeType.REGION);
    scc.addOr("dcId", SearchCriteria.Op.EQ, scope.getScopeId());
    sc.addAnd("scope", SearchCriteria.Op.SC, scc);
  }
  // we should return all image stores if cross-zone scope is passed
  // (scopeId = null)
  return listBy(sc);
}

代码示例来源: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;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com