Examples of IPAddressVO


Examples of com.cloud.network.dao.IPAddressVO

                        throw new InvalidParameterValueException("Can't remove the secondary ip " + secondaryIp + " is associate with the port forwarding rule");
                    }
                }
            }
            //check if the secondary ip associated with any static nat rule
            IPAddressVO publicIpVO = _ipAddressDao.findByVmIp(secondaryIp);
            if (publicIpVO != null) {
                s_logger.debug("VM nic IP " + secondaryIp + " is associated with the static NAT rule public IP address id " + publicIpVO.getId());
                throw new InvalidParameterValueException("Can' remove the ip " + secondaryIp + "is associate with static NAT rule public IP address id " + publicIpVO.getId());
            }
        } else if (dc.getNetworkType() == NetworkType.Basic || ntwkOff.getGuestType()  == Network.GuestType.Shared) {
            IPAddressVO ip = _ipAddressDao.findByIpAndNetworkId(secIpVO.getNetworkId(), secIpVO.getIp4Address());
            if (ip != null) {
                Transaction txn = Transaction.currentTxn();
                txn.start();
                _networkMgr.markIpAsUnavailable(ip.getId());
                _ipAddressDao.unassignIpAddress(ip.getId());
                txn.commit();
            }
        } else {
            throw new InvalidParameterValueException("Not supported for this network now");
        }
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

    private boolean releaseIpAddressInternal(long ipAddressId) throws InsufficientAddressCapacityException {
        Long userId = UserContext.current().getCallerUserId();
        Account caller = UserContext.current().getCaller();

        // Verify input parameters
        IPAddressVO ipVO = _ipAddressDao.findById(ipAddressId);
        if (ipVO == null) {
            throw new InvalidParameterValueException("Unable to find ip address by id");
        }

        if (ipVO.getAllocatedTime() == null) {
            s_logger.debug("Ip Address id= " + ipAddressId + " is not allocated, so do nothing.");
            return true;
        }

        // verify permissions
        if (ipVO.getAllocatedToAccountId() != null) {
            _accountMgr.checkAccess(caller, null, true, ipVO);
        }

        if (ipVO.isSourceNat()) {
            throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated.");
        }

        VlanVO vlan = _vlanDao.findById(ipVO.getVlanId());
        if (!vlan.getVlanType().equals(VlanType.VirtualNetwork)) {
            throw new IllegalArgumentException("only ip addresses that belong to a virtual network may be disassociated.");
        }

        // don't allow releasing system ip address
        if (ipVO.getSystem()) {
            InvalidParameterValueException ex = new InvalidParameterValueException("Can't release system IP address with specified id");
            ex.addProxyObject(ipVO.getUuid(), "systemIpAddrId");
            throw ex;
        }

        boolean success = _networkMgr.disassociatePublicIpAddress(ipAddressId, userId, caller);

        if (success) {
            Long networkId = ipVO.getAssociatedWithNetworkId();
            if (networkId != null) {
                Network guestNetwork = getNetwork(networkId);
                NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
                Long vmId = ipVO.getAssociatedWithVmId();
                if (offering.getElasticIp() && vmId != null) {
                    _rulesMgr.getSystemIpAndEnableStaticNatForVm(_userVmDao.findById(vmId), true);
                    return true;
                }
            }
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

       
        if (oldIp == null) {
            getNewIp = true;
        } else {
            // we need to get a new ip address if we try to deploy a vm in a different pod
            IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp);
            if (ipVO != null) {
                PodVlanMapVO mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId());
                if (mapVO.getPodId() != dest.getPod().getId()) {
                    Transaction txn = Transaction.currentTxn();
                    txn.start();
                   
                    //release the old ip here
                    _networkMgr.markIpAsUnavailable(ipVO.getId());
                    _ipAddressDao.unassignIpAddress(ipVO.getId());
                   
                    txn.commit();
                   
                    nic.setIp4Address(null);
                    getNewIp = true;
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

            }
            //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) {
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

    public void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
        }

        IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
        if (ip != null && nic.getReservationStrategy() != ReservationStrategy.Managed) {

            Transaction txn = Transaction.currentTxn();
            txn.start();

            _networkMgr.markIpAsUnavailable(ip.getId());
            _ipAddressDao.unassignIpAddress(ip.getId());

            txn.commit();
        }
        nic.deallocate();
       
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

        s_logger.debug("deallocate called with network: " + network.toString() + " nic: " + nic.toString() + " vm: " + vm.toString());
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
        }

        IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
        if (ip != null && nic.getReservationStrategy() != Nic.ReservationStrategy.Managed) {

            Transaction txn = Transaction.currentTxn();
            txn.start();

            _networkMgr.markIpAsUnavailable(ip.getId());
            _ipAddressDao.unassignIpAddress(ip.getId());

            txn.commit();
        }
        nic.deallocate();
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

        if (network.getSpecifyIpRanges()) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
            }

            IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
            if (ip != null) {
                Transaction txn = Transaction.currentTxn();
                txn.start();
                _networkMgr.markIpAsUnavailable(ip.getId());
                _ipAddressDao.unassignIpAddress(ip.getId());
                txn.commit();
            }
            nic.deallocate();
        }
    }
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

        if (oldIp == null) {
            getNewIp = true;
        } else {
            // we need to get a new ip address if we try to deploy a vm in a
            // different pod
            IPAddressVO ipVO = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), oldIp);
            if (ipVO != null) {
                PodVlanMapVO mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId());
                if (mapVO.getPodId() != dest.getPod().getId()) {
                    Transaction txn = Transaction.currentTxn();
                    txn.start();

                    // release the old ip here
                    _networkMgr.markIpAsUnavailable(ipVO.getId());
                    _ipAddressDao.unassignIpAddress(ipVO.getId());

                    txn.commit();

                    nic.setIp4Address(null);
                    getNewIp = true;
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

      if (s_logger.isDebugEnabled()) {
            s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
        }
     
      if (nic.getIp4Address() != null) {
            IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
            if (ip != null) {
                Transaction txn = Transaction.currentTxn();
                txn.start();
               
                // if the ip address a part of placeholder, don't release it
                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
                if (placeholderNic != null && placeholderNic.getIp4Address().equalsIgnoreCase(ip.getAddress().addr())) {
                    s_logger.debug("Not releasing direct ip " + ip.getId() +" yet as its ip is saved in the placeholder");
                } else {
                    _networkMgr.markIpAsUnavailable(ip.getId());
                    _ipAddressDao.unassignIpAddress(ip.getId());
                }
              
                //unassign nic secondary ip address
                s_logger.debug("remove nic " + nic.getId() + " secondary ip ");
                List<String> nicSecIps = null;
                nicSecIps = _nicSecondaryIpDao.getSecondaryIpAddressesForNic(nic.getId());
                for (String secIp: nicSecIps) {
                    IPAddressVO pubIp = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), secIp);
                    _networkMgr.markIpAsUnavailable(pubIp.getId());
                    _ipAddressDao.unassignIpAddress(pubIp.getId());
                }
   
                txn.commit();
            }
      }
View Full Code Here

Examples of com.cloud.network.dao.IPAddressVO

        Transaction txn = Transaction.currentTxn();
        txn.start();
        for (Nic nic : nics) {
            if (nic.getIp4Address() != null) {
                s_logger.debug("Releasing ip " + nic.getIp4Address() + " of placeholder nic " + nic);
                IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
                _networkMgr.markIpAsUnavailable(ip.getId());
                _ipAddressDao.unassignIpAddress(ip.getId());
                s_logger.debug("Removing placeholder nic " + nic);
                _nicDao.remove(nic.getId());
            }
        }
       
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.