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


Java IPAddressVO类代码示例

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


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

示例1: calculatePublicIpForAccount

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
private long calculatePublicIpForAccount(final long accountId) {
    Long dedicatedCount = 0L;
    final Long allocatedCount;

    final List<VlanVO> dedicatedVlans = _vlanDao.listDedicatedVlans(accountId);
    for (final VlanVO dedicatedVlan : dedicatedVlans) {
        final List<IPAddressVO> ips = _ipAddressDao.listByVlanId(dedicatedVlan.getId());
        dedicatedCount += new Long(ips.size());
    }
    allocatedCount = _ipAddressDao.countAllocatedIPsForAccount(accountId);
    if (dedicatedCount > allocatedCount) {
        return dedicatedCount;
    } else {
        return allocatedCount;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:ResourceLimitManagerImpl.java

示例2: markPublicIpAsAllocated

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@DB
@Override
public void markPublicIpAsAllocated(final IPAddressVO addr) {

    Transaction.execute(new TransactionCallbackNoReturn() {
        @Override
        public void doInTransactionWithoutResult(final TransactionStatus status) {
            final Account owner = _accountMgr.getAccount(addr.getAllocatedToAccountId());
            synchronized (this) {
                if (_ipAddressDao.lockRow(addr.getId(), true) != null) {
                    final IPAddressVO userIp = _ipAddressDao.findById(addr.getId());
                    if (userIp.getState() == IpAddress.State.Allocating || addr.getState() == IpAddress.State.Free) {
                        addr.setState(IpAddress.State.Allocated);
                        _ipAddressDao.update(addr.getId(), addr);
                        // Save usage event
                        if (owner.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
                            if (updateIpResourceCount(addr)) {
                                _resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
                            }
                        }
                    }
                }
            }
        }
    });
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:27,代码来源:IpAddressManagerImpl.java

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

示例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(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

示例5: deallocate

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
@DB
public void deallocate(final Network network, final NicProfile nic, final VirtualMachineProfile vm) {
    if (network.getSpecifyIpRanges()) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIPv4Address());
        }

        final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIPv4Address());
        if (ip != null) {
            Transaction.execute(new TransactionCallbackNoReturn() {
                @Override
                public void doInTransactionWithoutResult(final TransactionStatus status) {
                    _ipAddrMgr.markIpAsUnavailable(ip.getId());
                    _ipAddressDao.unassignIpAddress(ip.getId());
                }
            });
        }
        nic.deallocate();
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:22,代码来源:GuestNetworkGuru.java

示例6: deallocate

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
@DB
public void deallocate(final Network network, final NicProfile nic, final VirtualMachineProfile vm) {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIPv4Address());
    }

    final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIPv4Address());
    if (ip != null && nic.getReservationStrategy() != ReservationStrategy.Managed) {
        Transaction.execute(new TransactionCallbackNoReturn() {
            @Override
            public void doInTransactionWithoutResult(final TransactionStatus status) {
                _ipAddrMgr.markIpAsUnavailable(ip.getId());
                _ipAddressDao.unassignIpAddress(ip.getId());
            }
        });
    }
    nic.deallocate();

    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Deallocated nic: " + nic);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:24,代码来源:PublicNetworkGuru.java

