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


Java IPAddressVO.getState方法代码示例

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


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

示例1: applyIpAssociations

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public boolean applyIpAssociations(final Network network, final boolean continueOnError) throws ResourceUnavailableException {
    final List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
    boolean success = true;
    // CloudStack will take a lazy approach to associate an acquired public IP to a network service provider as
    // it will not know what service an acquired IP will be used for. An IP is actually associated with a provider when first
    // rule is applied. Similarly when last rule on the acquired IP is revoked, IP is not associated with any provider
    // but still be associated with the account. At this point just mark IP as allocated or released.
    for (final IPAddressVO addr : userIps) {
        if (addr.getState() == IpAddress.State.Allocating) {
            addr.setAssociatedWithNetworkId(network.getId());
            markPublicIpAsAllocated(addr);
        } else if (addr.getState() == IpAddress.State.Releasing) {
            // Cleanup all the resources for ip address if there are any, and only then un-assign ip in the system
            if (cleanupIpResources(addr.getId(), Account.ACCOUNT_ID_SYSTEM, _accountMgr.getSystemAccount())) {
                _ipAddressDao.unassignIpAddress(addr.getId());
            } else {
                success = false;
                s_logger.warn("Failed to release resources for ip address id=" + addr.getId());
            }
        }
    }
    return success;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:25,代码来源: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(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

示例3: applyIpAssociations

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException {
    List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
    boolean success = true;
    // CloudStack will take a lazy approach to associate an acquired public IP to a network service provider as
    // it will not know what service an acquired IP will be used for. An IP is actually associated with a provider when first
    // rule is applied. Similarly when last rule on the acquired IP is revoked, IP is not associated with any provider
    // but still be associated with the account. At this point just mark IP as allocated or released.
    for (IPAddressVO addr : userIps) {
        if (addr.getState() == IpAddress.State.Allocating) {
            addr.setAssociatedWithNetworkId(network.getId());
            markPublicIpAsAllocated(addr);
        } else if (addr.getState() == IpAddress.State.Releasing) {
            // Cleanup all the resources for ip address if there are any, and only then un-assign ip in the system
            if (cleanupIpResources(addr.getId(), Account.ACCOUNT_ID_SYSTEM, _accountMgr.getSystemAccount())) {
                _ipAddressDao.unassignIpAddress(addr.getId());
            } else {
                success = false;
                s_logger.warn("Failed to release resources for ip address id=" + addr.getId());
            }
        }
    }
    return success;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:25,代码来源:IpAddressManagerImpl.java

示例4: 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

示例5: createFloatingIp

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
public void createFloatingIp(IPAddressVO dbIp, StringBuffer syncLogMesg) throws Exception {

        if (dbIp.getState() == IpAddress.State.Releasing) {
            /* Don't need to push releasing ip */
            syncLogMesg.append("fip# DB: " + dbIp.getUuid() + ", state releasing, don't create in vnc\n");
            return;
        }
        syncLogMesg.append("fip# DB: " + dbIp.getAddress().addr() + "; VNC: none; action: create\n");
        if (!_manager.createFloatingIp(PublicIp.createFromAddrAndVlan(dbIp, _vlanDao.findById(dbIp.getVlanId())))) {
            syncLogMesg.append("fip# VNC: " + dbIp.getAddress().addr() + " unable to create\n");
            return;
        }
        syncLogMesg.append("fip# VNC: " + dbIp.getUuid() + " created\n");
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:15,代码来源:ServerDBSyncImpl.java

示例6: disassociatePublicIpAddress

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
@DB
public boolean disassociatePublicIpAddress(final long addrId, final long userId, final Account caller) {

    boolean success = true;
    // Cleanup all ip address resources - PF/LB/Static nat rules
    if (!cleanupIpResources(addrId, userId, caller)) {
        success = false;
        s_logger.warn("Failed to release resources for ip address id=" + addrId);
    }

    final IPAddressVO ip = markIpAsUnavailable(addrId);
    if (ip == null) {
        return true;
    }

    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Releasing ip id=" + addrId + "; sourceNat = " + ip.isSourceNat());
    }

    if (ip.getAssociatedWithNetworkId() != null) {
        final Network network = _networksDao.findById(ip.getAssociatedWithNetworkId());
        try {
            if (!applyIpAssociations(network, true)) {
                s_logger.warn("Unable to apply ip address associations for " + network);
                success = false;
            }
        } catch (final ResourceUnavailableException e) {
            throw new CloudRuntimeException("We should never get to here because we used true when applyIpAssociations", e);
        }
    } else {
        if (ip.getState() == IpAddress.State.Releasing) {
            _ipAddressDao.unassignIpAddress(ip.getId());
        }
    }

    if (success) {
        s_logger.debug("Released a public ip id=" + addrId);
    }

    return success;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:43,代码来源:IpAddressManagerImpl.java

示例7: reallocateRouterNetworks

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
public void reallocateRouterNetworks(final RouterDeploymentDefinition vpcRouterDeploymentDefinition, final VirtualRouter router, final VMTemplateVO template, final
HypervisorType hType)
        throws ConcurrentOperationException, InsufficientCapacityException {

    final TreeSet<String> publicVlans = new TreeSet<>();
    if (vpcRouterDeploymentDefinition.needsPublicNic()) {
        publicVlans.add(vpcRouterDeploymentDefinition.getSourceNatIP().getVlanTag());
    } else {
        s_logger.debug("VPC " + vpcRouterDeploymentDefinition.getVpc().getName() + " does not need a public nic.");
    }

    //1) allocate nic for control and source nat public ip
    final LinkedHashMap<Network, List<? extends NicProfile>> networks = configureDefaultNics(vpcRouterDeploymentDefinition);

    final Long vpcId = vpcRouterDeploymentDefinition.getVpc().getId();
    //2) allocate nic for private gateways if needed
    final List<PrivateGateway> privateGateways = vpcMgr.getVpcPrivateGateways(vpcId);
    if (privateGateways != null && !privateGateways.isEmpty()) {
        for (final PrivateGateway privateGateway : privateGateways) {
            final NicProfile privateNic = nicProfileHelper.createPrivateNicProfileForGateway(privateGateway, router);
            final Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
            networks.put(privateNetwork, new ArrayList<>(Arrays.asList(privateNic)));
        }
    }

    //3) allocate nic for guest gateway if needed
    final List<? extends Network> guestNetworks = vpcMgr.getVpcNetworks(vpcId);
    for (final Network guestNetwork : guestNetworks) {
        if (_networkModel.isPrivateGateway(guestNetwork.getId())) {
            continue;
        }
        if (guestNetwork.getState() == Network.State.Implemented || guestNetwork.getState() == Network.State.Setup) {
            final NicProfile guestNic = nicProfileHelper.createGuestNicProfileForVpcRouter(vpcRouterDeploymentDefinition, guestNetwork);
            networks.put(guestNetwork, new ArrayList<>(Arrays.asList(guestNic)));
        }
    }

    //4) allocate nic for additional public network(s)
    final List<IPAddressVO> ips = _ipAddressDao.listByAssociatedVpc(vpcId, false);
    final List<NicProfile> publicNics = new ArrayList<>();
    Network publicNetwork = null;
    for (final IPAddressVO ip : ips) {
        final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
        if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) && vpcMgr.isIpAllocatedToVpc(ip) &&
                !publicVlans.contains(publicIp.getVlanTag())) {
            s_logger.debug("Allocating nic for router in vlan " + publicIp.getVlanTag());
            final NicProfile publicNic = new NicProfile();
            publicNic.setDefaultNic(false);
            publicNic.setIPv4Address(publicIp.getAddress().addr());
            publicNic.setIPv4Gateway(publicIp.getGateway());
            publicNic.setIPv4Netmask(publicIp.getNetmask());
            publicNic.setMacAddress(publicIp.getMacAddress());
            publicNic.setBroadcastType(BroadcastDomainType.Vlan);
            publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
            publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
            final NetworkOffering publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOffering.SystemPublicNetwork).get(0);
            if (publicNetwork == null) {
                final List<? extends Network> publicNetworks = _networkMgr.setupNetwork(s_systemAccount, publicOffering, vpcRouterDeploymentDefinition.getPlan(), null, null,
                        false);
                publicNetwork = publicNetworks.get(0);
            }
            publicNics.add(publicNic);
            publicVlans.add(publicIp.getVlanTag());
        }
    }
    if (publicNetwork != null) {
        if (networks.get(publicNetwork) != null) {
            final
            List<NicProfile> publicNicProfiles = (List<NicProfile>) networks.get(publicNetwork);
            publicNicProfiles.addAll(publicNics);
            networks.put(publicNetwork, publicNicProfiles);
        } else {
            networks.put(publicNetwork, publicNics);
        }
    }

    final ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(vpcRouterDeploymentDefinition.getServiceOfferingId());

    _itMgr.allocate(router.getInstanceName(), template, routerOffering, networks, vpcRouterDeploymentDefinition.getPlan(), hType);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:82,代码来源:VpcNetworkHelperImpl.java

示例8: disassociatePublicIpAddress

import com.cloud.network.dao.IPAddressVO; //导入方法依赖的package包/类
@Override
@DB
public boolean disassociatePublicIpAddress(long addrId, long userId, Account caller) {

    boolean success = true;
    // Cleanup all ip address resources - PF/LB/Static nat rules
    if (!cleanupIpResources(addrId, userId, caller)) {
        success = false;
        s_logger.warn("Failed to release resources for ip address id=" + addrId);
    }

    IPAddressVO ip = markIpAsUnavailable(addrId);
    if (ip == null) {
        return true;
    }

    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Releasing ip id=" + addrId + "; sourceNat = " + ip.isSourceNat());
    }

    if (ip.getAssociatedWithNetworkId() != null) {
        Network network = _networksDao.findById(ip.getAssociatedWithNetworkId());
        try {
            if (!applyIpAssociations(network, rulesContinueOnErrFlag)) {
                s_logger.warn("Unable to apply ip address associations for " + network);
                success = false;
            }
        } catch (ResourceUnavailableException e) {
            throw new CloudRuntimeException("We should never get to here because we used true when applyIpAssociations", e);
        }
    } else {
        if (ip.getState() == IpAddress.State.Releasing) {
            _ipAddressDao.unassignIpAddress(ip.getId());
        }
    }

    if (success) {
        if (ip.isPortable()) {
            releasePortableIpAddress(addrId);
        }
        s_logger.debug("Released a public ip id=" + addrId);
    }

    return success;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:46,代码来源:IpAddressManagerImpl.java


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