Search in sources :

Example 91 with ClusterVO

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

the class DedicatedResourceManagerImpl method dedicateHost.

@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_DEDICATE_RESOURCE, eventDescription = "dedicating a Host")
public List<DedicatedResourceVO> dedicateHost(final Long hostId, final Long domainId, final String accountName) {
    Long accountId = null;
    if (accountName != null) {
        final Account caller = CallContext.current().getCallingAccount();
        final Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
        accountId = owner.getId();
    }
    checkAccountAndDomain(accountId, domainId);
    final HostVO host = _hostDao.findById(hostId);
    if (host == null) {
        throw new InvalidParameterValueException("Unable to find host by id " + hostId);
    } else {
        // check if host is of routing type
        if (host.getType() != Host.Type.Routing) {
            throw new CloudRuntimeException("Invalid host type for host " + host.getName());
        }
        final DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId);
        final DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId());
        final DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId());
        final DedicatedResourceVO dedicatedZoneOfHost = _dedicatedDao.findByZoneId(host.getDataCenterId());
        if (dedicatedHost != null) {
            s_logger.error("Host " + host.getName() + " is already dedicated");
            throw new CloudRuntimeException("Host " + host.getName() + " is already dedicated");
        }
        if (dedicatedClusterOfHost != null) {
            final boolean domainIdInChildreanList = getDomainChildIds(dedicatedClusterOfHost.getDomainId()).contains(domainId);
            // can dedicate a host to an account/domain if cluster is dedicated to parent-domain
            if (dedicatedClusterOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || (accountId != null && !(dedicatedClusterOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) {
                final ClusterVO cluster = _clusterDao.findById(host.getClusterId());
                s_logger.error("Host's Cluster " + cluster.getName() + " is already dedicated");
                throw new CloudRuntimeException("Host's Cluster " + cluster.getName() + " is already dedicated");
            }
        }
        if (dedicatedPodOfHost != null) {
            final boolean domainIdInChildreanList = getDomainChildIds(dedicatedPodOfHost.getDomainId()).contains(domainId);
            // can dedicate a host to an account/domain if pod is dedicated to parent-domain
            if (dedicatedPodOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || (accountId != null && !(dedicatedPodOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) {
                final HostPodVO pod = _podDao.findById(host.getPodId());
                s_logger.error("Host's Pod " + pod.getName() + " is already dedicated");
                throw new CloudRuntimeException("Host's Pod " + pod.getName() + " is already dedicated");
            }
        }
        if (dedicatedZoneOfHost != null) {
            final boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfHost.getDomainId()).contains(domainId);
            // can dedicate a host to an account/domain if zone is dedicated to parent-domain
            if (dedicatedZoneOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || (accountId != null && !(dedicatedZoneOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) {
                final Zone zone = zoneRepository.findOne(host.getDataCenterId());
                s_logger.error("Host's Data Center " + zone.getName() + " is already dedicated");
                throw new CloudRuntimeException("Host's Data Center " + zone.getName() + " is already dedicated");
            }
        }
    }
    final List<Long> childDomainIds = getDomainChildIds(domainId);
    childDomainIds.add(domainId);
    checkHostSuitabilityForExplicitDedication(accountId, childDomainIds, hostId);
    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(null, null, null, hostId, null, null, group.getId());
            try {
                dedicatedResource.setDomainId(domainId);
                if (accountIdFinal != null) {
                    dedicatedResource.setAccountId(accountIdFinal);
                }
                dedicatedResource = _dedicatedDao.persist(dedicatedResource);
            } catch (final Exception e) {
                s_logger.error("Unable to dedicate host due to " + e.getMessage(), e);
                throw new CloudRuntimeException("Failed to dedicate host. 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) 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 92 with ClusterVO

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

the class ConfigurationManagerImpl method updateConfiguration.

@Override
@DB
public String updateConfiguration(final long userId, final String name, final String category, final String value, final String scope, final Long resourceId) {
    final String validationMsg = validateConfigurationValue(name, value, scope);
    if (validationMsg != null) {
        s_logger.error("Invalid configuration option, name: " + name + ", value:" + value);
        throw new InvalidParameterValueException(validationMsg);
    }
    // global parameter updation
    if (scope != null && !scope.isEmpty() && !ConfigKey.Scope.Global.toString().equalsIgnoreCase(scope)) {
        switch(ConfigKey.Scope.valueOf(scope)) {
            case Zone:
                final DataCenterVO zone = _zoneDao.findById(resourceId);
                if (zone == null) {
                    throw new InvalidParameterValueException("unable to find zone by id " + resourceId);
                }
                _dcDetailsDao.addDetail(resourceId, name, value, true);
                break;
            case Cluster:
                final ClusterVO cluster = _clusterDao.findById(resourceId);
                if (cluster == null) {
                    throw new InvalidParameterValueException("unable to find cluster by id " + resourceId);
                }
                ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(resourceId, name);
                if (clusterDetailsVO == null) {
                    clusterDetailsVO = new ClusterDetailsVO(resourceId, name, value);
                    _clusterDetailsDao.persist(clusterDetailsVO);
                } else {
                    clusterDetailsVO.setValue(value);
                    _clusterDetailsDao.update(clusterDetailsVO.getId(), clusterDetailsVO);
                }
                break;
            case StoragePool:
                final StoragePoolVO pool = _storagePoolDao.findById(resourceId);
                if (pool == null) {
                    throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId);
                }
                if (name.equals(CapacityManager.StorageOverprovisioningFactor.key())) {
                    if (pool.getPoolType() != StoragePoolType.NetworkFilesystem) {
                        throw new InvalidParameterValueException("Unable to update  storage pool with id " + resourceId + ". Overprovision not supported for " + pool.getPoolType());
                    }
                }
                _storagePoolDetailsDao.addDetail(resourceId, name, value, true);
                break;
            case Account:
                final AccountVO account = _accountDao.findById(resourceId);
                if (account == null) {
                    throw new InvalidParameterValueException("unable to find account by id " + resourceId);
                }
                AccountDetailVO accountDetailVO = _accountDetailsDao.findDetail(resourceId, name);
                if (accountDetailVO == null) {
                    accountDetailVO = new AccountDetailVO(resourceId, name, value);
                    _accountDetailsDao.persist(accountDetailVO);
                } else {
                    accountDetailVO.setValue(value);
                    _accountDetailsDao.update(accountDetailVO.getId(), accountDetailVO);
                }
                break;
            default:
                throw new InvalidParameterValueException("Scope provided is invalid");
        }
        return value;
    }
    // Execute all updates in a single transaction
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    if (!_configDao.update(name, category, value)) {
        s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value);
        throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
    }
    PreparedStatement pstmt;
    if (Config.XenServerGuestNetwork.key().equalsIgnoreCase(name)) {
        final String sql = "update host_details set value=? where name=?";
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, value);
            pstmt.setString(2, "guest.network.device");
            pstmt.executeUpdate();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to update guest.network.device in host_details due to exception ", e);
        }
    } else if (Config.XenServerPrivateNetwork.key().equalsIgnoreCase(name)) {
        final String sql = "update host_details set value=? where name=?";
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, value);
            pstmt.setString(2, "private.network.device");
            pstmt.executeUpdate();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to update private.network.device in host_details due to exception ", e);
        }
    } else if (Config.XenServerPublicNetwork.key().equalsIgnoreCase(name)) {
        final String sql = "update host_details set value=? where name=?";
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, value);
            pstmt.setString(2, "public.network.device");
            pstmt.executeUpdate();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to update public.network.device in host_details due to exception ", e);
        }
    } else if (Config.XenServerStorageNetwork1.key().equalsIgnoreCase(name)) {
        final String sql = "update host_details set value=? where name=?";
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, value);
            pstmt.setString(2, "storage.network.device1");
            pstmt.executeUpdate();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to update storage.network.device1 in host_details due to exception ", e);
        }
    } else if (Config.XenServerStorageNetwork2.key().equals(name)) {
        final String sql = "update host_details set value=? where name=?";
        try {
            pstmt = txn.prepareAutoCloseStatement(sql);
            pstmt.setString(1, value);
            pstmt.setString(2, "storage.network.device2");
            pstmt.executeUpdate();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to update storage.network.device2 in host_details due to exception ", e);
        }
    } else if (Config.SecStorageSecureCopyCert.key().equalsIgnoreCase(name)) {
        // FIXME - Ideally there should be a listener model to listen to global config changes and be able to take action gracefully.
        // Expire the download urls
        final String sqlTemplate = "update template_store_ref set download_url_created=?";
        final String sqlVolume = "update volume_store_ref set download_url_created=?";
        try {
            // Change for templates
            pstmt = txn.prepareAutoCloseStatement(sqlTemplate);
            // Set the time before the epoch time.
            pstmt.setDate(1, new Date(-1l));
            pstmt.executeUpdate();
            // Change for volumes
            pstmt = txn.prepareAutoCloseStatement(sqlVolume);
            // Set the time before the epoch time.
            pstmt.setDate(1, new Date(-1l));
            pstmt.executeUpdate();
            // Cleanup the download urls
            _storageManager.cleanupDownloadUrls();
        } catch (final SQLException e) {
            throw new CloudRuntimeException("Failed to clean up download URLs in template_store_ref or volume_store_ref due to exception ", e);
        }
    }
    txn.commit();
    return _configDao.getValue(name);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) ClusterVO(com.cloud.dc.ClusterVO) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) AccountVO(com.cloud.user.AccountVO) Date(java.sql.Date) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) AccountDetailVO(com.cloud.user.AccountDetailVO) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) ClusterDetailsVO(com.cloud.dc.ClusterDetailsVO) DB(com.cloud.utils.db.DB)

