Package com.cloud.dc

Examples of com.cloud.dc.DataCenter


            ex.addProxyObject(id.toString(), "physicalNetworkId");
            throw ex;
        }

        // if zone is of Basic type, don't allow to add vnet range
        DataCenter zone = _dcDao.findById(network.getDataCenterId());
        if (zone == null) {
            InvalidParameterValueException ex = new InvalidParameterValueException("Zone with id=" + network.getDataCenterId() + " doesn't exist in the system");
            ex.addProxyObject(String.valueOf(network.getDataCenterId()), "dataCenterId");
            throw ex;
        }
        if (newVnetRange!= null) {
            if (zone.getNetworkType() == NetworkType.Basic
                    || (zone.getNetworkType() == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
                throw new InvalidParameterValueException("Can't add vnet range to the physical network in the zone that supports " + zone.getNetworkType() + " network, Security Group enabled: "
                        + zone.isSecurityGroupEnabled());
            }
        }

        if (tags != null && tags.size() > 1) {
            throw new InvalidParameterException("Unable to support more than one tag on network yet");
View Full Code Here


        if (zoneId == null) {
            return null;
        }

        DataCenter zone = _configService.getZone(zoneId);
        if (zone.getNetworkType() == NetworkType.Advanced) {
            List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
                    _accountService.getAccount(getEntityOwnerId()));
            if (networks.size() == 0) {
                String domain = _domainService.getDomain(getDomainId()).getName();
                throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain +
                        " doesn't have virtual networks in zone=" + zone.getName());
            }

            if (networks.size() < 1) {
                throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
            } else if (networks.size() > 1) {
View Full Code Here

                throw new InvalidParameterValueException("Unable to find network by network id specified");
            }

            NetworkOffering offering = _configService.getNetworkOffering(network.getNetworkOfferingId());

            DataCenter zone = _configService.getZone(network.getDataCenterId());
            if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
                // Since the basic zone network is owned by 'Root' domain, domain access checkers will fail for the
                // accounts in non-root domains while acquiring public IP. So add an exception for the 'Basic' zone
                // shared network with EIP/ELB service.
                return caller.getAccountId();
            }
View Full Code Here

                throw new InvalidParameterValueException("Either networkId or zoneId or publicIpId has to be specified");
            }
        }

        if (zoneId != null) {
            DataCenter zone = _configService.getZone(zoneId);
            if (zone.getNetworkType() == NetworkType.Advanced) {
                List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
                if (networks.size() == 0) {
                    String domain = _domainService.getDomain(getDomainId()).getName();
                    throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
                }

                if (networks.size() < 1) {
                    throw new InvalidParameterValueException("Account doesn't have any Isolated networks in the zone");
                } else if (networks.size() > 1) {
View Full Code Here

    HostDetailsDao _hostDetailDao;
    @Inject
    ConfigurationDao _configDao;

    private boolean canHandle(Network network, Service service) {
        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
        if ((zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == Network.GuestType.Isolated ||
                network.getGuestType() == Network.GuestType.Shared )) ||
                (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
            s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType());
            return false;
        }

        if (service == null) {
View Full Code Here

    }

    @Override
    public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
    InsufficientNetworkCapacityException {
        DataCenter zone = _configMgr.getZone(network.getDataCenterId());

        // don't have to implement network is Basic zone
        if (zone.getNetworkType() == NetworkType.Basic) {
            s_logger.debug("Not handling network implement in zone of type " + NetworkType.Basic);
            return false;
        }

        if (!canHandle(network, null)) {
View Full Code Here

        return true;
    }

    @Override
    public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
        DataCenter zone = _configMgr.getZone(network.getDataCenterId());

        // don't have to implement network is Basic zone
        if (zone.getNetworkType() == NetworkType.Basic) {
            s_logger.debug("Not handling network shutdown in zone of type " + NetworkType.Basic);
            return false;
        }

        if (!canHandle(network, null)) {
View Full Code Here

        if (getNewIp) {
            //we don't set reservationStrategy to Create because we need this method to be called again for the case when vm fails to deploy in Pod1, and we try to redeploy it in Pod2
            getIp(nic, dest.getPod(), vm, network);
        }
       
        DataCenter dc = _dcDao.findById(network.getDataCenterId());
        nic.setDns1(dc.getDns1());
        nic.setDns2(dc.getDns2());
    }
View Full Code Here

    }

    @DB
    protected void getIp(NicProfile nic, Pod pod, VirtualMachineProfile<? extends VirtualMachine> vm, Network network) throws InsufficientVirtualNetworkCapcityException,
            InsufficientAddressCapacityException, ConcurrentOperationException {
        DataCenter dc = _dcDao.findById(pod.getDataCenterId());
        if (nic.getIp4Address() == null) {
            Transaction txn = Transaction.currentTxn();
            txn.start();
           
            PublicIp ip = null;
            List<PodVlanMapVO> podRefs = _podVlanDao.listPodVlanMapsByPod(pod.getId());
            String podRangeGateway = null;
            if (!podRefs.isEmpty()) {
                podRangeGateway = _vlanDao.findById(podRefs.get(0).getVlanDbId()).getVlanGateway();
            }
            //Get ip address from the placeholder and don't allocate a new one
            if (vm.getType() == VirtualMachine.Type.DomainRouter) {
                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
                if (placeholderNic != null) {
                    IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), placeholderNic.getIp4Address());
                    ip = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
                    s_logger.debug("Nic got an ip address " + placeholderNic.getIp4Address() + " stored in placeholder nic for the network " + network + " and gateway " + podRangeGateway);
                }
            }
           
            if (ip == null) {
                ip = _networkMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), null, false);
            }
           
            nic.setIp4Address(ip.getAddress().toString());
            nic.setFormat(AddressFormat.Ip4);
            nic.setGateway(ip.getGateway());
            nic.setNetmask(ip.getNetmask());
            if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) {
                nic.setIsolationUri(URI.create("ec2://" + Vlan.UNTAGGED));
                nic.setBroadcastUri(URI.create("vlan://" + Vlan.UNTAGGED));
                nic.setBroadcastType(BroadcastDomainType.Native);
            }
            nic.setReservationId(String.valueOf(ip.getVlanTag()));
            nic.setMacAddress(ip.getMacAddress());
           
            //save the placeholder nic if the vm is the Virtual router
            if (vm.getType() == VirtualMachine.Type.DomainRouter) {
                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
                if (placeholderNic == null) {
                    s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address() + " for the network " + network);
                    _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), null, VirtualMachine.Type.DomainRouter);
                }
            }
            txn.commit();
        }
        nic.setDns1(dc.getDns1());
        nic.setDns2(dc.getDns2());
    }
View Full Code Here

        if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
            return super.implement(config, offering, dest, context);
        }

        DataCenter zone = dest.getDataCenter();
        NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), State.Allocated,
                config.getDataCenterId(), config.getPhysicalNetworkId());

        // Get a vlan tag
        int vlanTag;
        if (config.getBroadcastUri() == null) {
            String vnet = _dcDao.allocateVnet(zone.getId(), config.getPhysicalNetworkId(), config.getAccountId(),
                    context.getReservationId(), canUseSystemGuestVlan(config.getAccountId()));

            try {
                vlanTag = Integer.parseInt(vnet);
            } catch (NumberFormatException e) {
View Full Code Here

TOP

Related Classes of com.cloud.dc.DataCenter

Copyright © 2018 www.massapicom. 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.