本文整理匯總了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;
}
示例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;
}
示例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.");
}
}
}
}
}
示例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;
}
示例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);
}
}