示例7: replacePublicIpACL

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
public boolean replacePublicIpACL(final NetworkACL acl, final IPAddressVO publicIp) throws ResourceUnavailableException {

    if (publicIp.getIpACLId() != null) {
        // Revoke ACL Items of the existing ACL if the new ACL is empty
        // Existing rules won't be removed otherwise
        final List<NetworkACLItemVO> aclItems = _networkACLItemDao.listByACL(acl.getId());
        if (aclItems == null || aclItems.isEmpty()) {
            s_logger.debug("New network ACL is empty. Revoke existing rules before applying ACL");
            if (!revokeACLItemsForPublicIp(publicIp.getId())) {
                throw new CloudRuntimeException("Failed to replace network ACL. Error while removing existing ACL items for public ip: " + publicIp.getId());
            }
        }
    }

    publicIp.setIpACLId(acl.getId());
    //Update Public IP ACL
    if (_ipAddressDao.update(publicIp.getId(), publicIp)) {
        s_logger.debug("Updated public ip address: " + publicIp.getId() + " with ACL Id: " + acl.getId() + ", Applying ACL items");
        //Apply ACL to public ip
        return applyACLToPublicIp(publicIp.getId());
    }
    return false;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:25,代码来源:NetworkACLManagerImpl.java

示例8: getExistingSourceNatInVpc

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
private IPAddressVO getExistingSourceNatInVpc(final long ownerId, final long vpcId) {

        final List<IPAddressVO> addrs = listPublicIpsAssignedToVpc(ownerId, true, vpcId);

        IPAddressVO sourceNatIp = null;
        if (addrs.isEmpty()) {
            return null;
        } else {
            // Account already has ip addresses
            for (final IPAddressVO addr : addrs) {
                if (addr.isSourceNat()) {
                    sourceNatIp = addr;
                    return sourceNatIp;
                }
            }

            assert sourceNatIp != null : "How do we get a bunch of ip addresses but none of them are source nat? "
                    + "account=" + ownerId + "; vpcId=" + vpcId;
        }

        return sourceNatIp;
    }
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:23,代码来源:VpcManagerImpl.java

示例9: assignSourceNatIpAddressToVpc

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
public PublicIp assignSourceNatIpAddressToVpc(final Account owner, final Vpc vpc)
        throws InsufficientAddressCapacityException, ConcurrentOperationException {
    final long dcId = vpc.getZoneId();

    final IPAddressVO sourceNatIp = getExistingSourceNatInVpc(owner.getId(), vpc.getId());

    final PublicIp ipToReturn;

    if (sourceNatIp != null) {
        ipToReturn = PublicIp.createFromAddrAndVlan(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId()));
    } else {
        ipToReturn = _ipAddrMgr.assignDedicateIpAddress(owner, null, vpc.getId(), dcId, true);
    }

    return ipToReturn;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:VpcManagerImpl.java

示例10: checkIpForService

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
public boolean checkIpForService(final IpAddress userIp, final Service service, Long networkId) {
    if (networkId == null) {
        networkId = userIp.getAssociatedWithNetworkId();
    }

    final NetworkVO network = _networksDao.findById(networkId);
    final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    if (offering.getGuestType() != GuestType.Isolated) {
        return true;
    }
    final IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
    final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipVO, _vlanDao.findById(userIp.getVlanId()));
    if (!canIpUsedForService(publicIp, service, networkId)) {
        return false;
    }
    if (!offering.isConserveMode()) {
        return canIpUsedForNonConserveService(publicIp, service);
    }
    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:22,代码来源:NetworkModelImpl.java

示例11: getSourceNatIpAddressForGuestNetwork

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
public PublicIpAddress getSourceNatIpAddressForGuestNetwork(final Account owner, final Network guestNetwork) {
    final List<? extends IpAddress> addrs = listPublicIpsAssignedToGuestNtwk(owner.getId(), guestNetwork.getId(), true);

    final IPAddressVO sourceNatIp;
    if (addrs.isEmpty()) {
        return null;
    } else {
        for (final IpAddress addr : addrs) {
            if (addr.isSourceNat()) {
                sourceNatIp = _ipAddressDao.findById(addr.getId());
                return PublicIp.createFromAddrAndVlan(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId()));
            }
        }
    }

    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:NetworkModelImpl.java

示例12: addSystemFirewallRules

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_FIREWALL_OPEN, eventDescription = "creating firewall rule", create = true)
public boolean addSystemFirewallRules(final IPAddressVO ip, final Account acct) {
    final List<FirewallRuleVO> systemRules = _firewallDao.listSystemRules();
    for (final FirewallRuleVO rule : systemRules) {
        try {
            if (rule.getSourceCidrList() == null && (rule.getPurpose() == Purpose.Firewall || rule.getPurpose() == Purpose.NetworkACL)) {
                _firewallDao.loadSourceCidrs(rule);
            }
            createFirewallRule(ip.getId(), acct, rule.getXid(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getProtocol(), rule.getSourceCidrList(),
                    rule.getIcmpCode(), rule.getIcmpType(), rule.getRelated(), FirewallRuleType.System, rule.getNetworkId(), rule.getTrafficType(), true);
        } catch (final Exception e) {
            s_logger.debug("Failed to add system wide firewall rule, due to:" + e.toString());
        }
    }
    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:FirewallManagerImpl.java

示例13: finalizeStart

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
@Override
public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId, final Commands cmds, final ReservationContext context) {
    final CheckSshAnswer answer = (CheckSshAnswer) cmds.getAnswer("checkSsh");
    if (!answer.getResult()) {
        logger.warn("Unable to ssh to the VM: " + answer.getDetails());
        return false;
    }

    try {
        //get system ip and create static nat rule for the vm in case of basic networking with EIP/ELB
        _rulesMgr.getSystemIpAndEnableStaticNatForVm(profile.getVirtualMachine(), false);
        final IPAddressVO ipaddr = _ipAddressDao.findByAssociatedVmId(profile.getVirtualMachine().getId());
        if (ipaddr != null && ipaddr.getSystem()) {
            final SecondaryStorageVmVO secVm = _secStorageVmDao.findById(profile.getId());
            // override SSVM guest IP with EIP, so that download url's with be prepared with EIP
            secVm.setPublicIpAddress(ipaddr.getAddress().addr());
            _secStorageVmDao.update(secVm.getId(), secVm);
        }
    } catch (final Exception e) {
        logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", e);
        return false;
    }

    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:26,代码来源:SecondaryStorageManagerImpl.java

示例14: runDedicatePublicIpRangePostiveTest

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
void runDedicatePublicIpRangePostiveTest() throws Exception {
    final TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangePostiveTest");

    when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);

    when(configurationMgr._accountVlanMapDao.listAccountVlanMapsByAccount(anyLong())).thenReturn(null);

    final DataCenterVO dc =
            new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Advanced, null, null, true,
                    true, null, null);
    when(configurationMgr._zoneDao.findById(anyLong())).thenReturn(dc);

    final List<IPAddressVO> ipAddressList = new ArrayList<>();
    final IPAddressVO ipAddress = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
    ipAddressList.add(ipAddress);
    when(configurationMgr._publicIpAddressDao.listByVlanId(anyLong())).thenReturn(ipAddressList);

    try {
        final Vlan result = configurationMgr.dedicatePublicIpRange(dedicatePublicIpRangesCmd);
        Assert.assertNotNull(result);
    } catch (final Exception e) {
        s_logger.info("exception in testing runDedicatePublicIpRangePostiveTest message: " + e.toString());
    } finally {
        txn.close("runDedicatePublicIpRangePostiveTest");
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:27,代码来源:ConfigurationManagerTest.java

示例15: runDedicatePublicIpRangeInvalidZone

import com.cloud.network.dao.IPAddressVO; //导入依赖的package包/类
void runDedicatePublicIpRangeInvalidZone() throws Exception {
    final TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeInvalidZone");

    when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);

    when(configurationMgr._accountVlanMapDao.listAccountVlanMapsByVlan(anyLong())).thenReturn(null);

    // public ip range belongs to zone of type basic
    final DataCenterVO dc =
            new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true,
                    true, null, null);
    when(configurationMgr._zoneDao.findById(anyLong())).thenReturn(dc);

    final List<IPAddressVO> ipAddressList = new ArrayList<>();
    final IPAddressVO ipAddress = new IPAddressVO(new Ip("75.75.75.75"), 1, 0xaabbccddeeffL, 10, false);
    ipAddressList.add(ipAddress);
    when(configurationMgr._publicIpAddressDao.listByVlanId(anyLong())).thenReturn(ipAddressList);

    try {
        configurationMgr.dedicatePublicIpRange(dedicatePublicIpRangesCmd);
    } catch (final Exception e) {
        Assert.assertTrue(e.getMessage().contains("Public IP range can be dedicated to an account only in the zone of type Advanced"));
    } finally {
        txn.close("runDedicatePublicIpRangeInvalidZone");
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:27,代码来源:ConfigurationManagerTest.java


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