Search in sources :

Example 61 with ClusterVO

use of com.cloud.dc.ClusterVO in project cosmic by MissionCriticalCloud.

the class ClusterDaoImpl method getAvailableHypervisorInZone.

@Override
public List<HypervisorType> getAvailableHypervisorInZone(final Long zoneId) {
    final SearchCriteria<ClusterVO> sc = AvailHyperSearch.create();
    if (zoneId != null) {
        sc.setParameters("zoneId", zoneId);
    }
    final List<ClusterVO> clusters = listBy(sc);
    final List<HypervisorType> hypers = new ArrayList<>(4);
    for (final ClusterVO cluster : clusters) {
        hypers.add(cluster.getHypervisorType());
    }
    return hypers;
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) ClusterVO(com.cloud.dc.ClusterVO) ArrayList(java.util.ArrayList)

Example 62 with ClusterVO

use of com.cloud.dc.ClusterVO in project cosmic by MissionCriticalCloud.

the class AbstractStoragePoolAllocator method filter.

protected boolean filter(final ExcludeList avoid, final StoragePool pool, final DiskProfile dskCh, final DeploymentPlan plan) {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Checking if storage pool is suitable, name: " + pool.getName() + " ,poolId: " + pool.getId());
    }
    if (avoid.shouldAvoid(pool)) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("StoragePool is in avoid set, skipping this pool");
        }
        return false;
    }
    final Long clusterId = pool.getClusterId();
    if (clusterId != null) {
        final ClusterVO cluster = _clusterDao.findById(clusterId);
        if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool");
            }
            return false;
        }
    } else if (pool.getHypervisor() != null && !pool.getHypervisor().equals(HypervisorType.Any) && !(pool.getHypervisor() == dskCh.getHypervisorType())) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("StoragePool does not have required hypervisorType, skipping this pool");
        }
        return false;
    }
    if (!checkHypervisorCompatibility(dskCh.getHypervisorType(), dskCh.getType(), pool.getPoolType())) {
        return false;
    }
    // check capacity
    final Volume volume = _volumeDao.findById(dskCh.getVolumeId());
    final List<Volume> requestVolumes = new ArrayList<>();
    requestVolumes.add(volume);
    return storageMgr.storagePoolHasEnoughIops(requestVolumes, pool) && storageMgr.storagePoolHasEnoughSpace(requestVolumes, pool);
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Volume(com.cloud.storage.Volume) ArrayList(java.util.ArrayList)

Example 63 with ClusterVO

use of com.cloud.dc.ClusterVO in project cosmic by MissionCriticalCloud.

the class ExplicitDedicationProcessor method process.

/**
 * This method will process the affinity group of type 'Explicit Dedication' for a deployment of a VM that demands dedicated resources.
 * For ExplicitDedicationProcessor we need to add dedicated resources into the IncludeList based on the level we have dedicated resources available.
 * For eg. if admin dedicates a pod to a domain, then all the user in that domain can use the resources of that pod.
 * We need to take care of the situation when dedicated resources further have resources dedicated to sub-domain/account.
 * This IncludeList is then used to update the avoid list for a given data center.
 */
