Package com.cloud.dc

Examples of com.cloud.dc.Vlan


            }
            List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
            if (vlans == null) {
                throw new CloudRuntimeException("Cannot find related vlan attached to network " + networkId);
            }
            Vlan ipVlan = null;
            for (Vlan vlan : vlans) {
                if (NetUtils.isIp6InRange(ip6, vlan.getIp6Range())) {
                    ipVlan = vlan;
                    break;
                }
View Full Code Here


                String guestVlanTag = BroadcastDomainType.getValue(network.getBroadcastUri());
                String guestCidr = network.getCidr();
                ruleTO = new FirewallRuleTO(rule, guestVlanTag, rule.getTrafficType(), guestCidr, defaultEgressPolicy, rule.getType());
            } else {
                IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
                Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());

                ruleTO = new FirewallRuleTO(rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
            }
            rulesTO.add(ruleTO);
        }

        //Firewall rules configured for staticNAT/PF
View Full Code Here

        List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();

        for (StaticNat rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());

            StaticNatRuleTO ruleTO =
                new StaticNatRuleTO(0, vlan.getVlanTag(), sourceIp.getAddress().addr(), -1, -1, rule.getDestIpAddress(), -1, -1, "any", rule.isForRevoke(), false);
            staticNatRules.add(ruleTO);
        }

        sendStaticNatRules(staticNatRules, zone, externalFirewall.getId());
View Full Code Here

        List<PortForwardingRuleTO> pfRules = new ArrayList<PortForwardingRuleTO>();

        for (PortForwardingRule rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());

            PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
            pfRules.add(ruleTO);
        }

        sendPortForwardingRules(pfRules, zone, externalFirewall.getId());
        return true;
View Full Code Here

        if (vlans == null) {
            s_logger.debug("Cannot find related vlan attached to network " + networkId);
            return null;
        }
        String ip = null;
        Vlan ipVlan = null;
        if (requestedIp6 == null) {
            if (!_networkModel.isIP6AddressAvailableInNetwork(networkId)) {
                throw new InsufficientAddressCapacityException("There is no more address available in the network " + network.getName(), DataCenter.class,
                    network.getDataCenterId());
            }
            for (Vlan vlan : vlans) {
                if (!_networkModel.isIP6AddressAvailableInVlan(vlan.getId())) {
                    continue;
                }
                ip = NetUtils.getIp6FromRange(vlan.getIp6Range());
                int count = 0;
                while (_ipv6Dao.findByNetworkIdAndIp(networkId, ip) != null) {
                    ip = NetUtils.getNextIp6InRange(ip, vlan.getIp6Range());
                    count++;
                    // It's an arbitrate number to prevent the infinite loop
                    if (count > _ipv6RetryMax) {
                        ip = null;
                        break;
                    }
                }
                if (ip != null) {
                    ipVlan = vlan;
                }
            }
            if (ip == null) {
                throw new InsufficientAddressCapacityException("Cannot find a usable IP in the network " + network.getName() + " after " + _ipv6RetryMax +
                    "(network.ipv6.search.retry.max) times retry!", DataCenter.class, network.getDataCenterId());
            }
        } else {
            for (Vlan vlan : vlans) {
                if (NetUtils.isIp6InRange(requestedIp6, vlan.getIp6Range())) {
                    ipVlan = vlan;
                    break;
                }
            }
            if (ipVlan == null) {
                throw new CloudRuntimeException("Requested IPv6 is not in the predefined range!");
            }
            ip = requestedIp6;
            if (_ipv6Dao.findByNetworkIdAndIp(networkId, ip) != null) {
                throw new CloudRuntimeException("The requested IP is already taken!");
            }
        }
        DataCenterVO dc = _dcDao.findById(dcId);
        Long mac = dc.getMacAddress();
        Long nextMac = mac + 1;
        dc.setMacAddress(nextMac);
        _dcDao.update(dc.getId(), dc);

        String macAddress = NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(mac));
        UserIpv6AddressVO ipVO = new UserIpv6AddressVO(ip, dcId, macAddress, ipVlan.getId());
        ipVO.setPhysicalNetworkId(network.getPhysicalNetworkId());
        ipVO.setSourceNetworkId(networkId);
        ipVO.setState(UserIpv6Address.State.Allocated);
        ipVO.setDomainId(owner.getDomainId());
        ipVO.setAccountId(owner.getAccountId());
