Package com.cloud.network.vpc

Examples of com.cloud.network.vpc.PrivateIpVO


   
   
    protected void getIp(NicProfile nic, DataCenter dc, Network network)
            throws InsufficientVirtualNetworkCapcityException,InsufficientAddressCapacityException {
        if (nic.getIp4Address() == null) {
            PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getId(), null);
            String vlanTag = network.getBroadcastUri().getHost();
            String netmask = NetUtils.getCidrNetmask(network.getCidr());
            PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask,
                    NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));

            nic.setIp4Address(ip.getIpAddress());
            nic.setGateway(ip.getGateway());
            nic.setNetmask(ip.getNetmask());
            nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
View Full Code Here


            sc.setParameters("ipAddress", requestedIp);
        }
       
        Transaction txn = Transaction.currentTxn();
        txn.start();
        PrivateIpVO  vo = lockOneRandomRow(sc, true);
        if (vo == null) {
            txn.rollback();
            return null;
        }
        vo.setTakenAt(new Date());
        update(vo.getId(), vo);
        txn.commit();
        return vo;
    }
View Full Code Here

        }
        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
        sc.setParameters("ip", ipAddress);
        sc.setParameters("networkId", networkId);

        PrivateIpVO vo = createForUpdate();
       
        vo.setTakenAt(null);
        update(vo, sc);
    }
View Full Code Here

        } else {
            s_logger.debug("Private network already exists: " + privateNetwork);
        }
       
        //add entry to private_ip_address table
        PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNetwork.getId(), startIp);
        if (privateIp != null) {
            throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" +
                    " in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
        }
       
        Long mac = dc.getMacAddress();
        Long nextMac = mac + 1;
        dc.setMacAddress(nextMac);

        privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId);
        _privateIpDao.persist(privateIp);
       
        _dcDao.update(dc.getId(), dc);
       
        txn.commit();
View Full Code Here

                    SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, true, nicProfile);
                    cmds.addCommand(setupCmd);
                } else {

                    //set private network
                    PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(guestNic.getNetworkId(), guestNic.getIp4Address());
                    Network network = _networkDao.findById(guestNic.getNetworkId());
                    String vlanTag = network.getBroadcastUri().getHost();
                    String netmask = NetUtils.getCidrNetmask(network.getCidr());
                    PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, guestNic.getMacAddress());
                   
View Full Code Here

     */
    protected boolean setupVpcPrivateNetwork(VirtualRouter router, boolean add, NicProfile privateNic)
            throws ResourceUnavailableException {
       
        if (router.getState() == State.Running) {
            PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(), privateNic.getIp4Address());
            Network network = _networkDao.findById(privateNic.getNetworkId());
            String vlanTag = network.getBroadcastUri().getHost();
            String netmask = NetUtils.getCidrNetmask(network.getCidr());
            PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, privateNic.getMacAddress());
           
View Full Code Here

    }

    @DB
    protected NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
        Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
        PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
        Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
       
        NicProfile privateNicProfile = new NicProfile();
       
        if (privateNic != null) {
            VirtualMachine vm = _vmDao.findById(privateNic.getId());
            privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(),
                    _networkMgr.getNetworkRate(privateNetwork.getId(), vm.getId()),
                    _networkMgr.isSecurityGroupSupportedInNetwork(privateNetwork),
                    _networkMgr.getNetworkTag(vm.getHypervisorType(), privateNetwork));
        } else {
            String vlanTag = privateNetwork.getBroadcastUri().getHost();
            String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());
            PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, privateNetwork.getGateway(), netmask,
                    NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
           
            privateNicProfile.setIp4Address(ip.getIpAddress());
            privateNicProfile.setGateway(ip.getGateway());
            privateNicProfile.setNetmask(ip.getNetmask());
            privateNicProfile.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
View Full Code Here

            sc.setParameters("ipAddress", requestedIp);
        }

        TransactionLegacy txn = TransactionLegacy.currentTxn();
        txn.start();
        PrivateIpVO vo = lockOneRandomRow(sc, true);
        if (vo == null) {
            txn.rollback();
            return null;
        }
        vo.setTakenAt(new Date());
        update(vo.getId(), vo);
        txn.commit();
        return vo;
    }
View Full Code Here

        }
        SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
        sc.setParameters("ip", ipAddress);
        sc.setParameters("networkId", networkId);

        PrivateIpVO vo = createForUpdate();

        vo.setTakenAt(null);
        update(vo, sc);
    }
View Full Code Here

                                    + " in zone " + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName());
            }
        }

        //add entry to private_ip_address table
        PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId);
        if (privateIp != null) {
                        throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" + " in zone "
                                + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName());
        }

        Long mac = dc.getMacAddress();
        Long nextMac = mac + 1;
        dc.setMacAddress(nextMac);

        privateIp = new PrivateIpVO(startIp, privateNetwork.getId(), nextMac, vpcId, sourceNat);
        _privateIpDao.persist(privateIp);

        _dcDao.update(dc.getId(), dc);

        s_logger.debug("Private network " + privateNetwork + " is created");
View Full Code Here

TOP

Related Classes of com.cloud.network.vpc.PrivateIpVO

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.