当前位置: 首页>>代码示例>>Java>>正文


Java IPAddressVO.setVmIp方法代码示例

本文整理汇总了Java中com.cloud.network.dao.IPAddressVO.setVmIp方法的典型用法代码示例。如果您正苦于以下问题:Java IPAddressVO.setVmIp方法的具体用法?Java IPAddressVO.setVmIp怎么用?Java IPAddressVO.setVmIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.network.dao.IPAddressVO的用法示例。


在下文中一共展示了IPAddressVO.setVmIp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: disableStaticNat

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public boolean disableStaticNat(final long ipId, final Account caller, final long callerUserId, final boolean releaseIpIfElastic) throws ResourceUnavailableException {
    boolean success = true;

    final IPAddressVO ipAddress = _ipAddressDao.findById(ipId);
    checkIpAndUserVm(ipAddress, null, caller, false);
    final long networkId = ipAddress.getAssociatedWithNetworkId();

    if (!ipAddress.isOneToOneNat()) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("One to one nat is not enabled for the specified ip id");
        ex.addProxyObject(ipAddress.getUuid(), "ipId");
        throw ex;
    }

    // Revoke all firewall rules for the ip
    try {
        s_logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of disabling static nat for public IP id=" + ipId);
        if (!_firewallMgr.revokeFirewallRulesForIp(ipId, callerUserId, caller)) {
            s_logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of disable statis nat");
            success = false;
        }
    } catch (final ResourceUnavailableException e) {
        s_logger.warn("Unable to revoke all firewall rules for ip id=" + ipId + " as a part of ip release", e);
        success = false;
    }

    if (!revokeAllPFAndStaticNatRulesForIp(ipId, callerUserId, caller)) {
        s_logger.warn("Unable to revoke all static nat rules for ip " + ipAddress);
        success = false;
    }

    if (success) {
        final boolean isIpSystem = ipAddress.getSystem();
        ipAddress.setOneToOneNat(false);
        ipAddress.setAssociatedWithVmId(null);
        ipAddress.setVmIp(null);
        if (isIpSystem && !releaseIpIfElastic) {
            ipAddress.setSystem(false);
        }
        _ipAddressDao.update(ipAddress.getId(), ipAddress);
        _vpcMgr.unassignIPFromVpcNetwork(ipAddress.getId(), networkId);

        if (isIpSystem && releaseIpIfElastic && !_ipAddrMgr.handleSystemIpRelease(ipAddress)) {
            s_logger.warn("Failed to release system ip address " + ipAddress);
            success = false;
        }

        return true;
    } else {
        s_logger.warn("Failed to disable one to one nat for the ip address id" + ipId);
        return false;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:54,代码来源:RulesManagerImpl.java

示例2: disableStaticNat

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public boolean disableStaticNat(long ipId, Account caller, long callerUserId, boolean releaseIpIfElastic) throws ResourceUnavailableException {
    boolean success = true;

    IPAddressVO ipAddress = _ipAddressDao.findById(ipId);
    checkIpAndUserVm(ipAddress, null, caller, false);
    long networkId = ipAddress.getAssociatedWithNetworkId();

    if (!ipAddress.isOneToOneNat()) {
        InvalidParameterValueException ex = new InvalidParameterValueException("One to one nat is not enabled for the specified ip id");
        ex.addProxyObject(ipAddress.getUuid(), "ipId");
        throw ex;
    }

    ipAddress.setRuleState(IpAddress.State.Releasing);
    _ipAddressDao.update(ipAddress.getId(), ipAddress);
    ipAddress = _ipAddressDao.findById(ipId);

    // Revoke all firewall rules for the ip
    try {
        s_logger.debug("Revoking all " + Purpose.Firewall + "rules as a part of disabling static nat for public IP id=" + ipId);
        if (!_firewallMgr.revokeFirewallRulesForIp(ipId, callerUserId, caller)) {
            s_logger.warn("Unable to revoke all the firewall rules for ip id=" + ipId + " as a part of disable statis nat");
            success = false;
        }
    } catch (ResourceUnavailableException e) {
        s_logger.warn("Unable to revoke all firewall rules for ip id=" + ipId + " as a part of ip release", e);
        success = false;
    }

    if (!revokeAllPFAndStaticNatRulesForIp(ipId, callerUserId, caller)) {
        s_logger.warn("Unable to revoke all static nat rules for ip " + ipAddress);
        success = false;
    }

    if (success) {
        boolean isIpSystem = ipAddress.getSystem();
        ipAddress.setOneToOneNat(false);
        ipAddress.setAssociatedWithVmId(null);
        ipAddress.setRuleState(null);
        ipAddress.setVmIp(null);
        if (isIpSystem && !releaseIpIfElastic) {
            ipAddress.setSystem(false);
        }
        _ipAddressDao.update(ipAddress.getId(), ipAddress);
        _vpcMgr.unassignIPFromVpcNetwork(ipAddress.getId(), networkId);

        if (isIpSystem && releaseIpIfElastic && !_ipAddrMgr.handleSystemIpRelease(ipAddress)) {
            s_logger.warn("Failed to release system ip address " + ipAddress);
            success = false;
        }

        return true;
    } else {
        s_logger.warn("Failed to disable one to one nat for the ip address id" + ipId);
        ipAddress = _ipAddressDao.findById(ipId);
        ipAddress.setRuleState(null);
        _ipAddressDao.update(ipAddress.getId(), ipAddress);
        return false;
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:62,代码来源:RulesManagerImpl.java


注:本文中的com.cloud.network.dao.IPAddressVO.setVmIp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。