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


Java NicVO.getIPv4Address方法代码示例

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


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

示例1: getRouterControlIp

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
public String getRouterControlIp(final long routerId) {
    String routerControlIpAddress = null;
    final List<NicVO> nics = nicDao.listByVmId(routerId);
    for (final NicVO n : nics) {
        final NetworkVO nc = networkDao.findById(n.getNetworkId());
        if (nc != null && nc.getTrafficType() == TrafficType.Control) {
            routerControlIpAddress = n.getIPv4Address();
            // router will have only one control ip
            break;
        }
    }

    if (routerControlIpAddress == null) {
        logger.warn("Unable to find router's control ip in its attached NICs!. routerId: " + routerId);
        final DomainRouterVO router = routerDao.findById(routerId);
        return router.getPrivateIpAddress();
    }

    return routerControlIpAddress;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:21,代码来源:RouterControlHelper.java

示例2: getIpAddress

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
@Override
public String getIpAddress(final long networkId, final long instanceId) {
    final SearchCriteria<NicVO> sc = AllFieldsSearch.create();
    sc.setParameters("network", networkId);
    sc.setParameters("instance", instanceId);
    final NicVO nicVo = findOneBy(sc);
    if (nicVo != null) {
        return nicVo.getIPv4Address();
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:12,代码来源:NicDaoImpl.java

示例3: checkIpExclusionList

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
private void checkIpExclusionList(final String ipExclusionList, final String cidr, final List<NicVO> nicsPresent) {
    if (StringUtils.isNotBlank(ipExclusionList)) {
        // validate ipExclusionList
        // Perform a "syntax" check on the list
        if (!NetUtils.validIpRangeList(ipExclusionList)) {
            throw new InvalidParameterValueException("Syntax error in ipExclusionList");
        }

        final List<String> excludedIps = NetUtils.getAllIpsFromRangeList(ipExclusionList);

        if (cidr != null) {
            //Check that ipExclusionList (delimiters) is within the CIDR
            if (!NetUtils.isIpRangeListInCidr(ipExclusionList, cidr)) {
                throw new InvalidParameterValueException("An IP in the ipExclusionList is not part of the CIDR of the network " + cidr);
            }

            //Check that at least one IP is available after exclusion for the router interface
            final SortedSet<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr, NetUtils.listIp2LongList(excludedIps));
            if (allPossibleIps.isEmpty()) {
                throw new InvalidParameterValueException("The ipExclusionList excludes all IPs in the CIDR; at least one needs to be available");
            }
        }

        if (nicsPresent != null) {
            // Check that no existing nics/ips are part of the exclusion list
            for (final NicVO nic : nicsPresent) {
                final String nicIp = nic.getIPv4Address();
                //check if nic IP is exclusionList
                if (excludedIps.contains(nicIp) && !(Nic.State.Deallocating.equals(nic.getState()))) {
                    throw new InvalidParameterValueException("Active IP " + nic.getIPv4Address() + " exist in ipExclusionList.");
                }
            }
        }
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:36,代码来源:NetworkServiceImpl.java

示例4: getPlaceholderNicForRouter

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
@Override
public NicVO getPlaceholderNicForRouter(final Network network, final Long podId) {
    final List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkIdAndVmType(network.getId(), VirtualMachine.Type.DomainRouter);
    for (final NicVO nic : nics) {
        if (nic.getReserver() == null && (nic.getIPv4Address() != null || nic.getIPv6Address() != null)) {
            if (podId == null) {
                return nic;
            } else {
                //return nic only when its ip address belong to the pod range (for the Basic zone case)
                final List<? extends Vlan> vlans = _vlanDao.listVlansForPod(podId);
                for (final Vlan vlan : vlans) {
                    if (nic.getIPv4Address() != null) {
                        final IpAddress ip = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), nic.getIPv4Address());
                        if (ip != null && ip.getVlanId() == vlan.getId()) {
                            return nic;
                        }
                    } else {
                        final UserIpv6AddressVO ipv6 = _ipv6Dao.findByNetworkIdAndIp(network.getId(), nic.getIPv6Address());
                        if (ipv6 != null && ipv6.getVlanId() == vlan.getId()) {
                            return nic;
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:29,代码来源:NetworkModelImpl.java

示例5: createPasswordCommand

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
public void createPasswordCommand(final VirtualRouter router, final VirtualMachineProfile profile, final NicVO nic, final Commands cmds) {
    final String password = (String) profile.getParameter(VirtualMachineProfile.Param.VmPassword);
    final Zone zone = zoneRepository.findOne(router.getDataCenterId());

    // password should be set only on default network element
    if (password != null && nic.isDefaultNic()) {
        final SavePasswordCommand cmd = new SavePasswordCommand(password, nic.getIPv4Address(), profile.getVirtualMachine().getHostName(),
                _networkModel.getExecuteInSeqNtwkElmtCmd());
        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
        cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, zone.getNetworkType().toString());

        cmds.addCommand("password", cmd);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:16,代码来源:CommandSetupHelper.java


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