@Override protected HashMap<String, Object> buildConfigParams(HostVO host) { HashMap<String, Object> params = super.buildConfigParams(host); DataCenterVO zone = _dcDao.findById(host.getDataCenterId()); if (zone != null) { boolean securityGroupEnabled = zone.isSecurityGroupEnabled(); params.put("securitygroupenabled", Boolean.toString(securityGroupEnabled)); } return params; }
@Override public void postDiscovery(List<HostVO> hosts, long msId) { if (_useServiceVM) { for (HostVO h : hosts) { _agentMgr.agentStatusTransitTo(h, Event.AgentDisconnected, msId); } } for (HostVO h : hosts) { associateTemplatesToZone(h.getId(), h.getDataCenterId()); } }
private void updateNetworkLabels(HostVO host) { //check if networkLabels need to be updated in details //we send only private and storage network label to the resource. String privateNetworkLabel = _networkMgr.getDefaultManagementTrafficLabel(host.getDataCenterId(), host.getHypervisorType()); String storageNetworkLabel = _networkMgr.getDefaultStorageTrafficLabel(host.getDataCenterId(), host.getHypervisorType()); String privateDevice = host.getDetail("private.network.device"); String storageDevice = host.getDetail("storage.network.device1"); boolean update = false; if (privateNetworkLabel != null && !privateNetworkLabel.equalsIgnoreCase(privateDevice)) { host.setDetail("private.network.device", privateNetworkLabel); update = true; } if (storageNetworkLabel != null && !storageNetworkLabel.equalsIgnoreCase(storageDevice)) { host.setDetail("storage.network.device1", storageNetworkLabel); update = true; } if (update) { _hostDao.saveDetails(host); } }
private void sendModifyTargetsCommand(ModifyTargetsCommand cmd, long hostId) { Answer answer = agentMgr.easySend(hostId, cmd); if (answer == null) { throw new CloudRuntimeException("Unable to get an answer to the modify targets command"); } if (!answer.getResult()) { String msg = "Unable to modify targets on the following host: " + hostId; HostVO host = hostDao.findById(hostId); alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), msg, msg); throw new CloudRuntimeException(msg); } }
private void sendModifyTargetsCommand(ModifyTargetsCommand cmd, long hostId) { Answer answer = agentMgr.easySend(hostId, cmd); if (answer == null) { throw new CloudRuntimeException("Unable to get an answer to the modify targets command"); } if (!answer.getResult()) { String msg = "Unable to modify targets on the following host: " + hostId; HostVO host = hostDao.findById(hostId); alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), msg, msg); throw new CloudRuntimeException(msg); } }
@Override public List<HostVO> listAllHostsInOneZoneByType(final Type type, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getType(), Op.EQ, type); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); return sc.list(); }
@Override public List<HostVO> findHostByGuid(final long dcId, final String guid) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getGuid(), Op.EQ, guid); return sc.list(); }
@Override public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) { StartupCommand firstCmd = startup[0]; if (!(firstCmd instanceof StartupRoutingCommand)) { return null; } StartupRoutingCommand ssCmd = ((StartupRoutingCommand)firstCmd); if (ssCmd.getHypervisorType() != HypervisorType.XenServer) { return null; } HostPodVO pod = _podDao.findById(host.getPodId()); DataCenterVO dc = _dcDao.findById(host.getDataCenterId()); s_logger.info("Host: " + host.getName() + " connected with hypervisor type: " + HypervisorType.XenServer + ". Checking CIDR..."); _resourceMgr.checkCIDR(pod, dc, ssCmd.getPrivateIpAddress(), ssCmd.getPrivateNetmask()); return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.XenServer, details, hostTags); }
@Override public final HostVO createHostVOForDirectConnectAgent(final HostVO host, final StartupCommand[] startup, final ServerResource resource, final Map<String, String> details, final List<String> hostTags) { StartupCommand firstCmd = startup[0]; if (!(firstCmd instanceof StartupRoutingCommand)) { return null; } StartupRoutingCommand ssCmd = ((StartupRoutingCommand)firstCmd); if (ssCmd.getHypervisorType() != HypervisorType.Hyperv) { return null; } s_logger.info("Host: " + host.getName() + " connected with hypervisor type: " + HypervisorType.Hyperv + ". Checking CIDR..."); HostPodVO pod = _podDao.findById(host.getPodId()); DataCenterVO dc = _dcDao.findById(host.getDataCenterId()); _resourceMgr.checkCIDR(pod, dc, ssCmd.getPrivateIpAddress(), ssCmd.getPrivateNetmask()); return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Hyperv, details, hostTags); }
@Override public List<HostVO> listAllNotInMaintenanceHostsInOneZone(final Type type, final Long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); if (dcId != null) { sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); } sc.and(sc.entity().getType(), Op.EQ, type); sc.and(sc.entity().getResourceState(), Op.NIN, ResourceState.Maintenance, ResourceState.ErrorInMaintenance, ResourceState.PrepareForMaintenance, ResourceState.Error); return sc.list(); }
private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) { QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); if (dcId != null) { sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); } sc.and(sc.entity().getStatus(), Op.IN, Status.Up, Status.Connecting); sc.and(sc.entity().getType(), Op.EQ, Host.Type.SecondaryStorageVM); return sc.list(); }
@Override public List<HostVO> listAllUpAndEnabledHostsInOneZone(final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled); return sc.list(); }
@Override public VMTemplateHostVO findLocalSecondaryStorageByHostTemplate(long hostId, long templateId) { HostVO computingHost = _hostDao.findById(hostId); SearchCriteria<VMTemplateHostVO> sc = LocalSecondaryStorageSearch.create(); sc.setJoinParameters("host", "private_ip_address", computingHost.getPrivateIpAddress()); sc.setJoinParameters("host", "state", com.cloud.host.Status.Up); sc.setJoinParameters("host", "data_center_id", computingHost.getDataCenterId()); sc.setJoinParameters("host", "type", Host.Type.LocalSecondaryStorage); sc.setParameters("template_id", templateId); sc.setParameters("state", VMTemplateHostVO.Status.DOWNLOADED); sc.setParameters("destroyed", false); return findOneBy(sc); }
@Override public boolean prepareNodes(Long clusterId) { ClusterVO cluster = _clusterDao.findById(clusterId); if (cluster == null) { throw new CloudRuntimeException("Cannot find cluster for ID " + clusterId); } QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getClusterId(), Op.EQ, clusterId); sc.and(sc.entity().getPodId(), Op.EQ, cluster.getPodId()); sc.and(sc.entity().getDataCenterId(), Op.EQ, cluster.getDataCenterId()); sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing); List<HostVO> hosts = sc.list(); if (hosts.isEmpty()) { s_logger.debug("There is no host in cluster " + clusterId + ", no need to prepare OCFS2 nodes"); return true; } return prepareNodes(getClusterName(clusterId), hosts); }
@Override public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getHypervisorType(), Op.EQ, type); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled); return sc.list(); }
@Override public List<HostVO> listAllUpAndEnabledHostsInOneZoneByType(final Type type, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); sc.and(sc.entity().getType(), Op.EQ, type); sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled); return sc.list(); }
@Override public List<HostVO> listAllHosts(final Type type, final Long clusterId, final Long podId, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); if (type != null) { sc.and(sc.entity().getType(), Op.EQ, type); } if (clusterId != null) { sc.and(sc.entity().getClusterId(), Op.EQ, clusterId); } if (podId != null) { sc.and(sc.entity().getPodId(), Op.EQ, podId); } sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); return sc.list(); }
@Override public List<HostVO> listAllUpHosts(Type type, Long clusterId, Long podId, long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); if (type != null) { sc.and(sc.entity().getType(), Op.EQ, type); } if (clusterId != null) { sc.and(sc.entity().getClusterId(), Op.EQ, clusterId); } if (podId != null) { sc.and(sc.entity().getPodId(), Op.EQ, podId); } sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); return sc.list(); }
@Override public List<HostVO> listAllUpAndEnabledHosts(final Type type, final Long clusterId, final Long podId, final long dcId) { final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); if (type != null) { sc.and(sc.entity().getType(), Op.EQ, type); } if (clusterId != null) { sc.and(sc.entity().getClusterId(), Op.EQ, clusterId); } if (podId != null) { sc.and(sc.entity().getPodId(), Op.EQ, podId); } sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId); sc.and(sc.entity().getStatus(), Op.EQ, Status.Up); sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled); return sc.list(); }
@Override public List<HostVO> listByDataCenterIdAndHypervisorType(long zoneId, Hypervisor.HypervisorType hypervisorType) { SearchBuilder<ClusterVO> clusterSearch = _clusterDao.createSearchBuilder(); clusterSearch.and("allocationState", clusterSearch.entity().getAllocationState(), SearchCriteria.Op.EQ); clusterSearch.and("hypervisorType", clusterSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ); SearchBuilder<HostVO> hostSearch = createSearchBuilder(); hostSearch.and("dc", hostSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); hostSearch.and("type", hostSearch.entity().getType(), Op.EQ); hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ); hostSearch.and("resourceState", hostSearch.entity().getResourceState(), Op.EQ); hostSearch.join("clusterSearch", clusterSearch, hostSearch.entity().getClusterId(), clusterSearch.entity().getId(), JoinBuilder.JoinType.INNER); hostSearch.done(); SearchCriteria<HostVO> sc = hostSearch.create(); sc.setParameters("dc", zoneId); sc.setParameters("type", Host.Type.Routing); sc.setParameters("status", Status.Up); sc.setParameters("resourceState", ResourceState.Enabled); sc.setJoinParameters("clusterSearch", "allocationState", Grouping.AllocationState.Enabled); sc.setJoinParameters("clusterSearch", "hypervisorType", hypervisorType.toString()); return listBy(sc); }