View Full Code Here

                          * */
                        NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
                        if (networkOffering.getElasticIp()) {
                            IpAddress ip = ApiDBUtils.findIpByAssociatedVmId(vm.getId());
                            if (ip != null) {
                                Vlan vlan = ApiDBUtils.findVlanById(ip.getVlanId());
                                vmResponse.setPublicIp(ip.getAddress().addr());
                                vmResponse.setPublicNetmask(vlan.getVlanNetmask());
                                vmResponse.setGateway(vlan.getVlanGateway());
                            }
                        } else {
                            vmResponse.setPublicIp(singleNicProfile.getIp4Address());
                            vmResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
                            vmResponse.setPublicNetmask(singleNicProfile.getNetmask());
View Full Code Here

        //FIXME - get ipv6 address from the placeholder if it's stored there
        if (network.getIp6Gateway() != null) {
            if (nic.getIp6Address() == null) {
                UserIpv6Address ip = _ipv6Mgr.assignDirectIp6Address(dc.getId(), vm.getOwner(), network.getId(), requestedIpv6);
                Vlan vlan = _vlanDao.findById(ip.getVlanId());
                nic.setIp6Address(ip.getAddress().toString());
                nic.setIp6Gateway(vlan.getIp6Gateway());
                nic.setIp6Cidr(vlan.getIp6Cidr());
                if (ipv4) {
                    nic.setFormat(AddressFormat.DualStack);
                } else {
                    nic.setIsolationUri(IsolationType.Vlan.toUri(vlan.getVlanTag()));
                    nic.setBroadcastType(BroadcastDomainType.Vlan);
                    nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlan.getVlanTag()));
                    nic.setFormat(AddressFormat.Ip6);
                    nic.setReservationId(String.valueOf(vlan.getVlanTag()));
                    nic.setMacAddress(ip.getMacAddress());
                }
            }
            nic.setIp6Dns1(dc.getIp6Dns1());
            nic.setIp6Dns2(dc.getIp6Dns2());
View Full Code Here

        List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
        List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();

        for (FirewallRule rule : rules) {
            IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
            Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());

            if (rule.getPurpose() == Purpose.StaticNat) {
                StaticNatRule staticNatRule = (StaticNatRule) rule;
                StaticNatRuleTO ruleTO = new StaticNatRuleTO(staticNatRule, vlan.getVlanTag(), sourceIp.getAddress().addr(), staticNatRule.getDestIpAddress());
                staticNatRules.add(ruleTO);
            } else if (rule.getPurpose() == Purpose.PortForwarding) {
                PortForwardingRuleTO ruleTO = new PortForwardingRuleTO((PortForwardingRule) rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
                portForwardingRules.add(ruleTO);
            }
        }

        // Apply static nat rules
View Full Code Here

            }
            List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(networkId);
            if (vlans == null) {
                throw new CloudRuntimeException("Cannot find related vlan attached to network " + networkId);
            }
            Vlan ipVlan = null;
            for (Vlan vlan : vlans) {
                if (NetUtils.isIp6InRange(ip6, vlan.getIp6Range())) {
                    ipVlan = vlan;
                    break;
                }
View Full Code Here

    }

    @Override
    public void execute() throws ResourceUnavailableException, ResourceAllocationException{
        try {
            Vlan result = _configService.createVlanAndPublicIpRange(this);
            if (result != null) {
                VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result);
                response.setResponseName(getCommandName());
                this.setResponseObject(response);
            }else {
View Full Code Here

TOP

Related Classes of com.cloud.dc.Vlan

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.