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


Java IPAddressVO.setVpcId方法代码示例

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


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

示例1: reassignPublicIpsToNewVpc

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
private void reassignPublicIpsToNewVpc(long srcVpcId, Vpc dstVpc) {
    List<? extends IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVpc(srcVpcId, _vpcManager.isSrcNatIpRequired(dstVpc.getVpcOfferingId()) ? null : false);

    for(IPAddressVO publicIp : publicIps) {
        publicIp.setVpcId(dstVpc.getId());
        _ipAddressDao.persist(publicIp);
    }
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:9,代码来源:NetworkMigrationManagerImpl.java

示例2: cleanupVpcResources

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
public boolean cleanupVpcResources(final long vpcId, final Account caller, final long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException {
    s_logger.debug("Cleaning up resources for vpc id=" + vpcId);
    boolean success = true;

    // 1) Remove VPN connections and VPN gateway
    s_logger.debug("Cleaning up existed site to site VPN connections");
    _s2sVpnMgr.cleanupVpnConnectionByVpc(vpcId);
    s_logger.debug("Cleaning up existed site to site VPN gateways");
    _s2sVpnMgr.cleanupVpnGatewayByVpc(vpcId);

    // 2) release all ip addresses
    final List<IPAddressVO> ipsToRelease = _ipAddressDao.listByAssociatedVpc(vpcId, null);
    s_logger.debug("Releasing ips for vpc id=" + vpcId + " as a part of vpc cleanup");
    for (final IPAddressVO ipToRelease : ipsToRelease) {
        if (ipToRelease.isPortable()) {
            // portable IP address are associated with owner, until
            // explicitly requested to be disassociated.
            // so as part of VPC clean up just break IP association with VPC
            ipToRelease.setVpcId(null);
            ipToRelease.setAssociatedWithNetworkId(null);
            _ipAddressDao.update(ipToRelease.getId(), ipToRelease);
            s_logger.debug("Portable IP address " + ipToRelease + " is no longer associated with any VPC");
        } else {
            success = success && _ipAddrMgr.disassociatePublicIpAddress(ipToRelease.getId(), callerUserId, caller);
            if (!success) {
                s_logger.warn("Failed to cleanup ip " + ipToRelease + " as a part of vpc id=" + vpcId + " cleanup");
            }
        }
    }

    if (success) {
        s_logger.debug("Released ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process");
    } else {
        s_logger.warn("Failed to release ip addresses for vpc id=" + vpcId + " as a part of cleanup vpc process");
        // although it failed, proceed to the next cleanup step as it
        // doesn't depend on the public ip release
    }

    // 3) Delete all static route rules
    if (!revokeStaticRoutesForVpc(vpcId, caller)) {
        s_logger.warn("Failed to revoke static routes for vpc " + vpcId + " as a part of cleanup vpc process");
        return false;
    }

    // 4) Delete private gateways
    final List<PrivateGateway> gateways = getVpcPrivateGateways(vpcId);
    if (gateways != null) {
        for (final PrivateGateway gateway : gateways) {
            if (gateway != null) {
                s_logger.debug("Deleting private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup");
                if (!deleteVpcPrivateGateway(gateway.getId())) {
                    success = false;
                    s_logger.debug("Failed to delete private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup");
                } else {
                    s_logger.debug("Deleted private gateway " + gateway + " as a part of vpc " + vpcId + " resources cleanup");
                }
            }
        }
    }

    //5) Delete ACLs
    final SearchBuilder<NetworkACLVO> searchBuilder = _networkAclDao.createSearchBuilder();

    searchBuilder.and("vpcId", searchBuilder.entity().getVpcId(), Op.IN);
    final SearchCriteria<NetworkACLVO> searchCriteria = searchBuilder.create();
    searchCriteria.setParameters("vpcId", vpcId, 0);

    final Filter filter = new Filter(NetworkACLVO.class, "id", false, null, null);
    final Pair<List<NetworkACLVO>, Integer> aclsCountPair =  _networkAclDao.searchAndCount(searchCriteria, filter);

    final List<NetworkACLVO> acls = aclsCountPair.first();
    for (final NetworkACLVO networkAcl : acls) {
        if (networkAcl.getId() != NetworkACL.DEFAULT_ALLOW && networkAcl.getId() != NetworkACL.DEFAULT_DENY) {
            _networkAclMgr.deleteNetworkACL(networkAcl);
        }
    }
    return success;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:79,代码来源:VpcManagerImpl.java

示例3: implement

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context)
        throws InsufficientVirtualNetworkCapacityException {
    s_logger.debug("Implement network: " + network.getName() + ", traffic type: " + network.getTrafficType());

    VirtualNetworkModel vnModel = _manager.getDatabase().lookupVirtualNetwork(network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
    if (vnModel == null) {
        vnModel = new VirtualNetworkModel(network, network.getUuid(), _manager.getCanonicalName(network), network.getTrafficType());
        vnModel.setProperties(_manager.getModelController(), network);
    }

    try {
        if (!vnModel.verify(_manager.getModelController())) {
            vnModel.update(_manager.getModelController());
        }
    } catch (Exception ex) {
        s_logger.warn("virtual-network update: ", ex);
        return network;
    }
    _manager.getDatabase().getVirtualNetworks().add(vnModel);

    if (network.getVpcId() != null) {
        List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(network.getVpcId(), true);
        if (ips.isEmpty()) {
            s_logger.debug("Creating a source nat ip for network " + network);
            Account owner = _accountMgr.getAccount(network.getAccountId());
            try {
                PublicIp publicIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
                IPAddressVO ip = publicIp.ip();
                ip.setVpcId(network.getVpcId());
                _ipAddressDao.acquireInLockTable(ip.getId());
                _ipAddressDao.update(ip.getId(), ip);
                _ipAddressDao.releaseFromLockTable(ip.getId());
            } catch (Exception e) {
                s_logger.error("Unable to allocate source nat ip: " + e);
            }
        }
    }

    return network;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:42,代码来源:ContrailGuru.java


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