Search in sources :

Example 6 with Pod

use of com.cloud.dc.Pod in project cloudstack by apache.

the class BaremetalPxeElement method canHandle.

private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) {
    Pod pod = dest.getPod();
    if (pod != null && trafficType == TrafficType.Guest) {
        QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class);
        sc.and(sc.entity().getPodId(), Op.EQ, pod.getId());
        return sc.find() != null;
    }
    return false;
}
Also used : Pod(com.cloud.dc.Pod) BaremetalPxeVO(com.cloud.baremetal.database.BaremetalPxeVO)

Example 7 with Pod

use of com.cloud.dc.Pod in project cloudstack by apache.

the class IpAddressManagerImpl method fetchNewPublicIp.

@DB
public PublicIp fetchNewPublicIp(final long dcId, final Long podId, final List<Long> vlanDbIds, final Account owner, final VlanType vlanUse, final Long guestNetworkId, final boolean sourceNat, final boolean assign, final String requestedIp, final boolean isSystem, final Long vpcId, final Boolean displayIp) throws InsufficientAddressCapacityException {
    IPAddressVO addr = Transaction.execute(new TransactionCallbackWithException<IPAddressVO, InsufficientAddressCapacityException>() {

        @Override
        public IPAddressVO doInTransaction(TransactionStatus status) throws InsufficientAddressCapacityException {
            StringBuilder errorMessage = new StringBuilder("Unable to get ip adress in ");
            boolean fetchFromDedicatedRange = false;
            List<Long> dedicatedVlanDbIds = new ArrayList<Long>();
            List<Long> nonDedicatedVlanDbIds = new ArrayList<Long>();
            DataCenter zone = _entityMgr.findById(DataCenter.class, dcId);
            SearchCriteria<IPAddressVO> sc = null;
            if (podId != null) {
                sc = AssignIpAddressFromPodVlanSearch.create();
                sc.setJoinParameters("podVlanMapSB", "podId", podId);
                errorMessage.append(" pod id=" + podId);
            } else {
                sc = AssignIpAddressSearch.create();
                errorMessage.append(" zone id=" + dcId);
            }
            // If owner has dedicated Public IP ranges, fetch IP from the dedicated range
            // Otherwise fetch IP from the system pool
            Network network = _networksDao.findById(guestNetworkId);
            //Checking if network is null in the case of system VM's. At the time of allocation of IP address to systemVm, no network is present.
            if (network == null || !(network.getGuestType() == GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced)) {
                List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByAccount(owner.getId());
                for (AccountVlanMapVO map : maps) {
                    if (vlanDbIds == null || vlanDbIds.contains(map.getVlanDbId()))
                        dedicatedVlanDbIds.add(map.getVlanDbId());
                }
            }
            List<DomainVlanMapVO> domainMaps = _domainVlanMapDao.listDomainVlanMapsByDomain(owner.getDomainId());
            for (DomainVlanMapVO map : domainMaps) {
                if (vlanDbIds == null || vlanDbIds.contains(map.getVlanDbId()))
                    dedicatedVlanDbIds.add(map.getVlanDbId());
            }
            List<VlanVO> nonDedicatedVlans = _vlanDao.listZoneWideNonDedicatedVlans(dcId);
            for (VlanVO nonDedicatedVlan : nonDedicatedVlans) {
                if (vlanDbIds == null || vlanDbIds.contains(nonDedicatedVlan.getId()))
                    nonDedicatedVlanDbIds.add(nonDedicatedVlan.getId());
            }
            if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) {
                fetchFromDedicatedRange = true;
                sc.setParameters("vlanId", dedicatedVlanDbIds.toArray());
                errorMessage.append(", vlanId id=" + Arrays.toString(dedicatedVlanDbIds.toArray()));
            } else if (nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
                sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
                errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
            } else {
                if (podId != null) {
                    InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", Pod.class, podId);
                    ex.addProxyObject(ApiDBUtils.findPodById(podId).getUuid());
                    throw ex;
                }
                s_logger.warn(errorMessage.toString());
                InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId);
                ex.addProxyObject(ApiDBUtils.findZoneById(dcId).getUuid());
                throw ex;
            }
            sc.setParameters("dc", dcId);
            // for direct network take ip addresses only from the vlans belonging to the network
            if (vlanUse == VlanType.DirectAttached) {
                sc.setJoinParameters("vlan", "networkId", guestNetworkId);
                errorMessage.append(", network id=" + guestNetworkId);
            }
            sc.setJoinParameters("vlan", "type", vlanUse);
            if (requestedIp != null) {
                sc.addAnd("address", SearchCriteria.Op.EQ, requestedIp);
                errorMessage.append(": requested ip " + requestedIp + " is not available");
            }
            Filter filter = new Filter(IPAddressVO.class, "vlanId", true, 0l, 1l);
            List<IPAddressVO> addrs = _ipAddressDao.lockRows(sc, filter, true);
            // If all the dedicated IPs of the owner are in use fetch an IP from the system pool
            if (addrs.size() == 0 && fetchFromDedicatedRange) {
                // Verify if account is allowed to acquire IPs from the system
                boolean useSystemIps = UseSystemPublicIps.valueIn(owner.getId());
                if (useSystemIps && nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
                    fetchFromDedicatedRange = false;
                    sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
                    errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
                    addrs = _ipAddressDao.lockRows(sc, filter, true);
                }
            }
            if (addrs.size() == 0) {
                if (podId != null) {
                    InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", Pod.class, podId);
                    // for now, we hardcode the table names, but we should ideally do a lookup for the tablename from the VO object.
                    ex.addProxyObject(ApiDBUtils.findPodById(podId).getUuid());
                    throw ex;
                }
                s_logger.warn(errorMessage.toString());
                InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId);
                ex.addProxyObject(ApiDBUtils.findZoneById(dcId).getUuid());
                throw ex;
            }
            assert (addrs.size() == 1) : "Return size is incorrect: " + addrs.size();
            if (!fetchFromDedicatedRange && VlanType.VirtualNetwork.equals(vlanUse)) {
                // Check that the maximum number of public IPs for the given accountId will not be exceeded
                try {
                    _resourceLimitMgr.checkResourceLimit(owner, ResourceType.public_ip);
                } catch (ResourceAllocationException ex) {
                    s_logger.warn("Failed to allocate resource of type " + ex.getResourceType() + " for account " + owner);
                    throw new AccountLimitException("Maximum number of public IP addresses for account: " + owner.getAccountName() + " has been exceeded.");
                }
            }
            IPAddressVO addr = addrs.get(0);
            addr.setSourceNat(sourceNat);
            addr.setAllocatedTime(new Date());
            addr.setAllocatedInDomainId(owner.getDomainId());
            addr.setAllocatedToAccountId(owner.getId());
            addr.setSystem(isSystem);
            if (displayIp != null) {
                addr.setDisplay(displayIp);
            }
            if (assign) {
                markPublicIpAsAllocated(addr);
            } else {
                addr.setState(IpAddress.State.Allocating);
            }
            addr.setState(assign ? IpAddress.State.Allocated : IpAddress.State.Allocating);
            if (vlanUse != VlanType.DirectAttached) {
                addr.setAssociatedWithNetworkId(guestNetworkId);
                addr.setVpcId(vpcId);
            }
            _ipAddressDao.update(addr.getId(), addr);
            return addr;
        }
    });
    if (vlanUse == VlanType.VirtualNetwork) {
        _firewallMgr.addSystemFirewallRules(addr, owner);
    }
    return PublicIp.createFromAddrAndVlan(addr, _vlanDao.findById(addr.getVlanId()));
}
Also used : Pod(com.cloud.dc.Pod) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) AccountVlanMapVO(com.cloud.dc.AccountVlanMapVO) TransactionStatus(com.cloud.utils.db.TransactionStatus) SearchCriteria(com.cloud.utils.db.SearchCriteria) DomainVlanMapVO(com.cloud.dc.DomainVlanMapVO) Date(java.util.Date) DataCenter(com.cloud.dc.DataCenter) Filter(com.cloud.utils.db.Filter) IPAddressVO(com.cloud.network.dao.IPAddressVO) ArrayList(java.util.ArrayList) List(java.util.List) VlanVO(com.cloud.dc.VlanVO) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) AccountLimitException(com.cloud.exception.AccountLimitException) DB(com.cloud.utils.db.DB)

