Examples of HostPodVO


Examples of com.cloud.dc.HostPodVO

        DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,
                "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();

        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "255.255.255.255", "", 8, "test");
        pod = podDao.persist(pod);
        podId = pod.getId();

        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(HypervisorType.XenServer.toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                    "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
            dc = dcDao.persist(dc);
            dcId = dc.getId();
            // create pod

            HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(),
                    this.getHostCidr(), 8, "test");
            pod = podDao.persist(pod);
            podId = pod.getId();
            // create xen cluster
            ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
            cluster.setHypervisorType(this.getHypervisor().toString());
            cluster.setClusterType(ClusterType.CloudManaged);
            cluster.setManagedState(ManagedState.Managed);
            cluster = clusterDao.persist(cluster);
            clusterId = cluster.getId();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

            boolean canUse = false;

            if (plan.getHostId() != null) {
                HostVO host = _hostDao.findById(plan.getHostId());
                ClusterVO clusterofHost = _clusterDao.findById(host.getClusterId());
                HostPodVO podOfHost = _podDao.findById(host.getPodId());
                DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId());
                if (resourceList != null && resourceList.size() != 0) {
                    for (DedicatedResourceVO resource : resourceList) {
                        if ((resource.getHostId() != null && resource.getHostId() == plan.getHostId())
                                || (resource.getClusterId() != null && resource.getClusterId() == clusterofHost.getId())
                                || (resource.getPodId() != null && resource.getPodId() == podOfHost.getId())
                                || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfHost
                                        .getId())) {
                            canUse = true;
                        }
                    }
                }
                if (!canUse) {
                    throw new CloudRuntimeException("Cannot use this host " + host.getName()
                            + " for explicit dedication");
                }
            } else if (plan.getClusterId() != null) {
                ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
                HostPodVO podOfCluster = _podDao.findById(cluster.getPodId());
                DataCenterVO zoneOfCluster = _dcDao.findById(cluster.getDataCenterId());
                List<HostVO> hostToUse = new ArrayList<HostVO>();
                // check whether this cluster or its pod is dedicated
                if (resourceList != null && resourceList.size() != 0) {
                    for (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;
                        }

                        // check for all dedicated host; if it belongs to this
                        // cluster
                        if (!canUse) {
                            if (resource.getHostId() != null) {
                                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
                    List<HostVO> hostList = _hostDao.findByClusterId(cluster.getId());
                    for (HostVO host : hostList) {
                        if (!hostToUse.contains(host)) {
                            avoid.addHost(host.getId());
                        }
                    }
                }

            } else if (plan.getPodId() != null) {
                HostPodVO pod = _podDao.findById(plan.getPodId());
                DataCenterVO zoneOfPod = _dcDao.findById(pod.getDataCenterId());
                List<ClusterVO> clustersToUse = new ArrayList<ClusterVO>();
                List<HostVO> hostsToUse = new ArrayList<HostVO>();
                // check whether this cluster or its pod is dedicated
                if (resourceList != null && resourceList.size() != 0) {
                    for (DedicatedResourceVO resource : resourceList) {
                        if ((resource.getPodId() != null && resource.getPodId() == pod.getId())
                                || (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfPod
                                        .getId())) {
                            canUse = true;
                        }

                        // check for all dedicated cluster/host; if it belongs
                        // to
                        // this pod
                        if (!canUse) {
                            if (resource.getClusterId() != null) {
                                ClusterVO dCluster = _clusterDao.findById(resource.getClusterId());
                                if (dCluster.getPodId() == pod.getId()) {
                                    clustersToUse.add(dCluster);
                                }
                            }
                            if (resource.getHostId() != null) {
                                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
                    List<ClusterVO> clusterList = _clusterDao.listByPodId(pod.getId());
                    for (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
                    List<HostVO> hostList = _hostDao.findByPodId(pod.getId());
                    for (HostVO host : hostList) {
                        if (!hostsToUse.contains(host)) {
                            avoid.addHost(host.getId());
                        }
                    }
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();
        // create pod

        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(),
                this.getHostCidr(), 8, "test");
        pod = podDao.persist(pod);
        podId = pod.getId();
        // create xen cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(HypervisorType.XenServer.toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();
        // create pod

        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "192.168.56.1", "192.168.56.0/24", 8,
                "test");
        pod = podDao.persist(pod);
        // create xen cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(HypervisorType.XenServer.toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

        DataCenterVO zone = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,  "10.0.0.1/24",
                null, null, NetworkType.Basic, null, null, true,  true, null, null);
        zoneId = 1L;

        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), zoneId, "192.168.56.1", "192.168.56.0/24", 8, "test");
        podId = 1L;

        AccountVO acct = new AccountVO(200L);
        acct.setType(Account.ACCOUNT_TYPE_ADMIN);
        acct.setAccountName("admin");
        acct.setDomainId(domainId);
        UserContext.registerContext(1, acct, null, true);

        when(_accountDao.findByIdIncludingRemoved(0L)).thenReturn(acct);

        dc = new VmwareDatacenterVO(guid, vmwareDcName, vCenterHost, user, password);
        vmwareDcs = new ArrayList<VmwareDatacenterVO>();
        vmwareDcs.add(dc);
        vmwareDcId = dc.getId();

        cluster = new ClusterVO(zone.getId(), pod.getId(), "vmwarecluster");
        cluster.setHypervisorType(HypervisorType.VMware.toString());
        cluster.setClusterType(ClusterType.ExternalManaged);
        cluster.setManagedState(ManagedState.Managed);
        clusterId = 1L;
        clusterList = new ArrayList<ClusterVO>();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

            accountId  = owner.getId();
        }
        List<Long> childDomainIds = getDomainChildIds(domainId);
        childDomainIds.add(domainId);
        checkAccountAndDomain(accountId, domainId);
        HostPodVO pod = _podDao.findById(podId);
        List<HostVO> hosts = null;
        if (pod == null) {
            throw new InvalidParameterValueException("Unable to find pod by id " + podId);
        } else {
            DedicatedResourceVO dedicatedPod = _dedicatedDao.findByPodId(podId);
            DedicatedResourceVO dedicatedZoneOfPod = _dedicatedDao.findByZoneId(pod.getDataCenterId());
            //check if pod is dedicated
            if(dedicatedPod != null ) {
                s_logger.error("Pod " + pod.getName() + " is already dedicated");
                throw new CloudRuntimeException("Pod " + pod.getName() + " is already dedicated");
            }

            if (dedicatedZoneOfPod != null) {
                boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfPod.getDomainId()).contains(domainId);
                //can dedicate a pod to an account/domain if zone is dedicated to parent-domain
                if (dedicatedZoneOfPod.getAccountId() != null || (accountId == null && !domainIdInChildreanList)
                        || (accountId != null && !(dedicatedZoneOfPod.getDomainId() == domainId || domainIdInChildreanList))) {
                    DataCenterVO zone = _zoneDao.findById(pod.getDataCenterId());
                    s_logger.error("Cannot dedicate Pod. Its zone is already dedicated");
                    throw new CloudRuntimeException("Pod's Zone " + zone.getName() + " is already dedicated");
                }
            }

            //check if any resource under this pod is dedicated to different account or sub-domain
            List<ClusterVO> clusters = _clusterDao.listByPodId(pod.getId());
            List<DedicatedResourceVO> clustersToRelease = new ArrayList<DedicatedResourceVO>();
            List<DedicatedResourceVO> hostsToRelease = new ArrayList<DedicatedResourceVO>();
            for (ClusterVO cluster : clusters) {
                DedicatedResourceVO dCluster = _dedicatedDao.findByClusterId(cluster.getId());
                if (dCluster != null) {
                    if(!(childDomainIds.contains(dCluster.getDomainId()))) {
                        throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                    }
                    /*if all dedicated resources belongs to same account and domain then we should release dedication
                    and make new entry for this Pod*/
                    if (accountId != null) {
                        if (dCluster.getAccountId() == accountId) {
                            clustersToRelease.add(dCluster);
                        } else {
                            s_logger.error("Cluster " + cluster.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                            throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                        }
                    } else {
                        if (dCluster.getAccountId() == null && dCluster.getDomainId() == domainId) {
                            clustersToRelease.add(dCluster);
                        }
                    }
                }
            }

            for (DedicatedResourceVO dr : clustersToRelease) {
                releaseDedicatedResource(null, null, dr.getClusterId(), null);
            }

            hosts = _hostDao.findByPodId(pod.getId());
            for (HostVO host : hosts) {
                DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
                if (dHost != null) {
                    if(!(getDomainChildIds(domainId).contains(dHost.getDomainId()))) {
                        throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                    }
                    if (accountId != null) {
                        if (dHost.getAccountId() == accountId) {
                            hostsToRelease.add(dHost);
                        } else {
                            s_logger.error("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                            throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
                        }
                    } else {
                        if (dHost.getAccountId() == null && dHost.getDomainId() == domainId) {
                            hostsToRelease.add(dHost);
                        }
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                boolean domainIdInChildreanList = getDomainChildIds(dedicatedPodOfCluster.getDomainId()).contains(domainId);
                //can dedicate a cluster to an account/domain if pod is dedicated to parent-domain
                if (dedicatedPodOfCluster.getAccountId() != null || (accountId == null && !domainIdInChildreanList)
                        || (accountId != null && !(dedicatedPodOfCluster.getDomainId() == domainId || domainIdInChildreanList))) {
                    s_logger.error("Cannot dedicate Cluster. Its Pod is already dedicated");
                    HostPodVO pod = _podDao.findById(cluster.getPodId());
                    throw new CloudRuntimeException("Cluster's Pod " +  pod.getName() + " is already dedicated");
                }
            }

            if (dedicatedZoneOfCluster != null) {
                boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfCluster.getDomainId()).contains(domainId);
View Full Code Here

Examples of com.cloud.dc.HostPodVO

            if (dedicatedPodOfHost != null){
                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() == domainId || domainIdInChildreanList))) {
                    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) {
                boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfHost.getDomainId()).contains(domainId);
View Full Code Here

Examples of com.cloud.dc.HostPodVO

    }

    @Override
    public DedicatePodResponse createDedicatePodResponse(DedicatedResources resource) {
        DedicatePodResponse dedicatePodResponse = new DedicatePodResponse();
        HostPodVO pod = _podDao.findById(resource.getPodId());
        DomainVO domain = _domainDao.findById(resource.getDomainId());
        AccountVO account = _accountDao.findById(resource.getAccountId());
        AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
        dedicatePodResponse.setId(resource.getUuid());
        dedicatePodResponse.setPodId(pod.getUuid());
        dedicatePodResponse.setPodName(pod.getName());
        dedicatePodResponse.setDomainId(domain.getUuid());
        dedicatePodResponse.setAffinityGroupId(group.getUuid());
        if (account != null) {
            dedicatePodResponse.setAccountId(account.getUuid());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.