本文整理了Java中com.cloud.resource.ResourceManager.listAllHostsInCluster
方法的一些代码示例,展示了ResourceManager.listAllHostsInCluster
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceManager.listAllHostsInCluster
方法的具体详情如下:
包路径:com.cloud.resource.ResourceManager
类名称:ResourceManager
方法名:listAllHostsInCluster
暂无
代码示例来源:origin: apache/cloudstack
private List<Long> getUpdatedClusterList(List<Long> clusterList, Set<Long> hostsSet) {
List<Long> updatedClusterList = new ArrayList<Long>();
for (Long cluster : clusterList) {
List<HostVO> hosts = resourceMgr.listAllHostsInCluster(cluster);
Set<Long> hostsInClusterSet = new HashSet<Long>();
for (HostVO host : hosts) {
hostsInClusterSet.add(host.getId());
}
if (!hostsSet.containsAll(hostsInClusterSet)) {
updatedClusterList.add(cluster);
}
}
return updatedClusterList;
}
代码示例来源:origin: apache/cloudstack
private boolean updateHostsInCluster(final UpdateHostPasswordCmd command) {
// get all the hosts in this cluster
final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(command.getClusterId());
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
for (final HostVO h : hosts) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Changing password for host name = " + h.getName());
}
// update password for this host
final DetailVO nv = _detailsDao.findDetail(h.getId(), ApiConstants.USERNAME);
if (nv.getValue().equals(command.getUsername())) {
final DetailVO nvp = _detailsDao.findDetail(h.getId(), ApiConstants.PASSWORD);
nvp.setValue(DBEncryptionUtil.encrypt(command.getPassword()));
_detailsDao.persist(nvp);
} else {
// if one host in the cluster has diff username then
// rollback to maintain consistency
throw new InvalidParameterValueException("The username is not same for all hosts, please modify passwords for individual hosts.");
}
}
}
});
return true;
}
代码示例来源:origin: apache/cloudstack
protected HypervisorType getClusterToStartDomainRouterForOvm(final long podId) {
final List<ClusterVO> clusters = _clusterDao.listByPodId(podId);
for (final ClusterVO cv : clusters) {
if (cv.getHypervisorType() == HypervisorType.Ovm || cv.getHypervisorType() == HypervisorType.BareMetal) {
continue;
}
final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cv.getId());
if (hosts == null || hosts.isEmpty()) {
continue;
}
for (final HostVO h : hosts) {
if (h.getState() == Status.Up) {
s_logger.debug("Pick up host that has hypervisor type " + h.getHypervisorType() + " in cluster " + cv.getId() + " to start domain router for OVM");
return h.getHypervisorType();
}
}
}
final String errMsg = new StringBuilder("Cannot find an available cluster in Pod ").append(podId)
.append(" to start domain router for Ovm. \n Ovm won't support any system vm including domain router, ")
.append("please make sure you have a cluster with hypervisor type of any of xenserver/KVM/Vmware in the same pod")
.append(" with Ovm cluster. And there is at least one host in UP status in that cluster.").toString();
throw new CloudRuntimeException(errMsg);
}
代码示例来源:origin: apache/cloudstack
if (!CollectionUtils.isEmpty(clusterList)) {
for (Long cluster : clusterList) {
List<HostVO> hostsInCluster = resourceMgr.listAllHostsInCluster(cluster);
for (HostVO hostVO : hostsInCluster) {
代码示例来源:origin: apache/cloudstack
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
FenceCommand fence = new FenceCommand(vm, host);
代码示例来源:origin: apache/cloudstack
List<HostVO> hosts = resourceMgr.listAllHostsInCluster(host
.getClusterId());
FenceCommand fence = new FenceCommand(vm, host);
代码示例来源:origin: apache/cloudstack
setClusterGuid(clu, poolUuid);
} else {
List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId);
if (clusterHosts != null && clusterHosts.size() > 0) {
if (!clu.getGuid().equals(poolUuid)) {
代码示例来源:origin: apache/cloudstack
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
FenceCommand fence = new FenceCommand(vm, host);
代码示例来源:origin: apache/cloudstack
List<HostVO> hostsInCluster = resourceMgr.listAllHostsInCluster(cluster);
for (HostVO hostVO : hostsInCluster) {
allHosts.add(hostVO.getId());
代码示例来源:origin: apache/cloudstack
@Override
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
StartupCommand firstCmd = cmd[0];
if (!(firstCmd instanceof StartupRoutingCommand)) {
return null;
}
StartupRoutingCommand ssCmd = ((StartupRoutingCommand)firstCmd);
if (ssCmd.getHypervisorType() != getHypervisorType()) {
return null;
}
/* KVM requires host are the same in cluster */
ClusterVO clusterVO = _clusterDao.findById(host.getClusterId());
if (clusterVO == null) {
s_logger.debug("cannot find cluster: " + host.getClusterId());
throw new IllegalArgumentException("cannot add host, due to can't find cluster: " + host.getClusterId());
}
List<HostVO> hostsInCluster = _resourceMgr.listAllHostsInCluster(clusterVO.getId());
if (!hostsInCluster.isEmpty()) {
HostVO oneHost = hostsInCluster.get(0);
_hostDao.loadDetails(oneHost);
String hostOsInCluster = oneHost.getDetail("Host.OS");
String hostOs = ssCmd.getHostDetails().get("Host.OS");
if (!hostOsInCluster.equalsIgnoreCase(hostOs)) {
throw new IllegalArgumentException("Can't add host: " + firstCmd.getPrivateIpAddress() + " with hostOS: " + hostOs + " into a cluster," +
"in which there are " + hostOsInCluster + " hosts added");
}
}
_hostDao.loadDetails(host);
return _resourceMgr.fillRoutingHostVO(host, ssCmd, getHypervisorType(), host.getDetails(), null);
}
代码示例来源:origin: apache/cloudstack
void setClusterGuid(ClusterVO cluster, String guid) {
cluster.setGuid(guid);
try {
_clusterDao.update(cluster.getId(), cluster);
} catch (EntityExistsException e) {
QueryBuilder<ClusterVO> sc = QueryBuilder.create(ClusterVO.class);
sc.and(sc.entity().getGuid(), Op.EQ, guid);
List<ClusterVO> clusters = sc.list();
ClusterVO clu = clusters.get(0);
List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clu.getId());
if (clusterHosts == null || clusterHosts.size() == 0) {
clu.setGuid(null);
_clusterDao.update(clu.getId(), clu);
_clusterDao.update(cluster.getId(), cluster);
return;
}
throw e;
}
}
代码示例来源:origin: apache/cloudstack
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
FenceCommand fence = new FenceCommand(vm, host);
代码示例来源:origin: apache/cloudstack
@Override
public Status isAgentAlive(Host agent) {
if (agent.getHypervisorType() != HypervisorType.XenServer) {
return null;
}
CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
for (HostVO neighbor : neighbors) {
if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
continue;
}
Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
if (answer != null && answer.getResult()) {
CheckOnHostAnswer ans = (CheckOnHostAnswer)answer;
if (!ans.isDetermined()) {
s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent);
continue;
}
// even it returns true, that means host is up, but XAPI may not work
return ans.isAlive() ? null : Status.Down;
}
}
return null;
}
代码示例来源:origin: apache/cloudstack
if (scope.equals(ScopeType.CLUSTER)) {
ClusterVO cluster = _clusterDao.findById(storagePool.getClusterId());
hosts = _resourceMgr.listAllHostsInCluster(cluster.getId());
} else if (scope.equals(ScopeType.ZONE)) {
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, volume.getDataCenterId());
内容来源于网络,如有侵权,请联系作者删除!