Example 8 with Pod

use of com.cloud.dc.Pod in project cloudstack by apache.

the class ConfigurationManagerImpl method createVlanAndPublicIpRange.

@Override
@DB
public Vlan createVlanAndPublicIpRange(final long zoneId, final long networkId, final long physicalNetworkId, final boolean forVirtualNetwork, final Long podId, final String startIP, final String endIP, final String vlanGateway, final String vlanNetmask, String vlanId, Domain domain, final Account vlanOwner, final String startIPv6, final String endIPv6, final String vlanIp6Gateway, final String vlanIp6Cidr) {
    final Network network = _networkModel.getNetwork(networkId);
    boolean ipv4 = false, ipv6 = false;
    if (startIP != null) {
        ipv4 = true;
    }
    if (startIPv6 != null) {
        ipv6 = true;
    }
    if (!ipv4 && !ipv6) {
        throw new InvalidParameterValueException("Please specify IPv4 or IPv6 address.");
    }
    // Validate the zone
    final DataCenterVO zone = _zoneDao.findById(zoneId);
    if (zone == null) {
        throw new InvalidParameterValueException("Please specify a valid zone.");
    }
    // ACL check
    checkZoneAccess(CallContext.current().getCallingAccount(), zone);
    // Validate the physical network
    if (_physicalNetworkDao.findById(physicalNetworkId) == null) {
        throw new InvalidParameterValueException("Please specify a valid physical network id");
    }
    // Validate the pod
    if (podId != null) {
        final Pod pod = _podDao.findById(podId);
        if (pod == null) {
            throw new InvalidParameterValueException("Please specify a valid pod.");
        }
        if (pod.getDataCenterId() != zoneId) {
            throw new InvalidParameterValueException("Pod id=" + podId + " doesn't belong to zone id=" + zoneId);
        }
        // pod vlans can be created in basic zone only
        if (zone.getNetworkType() != NetworkType.Basic || network.getTrafficType() != TrafficType.Guest) {
            throw new InvalidParameterValueException("Pod id can be specified only for the networks of type " + TrafficType.Guest + " in zone of type " + NetworkType.Basic);
        }
    }
    // 2) if vlan is missing, default it to the guest network's vlan
    if (network.getTrafficType() == TrafficType.Guest) {
        String networkVlanId = null;
        boolean connectivityWithoutVlan = false;
        if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Connectivity)) {
            Map<Capability, String> connectivityCapabilities = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.Connectivity);
            connectivityWithoutVlan = MapUtils.isNotEmpty(connectivityCapabilities) && connectivityCapabilities.containsKey(Capability.NoVlan);
        }
        final URI uri = network.getBroadcastUri();
        if (connectivityWithoutVlan) {
            networkVlanId = network.getBroadcastDomainType().toUri(network.getUuid()).toString();
        } else if (uri != null) {
            // Do not search for the VLAN tag when the network doesn't support VLAN
            if (uri.toString().startsWith("vlan")) {
                final String[] vlan = uri.toString().split("vlan:\\/\\/");
                networkVlanId = vlan[1];
                // For pvlan
                networkVlanId = networkVlanId.split("-")[0];
            }
        }
        if (vlanId != null && !connectivityWithoutVlan) {
            // network's vlanId
            if (networkVlanId != null && !NetUtils.isSameIsolationId(networkVlanId, vlanId)) {
                throw new InvalidParameterValueException("Vlan doesn't match vlan of the network");
            }
        } else {
            vlanId = networkVlanId;
        }
    } else if (network.getTrafficType() == TrafficType.Public && vlanId == null) {
        throw new InvalidParameterValueException("Unable to determine vlan id or untagged vlan for public network");
    }
    if (vlanId == null) {
        vlanId = Vlan.UNTAGGED;
    }
    final VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
    if ((domain != null || vlanOwner != null) && zone.getNetworkType() != NetworkType.Advanced) {
        throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced);
    }
    if (ipv4) {
        // Make sure the gateway is valid
        if (!NetUtils.isValidIp(vlanGateway)) {
            throw new InvalidParameterValueException("Please specify a valid gateway");
        }
        // Make sure the netmask is valid
        if (!NetUtils.isValidNetmask(vlanNetmask)) {
            throw new InvalidParameterValueException("Please specify a valid netmask");
        }
    }
    if (ipv6) {
        if (!NetUtils.isValidIpv6(vlanIp6Gateway)) {
            throw new InvalidParameterValueException("Please specify a valid IPv6 gateway");
        }
        if (!NetUtils.isValidIp6Cidr(vlanIp6Cidr)) {
            throw new InvalidParameterValueException("Please specify a valid IPv6 CIDR");
        }
    }
    if (ipv4) {
        final String newCidr = NetUtils.getCidrFromGatewayAndNetmask(vlanGateway, vlanNetmask);
        //Make sure start and end ips are with in the range of cidr calculated for this gateway and netmask {
        if (!NetUtils.isIpWithtInCidrRange(vlanGateway, newCidr) || !NetUtils.isIpWithtInCidrRange(startIP, newCidr) || !NetUtils.isIpWithtInCidrRange(endIP, newCidr)) {
            throw new InvalidParameterValueException("Please specify a valid IP range or valid netmask or valid gateway");
        }
        // Check if the new VLAN's subnet conflicts with the guest network
        // in
        // the specified zone (guestCidr is null for basic zone)
        // when adding shared network with same cidr of zone guest cidr,
        // if the specified vlan is not present in zone, physical network, allow to create the network as the isolation is based on VLAN.
        final String guestNetworkCidr = zone.getGuestNetworkCidr();
        if (guestNetworkCidr != null && NetUtils.isNetworksOverlap(newCidr, guestNetworkCidr) && _zoneDao.findVnet(zoneId, physicalNetworkId, vlanId).isEmpty() != true) {
            throw new InvalidParameterValueException("The new IP range you have specified has  overlapped with the guest network in zone: " + zone.getName() + "along with existing Vlan also. Please specify a different gateway/netmask");
        }
        // Check if there are any errors with the IP range
        checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
        checkConflictsWithPortableIpRange(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
        // Throw an exception if this subnet overlaps with subnet on other VLAN,
        // if this is ip range extension, gateway, network mask should be same and ip range should not overlap
        final List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
        for (final VlanVO vlan : vlans) {
            final String otherVlanGateway = vlan.getVlanGateway();
            final String otherVlanNetmask = vlan.getVlanNetmask();
            // Continue if it's not IPv4
            if (otherVlanGateway == null || otherVlanNetmask == null) {
                continue;
            }
            if (vlan.getNetworkId() == null) {
                continue;
            }
            final String otherCidr = NetUtils.getCidrFromGatewayAndNetmask(otherVlanGateway, otherVlanNetmask);
            if (!NetUtils.isNetworksOverlap(newCidr, otherCidr)) {
                continue;
            }
            // from here, subnet overlaps
            if (!vlanId.equals(vlan.getVlanTag())) {
                boolean overlapped = false;
                if (network.getTrafficType() == TrafficType.Public) {
                    overlapped = true;
                } else {
                    final Long nwId = vlan.getNetworkId();
                    if (nwId != null) {
                        final Network nw = _networkModel.getNetwork(nwId);
                        if (nw != null && nw.getTrafficType() == TrafficType.Public) {
                            overlapped = true;
                        }
                    }
                }
                if (overlapped) {
                    throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName() + " has overlapped with the subnet. Please specify a different gateway/netmask.");
                }
            } else {
                final String[] otherVlanIpRange = vlan.getIpRange().split("\\-");
                final String otherVlanStartIP = otherVlanIpRange[0];
                String otherVlanEndIP = null;
                if (otherVlanIpRange.length > 1) {
                    otherVlanEndIP = otherVlanIpRange[1];
                }
                // extend IP range
                if (!vlanGateway.equals(otherVlanGateway) || !vlanNetmask.equals(vlan.getVlanNetmask())) {
                    throw new InvalidParameterValueException("The IP range has already been added with gateway " + otherVlanGateway + " ,and netmask " + otherVlanNetmask + ", Please specify the gateway/netmask if you want to extend ip range");
                }
                if (!NetUtils.is31PrefixCidr(newCidr)) {
                    if (NetUtils.ipRangesOverlap(startIP, endIP, otherVlanStartIP, otherVlanEndIP)) {
                        throw new InvalidParameterValueException("The IP range already has IPs that overlap with the new range." + " Please specify a different start IP/end IP.");
                    }
                }
            }
        }
    }
    String ipv6Range = null;
    if (ipv6) {
        ipv6Range = startIPv6;
        if (endIPv6 != null) {
            ipv6Range += "-" + endIPv6;
        }
        final List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
        for (final VlanVO vlan : vlans) {
            if (vlan.getIp6Gateway() == null) {
                continue;
            }
            if (NetUtils.isSameIsolationId(vlanId, vlan.getVlanTag())) {
                if (NetUtils.isIp6RangeOverlap(ipv6Range, vlan.getIp6Range())) {
                    throw new InvalidParameterValueException("The IPv6 range with tag: " + vlan.getVlanTag() + " already has IPs that overlap with the new range. Please specify a different start IP/end IP.");
                }
                if (!vlanIp6Gateway.equals(vlan.getIp6Gateway())) {
                    throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " has already been added with gateway " + vlan.getIp6Gateway() + ". Please specify a different tag.");
                }
            }
        }
    }
    // Check if the vlan is being used
    if (_zoneDao.findVnet(zoneId, physicalNetworkId, vlanId).size() > 0) {
        throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for dynamic vlan allocation for the guest network in zone " + zone.getName());
    }
    String ipRange = null;
    if (ipv4) {
        ipRange = startIP;
        if (endIP != null) {
            ipRange += "-" + endIP;
        }
    }
    // Everything was fine, so persist the VLAN
    final VlanVO vlan = commitVlanAndIpRange(zoneId, networkId, physicalNetworkId, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId, domain, vlanOwner, vlanIp6Gateway, vlanIp6Cidr, ipv4, zone, vlanType, ipv6Range, ipRange);
    return vlan;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Pod(com.cloud.dc.Pod) Capability(com.cloud.network.Network.Capability) URI(java.net.URI) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) VlanVO(com.cloud.dc.VlanVO) VlanType(com.cloud.dc.Vlan.VlanType) DB(com.cloud.utils.db.DB)