@Override
public void process(final VirtualMachineProfile vmProfile, final DeploymentPlan plan, ExcludeList avoid) throws AffinityConflictException {
    final VirtualMachine vm = vmProfile.getVirtualMachine();
    final List<AffinityGroupVMMapVO> vmGroupMappings = _affinityGroupVMMapDao.findByVmIdType(vm.getId(), getType());
    final Zone zone = zoneRepository.findOne(vm.getDataCenterId());
    final List<DedicatedResourceVO> resourceList = new ArrayList<>();
    if (vmGroupMappings != null && !vmGroupMappings.isEmpty()) {
        for (final AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) {
            if (vmGroupMapping != null) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId() + "of type 'ExplicitDedication' for VM Id: " + vm.getId());
                }
                final long affinityGroupId = vmGroupMapping.getAffinityGroupId();
                final List<DedicatedResourceVO> dr = _dedicatedDao.listByAffinityGroupId(affinityGroupId);
                resourceList.addAll(dr);
            }
        }
        boolean canUse = false;
        if (plan.getHostId() != null) {
            final HostVO host = _hostDao.findById(plan.getHostId());
            final ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
            final HostPodVO podOfHost = _podDao.findById(host.getPodId());
            final Zone zoneOfHost = zoneRepository.findOne(host.getDataCenterId());
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getHostId() != null && resource.getHostId().longValue() == plan.getHostId().longValue()) || (resource.getClusterId() != null && resource.getClusterId().longValue() == clusterofHost.getId()) || (resource.getPodId() != null && resource.getPodId().longValue() == podOfHost.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId().longValue() == zoneOfHost.getId())) {
                        canUse = true;
                    }
                }
            }
            if (!canUse) {
                throw new CloudRuntimeException("Cannot use this host " + host.getName() + " for explicit dedication");
            }
        } else if (plan.getClusterId() != null) {
            final ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
            final HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
            final Zone zoneOfCluster = zoneRepository.findOne(cluster.getDataCenterId());
            final List<HostVO> hostToUse = new ArrayList<>();
            // check whether this cluster or its pod is dedicated
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getClusterId() != null && resource.getClusterId() == cluster.getId()) || (resource.getPodId() != null && resource.getPodId() == podOfCluster.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfCluster.getId())) {
                        canUse = true;
                    }
                    // cluster
                    if (!canUse) {
                        if (resource.getHostId() != null) {
                            final HostVO dHost = _hostDao.findById(resource.getHostId());
                            if (dHost.getClusterId() == cluster.getId()) {
                                hostToUse.add(dHost);
                            }
                        }
                    }
                }
            }
            if (hostToUse.isEmpty() && !canUse) {
                throw new CloudRuntimeException("Cannot use this cluster " + cluster.getName() + " for explicit dedication");
            }
            if (hostToUse != null && hostToUse.size() != 0) {
                // add other non-dedicated hosts to avoid list
                final List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
                for (final HostVO host : hostList) {
                    if (!hostToUse.contains(host)) {
                        avoid.addHost(host.getId());
                    }
                }
            }
        } else if (plan.getPodId() != null) {
            final HostPodVO pod = _podDao.findById(plan.getPodId());
            final Zone zoneOfPod = zoneRepository.findOne(pod.getDataCenterId());
            final List<ClusterVO> clustersToUse = new ArrayList<>();
            final List<HostVO> hostsToUse = new ArrayList<>();
            // check whether this cluster or its pod is dedicated
            if (resourceList != null && resourceList.size() != 0) {
                for (final DedicatedResourceVO resource : resourceList) {
                    if ((resource.getPodId() != null && resource.getPodId() == pod.getId()) || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfPod.getId())) {
                        canUse = true;
                    }
                    // this pod
                    if (!canUse) {
                        if (resource.getClusterId() != null) {
                            final ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
                            if (dCluster.getPodId() == pod.getId()) {
                                clustersToUse.add(dCluster);
                            }
                        }
                        if (resource.getHostId() != null) {
                            final HostVO dHost = _hostDao.findById(resource.getHostId());
                            if (dHost.getPodId() == pod.getId()) {
                                hostsToUse.add(dHost);
                            }
                        }
                    }
                }
            }
            if (hostsToUse.isEmpty() && clustersToUse.isEmpty() && !canUse) {
                throw new CloudRuntimeException("Cannot use this pod " + pod.getName() + " for explicit dedication");
            }
            if (clustersToUse != null && clustersToUse.size() != 0) {
                // add other non-dedicated clusters to avoid list
                final List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
                for (final ClusterVO cluster : clusterList) {
                    if (!clustersToUse.contains(cluster)) {
                        avoid.addCluster(cluster.getId());
                    }
                }
            }
            if (hostsToUse != null && hostsToUse.size() != 0) {
                // add other non-dedicated hosts to avoid list
                final List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
                for (final HostVO host : hostList) {
                    if (!hostsToUse.contains(host)) {
                        avoid.addHost(host.getId());
                    }
                }
            }
        } else {
            // check all resources under this zone
            if (resourceList != null && resourceList.size() != 0) {
                avoid = updateAvoidList(resourceList, avoid, zone);
            } else {
                avoid.addZone(zone.getId());
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("No dedicated resources available for this domain or account under this group");
                }
            }
            s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: {}", avoid.toString());
        }
    }
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) List(java.util.List) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 64 with ClusterVO