Example 93 with ClusterVO

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

the class DeploymentPlanningManagerImpl method checkClustersforDestination.

// /refactoring planner methods
private DeployDestination checkClustersforDestination(final List<Long> clusterList, final VirtualMachineProfile vmProfile, final DeploymentPlan plan, final ExcludeList avoid, final Zone zone, final DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, final ExcludeList plannerAvoidOutput) {
    if (s_logger.isTraceEnabled()) {
        s_logger.trace("ClusterId List to consider: " + clusterList);
    }
    for (final Long clusterId : clusterList) {
        final ClusterVO clusterVO = _clusterDao.findById(clusterId);
        if (clusterVO.getHypervisorType() != vmProfile.getHypervisorType()) {
            s_logger.debug("Cluster: " + clusterId + " has HyperVisorType that does not match the VM, skipping this cluster");
            avoid.addCluster(clusterVO.getId());
            continue;
        }
        s_logger.debug("Checking resources in Cluster: " + clusterId + " under Pod: " + clusterVO.getPodId());
        // search for resources(hosts and storage) under this zone, pod,
        // cluster.
        final DataCenterDeployment potentialPlan = new DataCenterDeployment(plan.getDataCenterId(), clusterVO.getPodId(), clusterVO.getId(), null, plan.getPoolId(), null, plan.getReservationContext());
        // find suitable hosts under this cluster, need as many hosts as we
        // get.
        final List<Host> suitableHosts = findSuitableHosts(vmProfile, potentialPlan, avoid, HostAllocator.RETURN_UPTO_ALL);
        // pools for each volume of the VM
        if (suitableHosts != null && !suitableHosts.isEmpty()) {
            final Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
            final Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
            final List<Volume> readyAndReusedVolumes = result.second();
            // choose the potential host and pool for the VM
            if (!suitableVolumeStoragePools.isEmpty()) {
                final Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired, readyAndReusedVolumes);
                if (potentialResources != null) {
                    final Pod pod = _podDao.findById(clusterVO.getPodId());
                    final Host host = _hostDao.findById(potentialResources.first().getId());
                    final Map<Volume, StoragePool> storageVolMap = potentialResources.second();
                    // we don't have to prepare this volume.
                    for (final Volume vol : readyAndReusedVolumes) {
                        storageVolMap.remove(vol);
                    }
                    final DeployDestination dest = new DeployDestination(zone, pod, clusterVO, host, storageVolMap);
                    s_logger.debug("Returning Deployment Destination: " + dest);
                    return dest;
                }
            } else {
                s_logger.debug("No suitable storagePools found under this Cluster: " + clusterId);
            }
        } else {
            s_logger.debug("No suitable hosts found under this Cluster: " + clusterId);
        }
        if (canAvoidCluster(clusterVO, avoid, plannerAvoidOutput, vmProfile)) {
            avoid.addCluster(clusterVO.getId());
        }
    }
    s_logger.debug("Could not find suitable Deployment Destination for this VM under any clusters, returning. ");
    return null;
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) StoragePool(com.cloud.storage.StoragePool) Pod(com.cloud.dc.Pod) Host(com.cloud.host.Host) Volume(com.cloud.storage.Volume) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap)