Example 9 with Pod

use of com.cloud.dc.Pod in project cloudstack by apache.

the class DeploymentPlanningManagerImpl method checkClustersforDestination.

// /refactoring planner methods
private DeployDestination checkClustersforDestination(List<Long> clusterList, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, DataCenter dc, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, ExcludeList plannerAvoidOutput) {
    if (s_logger.isTraceEnabled()) {
        s_logger.trace("ClusterId List to consider: " + clusterList);
    }
    for (Long clusterId : clusterList) {
        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.
        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.
        List<Host> suitableHosts = findSuitableHosts(vmProfile, potentialPlan, avoid, HostAllocator.RETURN_UPTO_ALL);
        // pools for each volume of the VM
        if (suitableHosts != null && !suitableHosts.isEmpty()) {
            if (vmProfile.getHypervisorType() == HypervisorType.BareMetal) {
                Pod pod = _podDao.findById(clusterVO.getPodId());
                DeployDestination dest = new DeployDestination(dc, pod, clusterVO, suitableHosts.get(0));
                return dest;
            }
            Pair<Map<Volume, List<StoragePool>>, List<Volume>> result = findSuitablePoolsForVolumes(vmProfile, potentialPlan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL);
            Map<Volume, List<StoragePool>> suitableVolumeStoragePools = result.first();
            List<Volume> readyAndReusedVolumes = result.second();
            // choose the potential host and pool for the VM
            if (!suitableVolumeStoragePools.isEmpty()) {
                Pair<Host, Map<Volume, StoragePool>> potentialResources = findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired, readyAndReusedVolumes);
                if (potentialResources != null) {
                    Pod pod = _podDao.findById(clusterVO.getPodId());
                    Host host = _hostDao.findById(potentialResources.first().getId());
                    Map<Volume, StoragePool> storageVolMap = potentialResources.second();
                    // we don't have to prepare this volume.
                    for (Volume vol : readyAndReusedVolumes) {
                        storageVolMap.remove(vol);
                    }
                    DeployDestination dest = new DeployDestination(dc, 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 10 with Pod

use of com.cloud.dc.Pod in project cloudstack by apache.

the class VmWorkMigrate method getDeployDestination.

public DeployDestination getDeployDestination() {
    DataCenter zone = zoneId != null ? s_entityMgr.findById(DataCenter.class, zoneId) : null;
    Pod pod = podId != null ? s_entityMgr.findById(Pod.class, podId) : null;
    Cluster cluster = clusterId != null ? s_entityMgr.findById(Cluster.class, clusterId) : null;
    Host host = hostId != null ? s_entityMgr.findById(Host.class, hostId) : null;
    Map<Volume, StoragePool> vols = null;
    if (storage != null) {
        vols = new HashMap<Volume, StoragePool>(storage.size());
        for (Map.Entry<String, String> entry : storage.entrySet()) {
            vols.put(s_entityMgr.findByUuid(Volume.class, entry.getKey()), s_entityMgr.findByUuid(StoragePool.class, entry.getValue()));
        }
    }
    DeployDestination dest = new DeployDestination(zone, pod, cluster, host, vols);
    return dest;
}
Also used : DataCenter(com.cloud.dc.DataCenter) StoragePool(com.cloud.storage.StoragePool) Pod(com.cloud.dc.Pod) Volume(com.cloud.storage.Volume) DeployDestination(com.cloud.deploy.DeployDestination) Cluster(com.cloud.org.Cluster) Host(com.cloud.host.Host) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Pod (com.cloud.dc.Pod)23 DataCenter (com.cloud.dc.DataCenter)9 ArrayList (java.util.ArrayList)6 Host (com.cloud.host.Host)5 Cluster (com.cloud.org.Cluster)5 StoragePool (com.cloud.storage.StoragePool)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 DeployDestination (com.cloud.deploy.DeployDestination)4 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 Volume (com.cloud.storage.Volume)4 DB (com.cloud.utils.db.DB)4 List (java.util.List)4 PodResponse (com.cloud.api.response.PodResponse)3 DiskOffering (com.cloud.offering.DiskOffering)3 ServiceOffering (com.cloud.offering.ServiceOffering)3 HashMap (java.util.HashMap)3 ServerApiException (com.cloud.api.ServerApiException)2 ClusterDetailsVO (com.cloud.dc.ClusterDetailsVO)2 ClusterVO (com.cloud.dc.ClusterVO)2 VlanVO (com.cloud.dc.VlanVO)2