use of com.cloud.dc.ClusterVO in project cosmic by MissionCriticalCloud.

the class DedicatedResourceManagerImpl method dedicateZone.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_DEDICATE_RESOURCE, eventDescription = "dedicating a Zone")
public List<DedicatedResourceVO> dedicateZone(final Long zoneId, final Long domainId, final String accountName) {
    Long accountId = null;
    List<HostVO> hosts = null;
    if (accountName != null) {
        final Account caller = CallContext.current().getCallingAccount();
        final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
        accountId = owner.getId();
    }
    final List<Long> childDomainIds = getDomainChildIds(domainId);
    childDomainIds.add(domainId);
    checkAccountAndDomain(accountId, domainId);
    final Zone zone = zoneRepository.findOne(zoneId);
    if (zone == null) {
        throw new InvalidParameterValueException("Unable to find zone by id " + zoneId);
    } else {
        final DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(zoneId);
        // check if zone is dedicated
        if (dedicatedZone != null) {
            s_logger.error("Zone " + zone.getName() + " is already dedicated");
            throw new CloudRuntimeException("Zone  " + zone.getName() + " is already dedicated");
        }
        // check if any resource under this zone is dedicated to different account or sub-domain
        final List<HostPodVO> pods = _podDao.listByDataCenterId(zone.getId());
        final List<DedicatedResourceVO> podsToRelease = new ArrayList<>();
        final List<DedicatedResourceVO> clustersToRelease = new ArrayList<>();
        final List<DedicatedResourceVO> hostsToRelease = new ArrayList<>();
        for (final HostPodVO pod : pods) {
            final DedicatedResourceVO dPod = _dedicatedDao.findByPodId(pod.getId());
            if (dPod != null) {
                if (!(childDomainIds.contains(dPod.getDomainId()))) {
                    throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dPod.getAccountId().equals(accountId)) {
                        podsToRelease.add(dPod);
                    } else {
                        s_logger.error("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dPod.getAccountId() == null && dPod.getDomainId().equals(domainId)) {
                        podsToRelease.add(dPod);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : podsToRelease) {
            releaseDedicatedResource(null, dr.getPodId(), null, null);
        }
        final List<ClusterVO> clusters = _clusterDao.listClustersByDcId(zone.getId());
        for (final ClusterVO cluster : clusters) {
            final DedicatedResourceVO dCluster = _dedicatedDao.findByClusterId(cluster.getId());
            if (dCluster != null) {
                if (!(childDomainIds.contains(dCluster.getDomainId()))) {
                    throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dCluster.getAccountId().equals(accountId)) {
                        clustersToRelease.add(dCluster);
                    } else {
                        s_logger.error("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dCluster.getAccountId() == null && dCluster.getDomainId().equals(domainId)) {
                        clustersToRelease.add(dCluster);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : clustersToRelease) {
            releaseDedicatedResource(null, null, dr.getClusterId(), null);
        }
        hosts = _hostDao.listByDataCenterId(zone.getId());
        for (final HostVO host : hosts) {
            final DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
            if (dHost != null) {
                if (!(childDomainIds.contains(dHost.getDomainId()))) {
                    throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                }
                if (accountId != null) {
                    if (dHost.getAccountId().equals(accountId)) {
                        hostsToRelease.add(dHost);
                    } else {
                        s_logger.error("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                        throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + zone.getName() + " is dedicated to different account/domain");
                    }
                } else {
                    if (dHost.getAccountId() == null && dHost.getDomainId().equals(domainId)) {
                        hostsToRelease.add(dHost);
                    }
                }
            }
        }
        for (final DedicatedResourceVO dr : hostsToRelease) {
            releaseDedicatedResource(null, null, null, dr.getHostId());
        }
    }
    checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);
    final Long accountIdFinal = accountId;
    return Transaction.execute(new TransactionCallback<List<DedicatedResourceVO>>() {

        @Override
        public List<DedicatedResourceVO> doInTransaction(final TransactionStatus status) {
            // find or create the affinity group by name under this account/domain
            final AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountIdFinal);
            if (group == null) {
                s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
                throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
            }
            DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zoneId, null, null, null, null, null, group.getId());
            try {
                dedicatedResource.setDomainId(domainId);
                if (accountIdFinal != null) {
                    dedicatedResource.setAccountId(accountIdFinal);
                }
                dedicatedResource = _dedicatedDao.persist(dedicatedResource);
                // save the domainId in the zone
                zone.setDomainId(domainId);
                zoneRepository.save(zone);
            } catch (final Exception e) {
                s_logger.error("Unable to dedicate zone due to " + e.getMessage(), e);
                throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
            }
            final List<DedicatedResourceVO> result = new ArrayList<>();
            result.add(dedicatedResource);
            return result;
        }
    });
}
Also used : Account(com.cloud.user.Account) ClusterVO(com.cloud.dc.ClusterVO) Zone(com.cloud.db.model.Zone) ArrayList(java.util.ArrayList) TransactionStatus(com.cloud.utils.db.TransactionStatus) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) AffinityGroup(com.cloud.affinity.AffinityGroup) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) List(java.util.List) ArrayList(java.util.ArrayList) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) ActionEvent(com.cloud.event.ActionEvent) DB(com.cloud.utils.db.DB)

Example 65 with ClusterVO

use of com.cloud.dc.ClusterVO in project cosmic by MissionCriticalCloud.

the class XcpServerDiscoverer method find.

@Override
public Map<? extends ServerResource, Map<String, String>> find(final long dcId, final Long podId, final Long clusterId, final URI url, final String username, final String password, final List<String> hostTags) throws DiscoveryException {
    final Map<CitrixResourceBase, Map<String, String>> resources = new HashMap<>();
    Connection conn = null;
    if (!url.getScheme().equals("http")) {
        final String msg = "urlString is not http so we're not taking care of the discovery for this: " + url;
        s_logger.debug(msg);
        return null;
    }
    if (clusterId == null) {
        final String msg = "must specify cluster Id when add host";
        s_logger.debug(msg);
        throw new RuntimeException(msg);
    }
    if (podId == null) {
        final String msg = "must specify pod Id when add host";
        s_logger.debug(msg);
        throw new RuntimeException(msg);
    }
    final ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null || cluster.getHypervisorType() != HypervisorType.XenServer) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info("invalid cluster id or cluster is not for XenServer hypervisors");
        }
        return null;
    }
    try {
        final String hostname = url.getHost();
        final InetAddress ia = InetAddress.getByName(hostname);
        final String hostIp = ia.getHostAddress();
        final Queue<String> pass = new LinkedList<>();
        pass.add(password);
        conn = _connPool.getConnect(hostIp, username, pass);
        if (conn == null) {
            final String msg = "Unable to get a connection to " + url;
            s_logger.debug(msg);
            throw new DiscoveryException(msg);
        }
        final Set<Pool> pools = Pool.getAll(conn);
        final Pool pool = pools.iterator().next();
        final Pool.Record pr = pool.getRecord(conn);
        String poolUuid = pr.uuid;
        final Map<Host, Host.Record> hosts = Host.getAllRecords(conn);
        String latestHotFix = "";
        if (poolHasHotFix(conn, hostIp, XenserverConfigs.XSHotFix62ESP1004)) {
            latestHotFix = XenserverConfigs.XSHotFix62ESP1004;
        } else if (poolHasHotFix(conn, hostIp, XenserverConfigs.XSHotFix62ESP1)) {
            latestHotFix = XenserverConfigs.XSHotFix62ESP1;
        }
        /*set cluster hypervisor type to xenserver*/
        final ClusterVO clu = _clusterDao.findById(clusterId);
        if (clu.getGuid() == null) {
            setClusterGuid(clu, poolUuid);
        } else {
            final List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId);
            if (clusterHosts != null && clusterHosts.size() > 0) {
                if (!clu.getGuid().equals(poolUuid)) {
                    final String msg = "Please join the host " + hostIp + " to XS pool  " + clu.getGuid() + " through XC/XS before adding it through CS UI";
                    s_logger.warn(msg);
                    throw new DiscoveryException(msg);
                }
            } else {
                setClusterGuid(clu, poolUuid);
            }
        }
        // can not use this conn after this point, because this host may join a pool, this conn is retired
        if (conn != null) {
            try {
                Session.logout(conn);
            } catch (final Exception e) {
                s_logger.debug("Caught exception during logout", e);
            }
            conn.dispose();
            conn = null;
        }
        poolUuid = clu.getGuid();
        _clusterDao.update(clusterId, clu);
        if (_checkHvm) {
            for (final Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
                final Host.Record record = entry.getValue();
                boolean support_hvm = false;
                for (final String capability : record.capabilities) {
                    if (capability.contains("hvm")) {
                        support_hvm = true;
                        break;
                    }
                }
                if (!support_hvm) {
                    final String msg = "Unable to add host " + record.address + " because it doesn't support hvm";
                    _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, msg, msg);
                    s_logger.debug(msg);
                    throw new RuntimeException(msg);
                }
            }
        }
        for (final Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
            final Host.Record record = entry.getValue();
            final String hostAddr = record.address;
            final String prodVersion = CitrixHelper.getProductVersion(record);
            final String xenVersion = record.softwareVersion.get("xen");
            String hostOS = record.softwareVersion.get("product_brand");
            if (hostOS == null) {
                hostOS = record.softwareVersion.get("platform_name");
            }
            final String hostOSVer = prodVersion;
            final String hostKernelVer = record.softwareVersion.get("linux");
            if (_resourceMgr.findHostByGuid(record.uuid) != null) {
                s_logger.debug("Skipping " + record.address + " because " + record.uuid + " is already in the database.");
                continue;
            }
            final CitrixResourceBase resource = createServerResource(dcId, podId, record, latestHotFix);
            s_logger.info("Found host " + record.hostname + " ip=" + record.address + " product version=" + prodVersion);
            final Map<String, String> details = new HashMap<>();
            final Map<String, Object> params = new HashMap<>();
            details.put("url", hostAddr);
            details.put("username", username);
            params.put("username", username);
            details.put("password", password);
            params.put("password", password);
            params.put("zone", Long.toString(dcId));
            params.put("guid", record.uuid);
            params.put("pod", podId.toString());
            params.put("cluster", clusterId.toString());
            params.put("pool", poolUuid);
            params.put("ipaddress", record.address);
            details.put(HostInfo.HOST_OS, hostOS);
            details.put(HostInfo.HOST_OS_VERSION, hostOSVer);
            details.put(HostInfo.HOST_OS_KERNEL_VERSION, hostKernelVer);
            details.put(HostInfo.HYPERVISOR_VERSION, xenVersion);
            final String privateNetworkLabel = _networkMgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.XenServer);
            final String storageNetworkLabel = _networkMgr.getDefaultStorageTrafficLabel(dcId, HypervisorType.XenServer);
            if (!params.containsKey("private.network.device") && privateNetworkLabel != null) {
                params.put("private.network.device", privateNetworkLabel);
                details.put("private.network.device", privateNetworkLabel);
            }
            if (!params.containsKey("storage.network.device1") && storageNetworkLabel != null) {
                params.put("storage.network.device1", storageNetworkLabel);
                details.put("storage.network.device1", storageNetworkLabel);
            }
            params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
            params.put("wait", Integer.toString(_wait));
            details.put("wait", Integer.toString(_wait));
            params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
            params.put(Config.XenServerMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenServerMaxNics.toString()));
            params.put(Config.XenServerHeartBeatTimeout.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatTimeout.toString()));
            params.put(Config.XenServerHeartBeatInterval.toString().toLowerCase(), _configDao.getValue(Config.XenServerHeartBeatInterval.toString()));
            params.put(Config.InstanceName.toString().toLowerCase(), _instance);
            details.put(Config.InstanceName.toString().toLowerCase(), _instance);
            try {
                resource.configure("XenServer", params);
            } catch (final ConfigurationException e) {
                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + record.address, "Error is " + e.getMessage());
                s_logger.warn("Unable to instantiate " + record.address, e);
                continue;
            }
            resource.start();
            resources.put(resource, details);
        }
    } catch (final SessionAuthenticationFailed e) {
        throw new DiscoveredWithErrorException("Authentication error");
    } catch (final XenAPIException e) {
        s_logger.warn("XenAPI exception", e);
        return null;
    } catch (final XmlRpcException e) {
        s_logger.warn("Xml Rpc Exception", e);
        return null;
    } catch (final UnknownHostException e) {
        s_logger.warn("Unable to resolve the host name", e);
        return null;
    } catch (final Exception e) {
        s_logger.debug("other exceptions: " + e.toString(), e);
        return null;
    }
    return resources;
}
Also used : HashMap(java.util.HashMap) XenAPIException(com.xensource.xenapi.Types.XenAPIException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ConfigurationException(javax.naming.ConfigurationException) Pool(com.xensource.xenapi.Pool) XenServerConnectionPool(com.cloud.hypervisor.xenserver.resource.XenServerConnectionPool) DiscoveryException(com.cloud.exception.DiscoveryException) ClusterVO(com.cloud.dc.ClusterVO) UnknownHostException(java.net.UnknownHostException) Connection(com.xensource.xenapi.Connection) DiscoveredWithErrorException(com.cloud.exception.DiscoveredWithErrorException) Host(com.xensource.xenapi.Host) LinkedList(java.util.LinkedList) HostVO(com.cloud.host.HostVO) DiscoveredWithErrorException(com.cloud.exception.DiscoveredWithErrorException) DiscoveryException(com.cloud.exception.DiscoveryException) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) XenAPIException(com.xensource.xenapi.Types.XenAPIException) EntityExistsException(javax.persistence.EntityExistsException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) ConfigurationException(javax.naming.ConfigurationException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) HypervisorVersionChangedException(com.cloud.utils.exception.HypervisorVersionChangedException) UnknownHostException(java.net.UnknownHostException) UnableDeleteHostException(com.cloud.resource.UnableDeleteHostException) CitrixResourceBase(com.cloud.hypervisor.xenserver.resource.CitrixResourceBase) SessionAuthenticationFailed(com.xensource.xenapi.Types.SessionAuthenticationFailed) Map(java.util.Map) HashMap(java.util.HashMap) InetAddress(java.net.InetAddress) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Aggregations

ClusterVO (com.cloud.dc.ClusterVO)151 HostVO (com.cloud.host.HostVO)72 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)66 ArrayList (java.util.ArrayList)55 HostPodVO (com.cloud.dc.HostPodVO)46 DataCenterVO (com.cloud.dc.DataCenterVO)38 ConfigurationException (javax.naming.ConfigurationException)37 HashMap (java.util.HashMap)28 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)24 Map (java.util.Map)24 DiscoveryException (com.cloud.exception.DiscoveryException)21 DB (com.cloud.utils.db.DB)21 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)20 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)20 Account (com.cloud.user.Account)17 List (java.util.List)17 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)17 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)16 ClusterDetailsVO (com.cloud.dc.ClusterDetailsVO)15 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)14