Example 94 with ClusterVO

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

the class LibvirtServerDiscoverer method find.

@Override
public Map<? extends ServerResource, Map<String, String>> find(final long dcId, final Long podId, final Long clusterId, final URI uri, final String username, final String password, final List<String> hostTags) throws DiscoveryException {
    final ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null || cluster.getHypervisorType() != getHypervisorType()) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info("invalid cluster id or cluster is not for " + getHypervisorType() + " hypervisors");
        }
        return null;
    }
    final Map<KvmDummyResourceBase, Map<String, String>> resources = new HashMap<>();
    final Map<String, String> details = new HashMap<>();
    if (!uri.getScheme().equals("http")) {
        final String msg = "urlString is not http so we're not taking care of the discovery for this: " + uri;
        s_logger.debug(msg);
        return null;
    }
    com.trilead.ssh2.Connection sshConnection = null;
    String agentIp = null;
    try {
        final String hostname = uri.getHost();
        final InetAddress ia = InetAddress.getByName(hostname);
        agentIp = ia.getHostAddress();
        final String guid = UUID.nameUUIDFromBytes(agentIp.getBytes()).toString();
        final List<HostVO> existingHosts = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.Routing, dcId);
        if (existingHosts != null) {
            for (final HostVO existingHost : existingHosts) {
                if (existingHost.getGuid().toLowerCase().startsWith(guid.toLowerCase())) {
                    s_logger.debug("Skipping " + agentIp + " because " + guid + " is already in the database for resource " + existingHost.getGuid());
                    return null;
                }
            }
        }
        sshConnection = new com.trilead.ssh2.Connection(agentIp, SSH_PORT);
        try {
            sshConnection.connect(null, 60000, 60000);
        } catch (final IOException e) {
            s_logger.error("Cannot connect to KVM host at " + agentIp + ":" + SSH_PORT + "  due to: " + e.getMessage(), e);
            return null;
        }
        try {
            if (!sshConnection.authenticateWithPassword(username, password)) {
                s_logger.warn("Failed to authenticate to KVM host at " + agentIp + ":" + SSH_PORT);
                throw new DiscoveredWithErrorException("Authentication error");
            }
        } catch (final IOException e) {
            s_logger.error("Failed to authenticate to KVM host at  " + agentIp + ":" + SSH_PORT + "  due to: " + e.getMessage(), e);
            return null;
        }
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "lsmod|grep kvm", 3)) {
            s_logger.debug("It's not a KVM enabled machine");
            return null;
        }
        final List<PhysicalNetworkSetupInfo> netInfos = _networkMgr.getPhysicalNetworkInfo(dcId, getHypervisorType());
        String kvmPrivateNic = null;
        String kvmPublicNic = null;
        String kvmGuestNic = null;
        for (final PhysicalNetworkSetupInfo info : netInfos) {
            if (info.getPrivateNetworkName() != null) {
                kvmPrivateNic = info.getPrivateNetworkName();
            }
            if (info.getPublicNetworkName() != null) {
                kvmPublicNic = info.getPublicNetworkName();
            }
            if (info.getGuestNetworkName() != null) {
                kvmGuestNic = info.getGuestNetworkName();
            }
        }
        if (kvmPrivateNic == null && kvmPublicNic == null && kvmGuestNic == null) {
            kvmPrivateNic = _kvmPrivateNic;
            kvmPublicNic = _kvmPublicNic;
            kvmGuestNic = _kvmGuestNic;
        }
        if (kvmPublicNic == null) {
            kvmPublicNic = (kvmGuestNic != null) ? kvmGuestNic : kvmPrivateNic;
        }
        if (kvmPrivateNic == null) {
            kvmPrivateNic = (kvmPublicNic != null) ? kvmPublicNic : kvmGuestNic;
        }
        if (kvmGuestNic == null) {
            kvmGuestNic = (kvmPublicNic != null) ? kvmPublicNic : kvmPrivateNic;
        }
        String parameters = " -m " + _hostIp + " -z " + dcId + " -p " + podId + " -c " + clusterId + " -g " + guid + " -a";
        parameters += " --pubNic=" + kvmPublicNic;
        parameters += " --prvNic=" + kvmPrivateNic;
        parameters += " --guestNic=" + kvmGuestNic;
        parameters += " --hypervisor=" + cluster.getHypervisorType().toString().toLowerCase();
        String setupAgentCommand = "cosmic-setup-agent ";
        if (!username.equals("root")) {
            setupAgentCommand = "sudo cosmic-setup-agent ";
        }
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, setupAgentCommand + parameters, 3)) {
            s_logger.info("cosmic agent setup command failed: " + setupAgentCommand + parameters);
            return null;
        }
        final KvmDummyResourceBase kvmResource = new KvmDummyResourceBase();
        final Map<String, Object> params = new HashMap<>();
        params.put("router.aggregation.command.each.timeout", _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
        params.put("zone", Long.toString(dcId));
        params.put("pod", Long.toString(podId));
        params.put("cluster", Long.toString(clusterId));
        params.put("guid", guid);
        params.put("agentIp", agentIp);
        kvmResource.configure("kvm agent", params);
        resources.put(kvmResource, details);
        final HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guid);
        if (connectedHost == null) {
            return null;
        }
        details.put("guid", connectedHost.getGuid());
        // place a place holder guid derived from cluster ID
        if (cluster.getGuid() == null) {
            cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
            _clusterDao.update(clusterId, cluster);
        }
        // save user name and password
        _hostDao.loadDetails(connectedHost);
        final Map<String, String> hostDetails = connectedHost.getDetails();
        hostDetails.put("password", password);
        hostDetails.put("username", username);
        _hostDao.saveDetails(connectedHost);
        return resources;
    } catch (final ConfigurationException e) {
        s_logger.error("Failed to obtain configuration parameters for KVM host: " + e.getMessage(), e);
    } catch (final UnknownHostException e) {
        s_logger.error("Failed to discover IP of KVM host at " + agentIp + " due to: " + e.getMessage(), e);
    } finally {
        if (sshConnection != null) {
            sshConnection.close();
        }
    }
    return null;
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) DiscoveredWithErrorException(com.cloud.exception.DiscoveredWithErrorException) IOException(java.io.IOException) HostVO(com.cloud.host.HostVO) ConfigurationException(javax.naming.ConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map) InetAddress(java.net.InetAddress) PhysicalNetworkSetupInfo(com.cloud.network.PhysicalNetworkSetupInfo)

Example 95 with ClusterVO

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

the class VirtualMachineManagerImpl method checkIfPlanIsDeployable.

private void checkIfPlanIsDeployable(final VMInstanceVO vm, final Long rootVolClusterId, final Long clusterIdSpecified) throws ResourceUnavailableException {
    if (rootVolClusterId.longValue() != clusterIdSpecified.longValue()) {
        // cannot satisfy the plan passed in to the planner
        final ClusterVO volumeCluster = _clusterDao.findById(rootVolClusterId);
        final ClusterVO vmCluster = _clusterDao.findById(clusterIdSpecified);
        final String errorMsg;
        errorMsg = String.format("Root volume is ready in cluster '%s' while VM is to be started in cluster '%s'. Make sure these match. Unable to create a deployment for %s", volumeCluster.getName(), vmCluster.getName(), vm);
        s_logger.debug(errorMsg);
        throw new ResourceUnavailableException(errorMsg, Cluster.class, clusterIdSpecified);
    }
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

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