當前位置: 首頁>>代碼示例>>Java>>正文


Java IPAddressVO.getAllocatedTime方法代碼示例

本文整理匯總了Java中com.cloud.network.dao.IPAddressVO.getAllocatedTime方法的典型用法代碼示例。如果您正苦於以下問題:Java IPAddressVO.getAllocatedTime方法的具體用法?Java IPAddressVO.getAllocatedTime怎麽用?Java IPAddressVO.getAllocatedTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cloud.network.dao.IPAddressVO的用法示例。


在下文中一共展示了IPAddressVO.getAllocatedTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: markIpAsUnavailable

import com.cloud.network.dao.IPAddressVO; //導入方法依賴的package包/類
@DB
@Override
public IPAddressVO markIpAsUnavailable(final long addrId) {
    final IPAddressVO ip = _ipAddressDao.findById(addrId);

    if (ip.getAllocatedToAccountId() == null && ip.getAllocatedTime() == null) {
        s_logger.trace("Ip address id=" + addrId + " is already released");
        return ip;
    }

    if (ip.getState() != State.Releasing) {
        return Transaction.execute(new TransactionCallback<IPAddressVO>() {
            @Override
            public IPAddressVO doInTransaction(final TransactionStatus status) {
                if (updateIpResourceCount(ip)) {
                    _resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
                }

                return _ipAddressDao.markAsUnavailable(addrId);
            }
        });
    }

    return ip;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:26,代碼來源:IpAddressManagerImpl.java

示例2: markIpAsUnavailable

import com.cloud.network.dao.IPAddressVO; //導入方法依賴的package包/類
@DB
@Override
public IPAddressVO markIpAsUnavailable(final long addrId) {
    final IPAddressVO ip = _ipAddressDao.findById(addrId);

    if (ip.getAllocatedToAccountId() == null && ip.getAllocatedTime() == null) {
        s_logger.trace("Ip address id=" + addrId + " is already released");
        return ip;
    }

    if (ip.getState() != State.Releasing) {
        return Transaction.execute(new TransactionCallback<IPAddressVO>() {
            @Override
            public IPAddressVO doInTransaction(TransactionStatus status) {
                if (updateIpResourceCount(ip)) {
                    _resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
                }

                // Save usage event
                if (ip.getAllocatedToAccountId() != null && ip.getAllocatedToAccountId() != Account.ACCOUNT_ID_SYSTEM) {
                    VlanVO vlan = _vlanDao.findById(ip.getVlanId());

                    String guestType = vlan.getVlanType().toString();
                    if (!isIpDedicated(ip)) {
                        String eventType = ip.isPortable() ? EventTypes.EVENT_PORTABLE_IP_RELEASE : EventTypes.EVENT_NET_IP_RELEASE;
                        UsageEventUtils.publishUsageEvent(eventType, ip.getAllocatedToAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(), ip.isSourceNat(),
                                guestType, ip.getSystem(), ip.getClass().getName(), ip.getUuid());
                    }
                }

                return _ipAddressDao.markAsUnavailable(addrId);
            }
        });
    }

    return ip;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:38,代碼來源:IpAddressManagerImpl.java

示例3: releaseIpAddressInternal

import com.cloud.network.dao.IPAddressVO; //導入方法依賴的package包/類
@DB
private boolean releaseIpAddressInternal(final long ipAddressId) throws InsufficientAddressCapacityException {
    final Long userId = CallContext.current().getCallingUserId();
    final Account caller = CallContext.current().getCallingAccount();

    // Verify input parameters
    final 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.");
    }

    final 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()) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("Can't release system IP address with specified id");
        ex.addProxyObject(ipVO.getUuid(), "systemIpAddrId");
        throw ex;
    }

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

    if (success) {
        final Long networkId = ipVO.getAssociatedWithNetworkId();
        if (networkId != null) {
            final Network guestNetwork = getNetwork(networkId);
            final NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
            final Long vmId = ipVO.getAssociatedWithVmId();
            if (offering.getElasticIp() && vmId != null) {
                _rulesMgr.getSystemIpAndEnableStaticNatForVm(_userVmDao.findById(vmId), true);
                return true;
            }
        }
    } else {
        s_logger.warn("Failed to release public ip address id=" + ipAddressId);
    }
    return success;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:56,代碼來源:NetworkServiceImpl.java

示例4: releaseIpAddressInternal

import com.cloud.network.dao.IPAddressVO; //導入方法依賴的package包/類
@DB
private boolean releaseIpAddressInternal(long ipAddressId) throws InsufficientAddressCapacityException {
    Long userId = CallContext.current().getCallingUserId();
    Account caller = CallContext.current().getCallingAccount();

    // 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()) {
        throwInvalidIdException("Can't release system IP address with specified id", ipVO.getUuid(), "systemIpAddrId");
    }

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

    if (success) {
        Long networkId = ipVO.getAssociatedWithNetworkId();
        if (networkId != null) {
            Network guestNetwork = getNetwork(networkId);
            NetworkOffering offering = _entityMgr.findById(NetworkOffering.class, guestNetwork.getNetworkOfferingId());
            Long vmId = ipVO.getAssociatedWithVmId();
            if (offering.getElasticIp() && vmId != null) {
                _rulesMgr.getSystemIpAndEnableStaticNatForVm(_userVmDao.findById(vmId), true);
                return true;
            }
        }
    } else {
        s_logger.warn("Failed to release public ip address id=" + ipAddressId);
    }
    return success;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:54,代碼來源:NetworkServiceImpl.java


注:本文中的com.cloud.network.dao.IPAddressVO.getAllocatedTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。