public static List<String> getIpAddresses(VmNicInventory nic) { List<String> ret = new ArrayList<>(); for (UsedIpInventory ip : nic.getUsedIps()) { ret.add(ip.getIp()); } return ret; }
public static boolean nicIncludeAllIps(VmNicInventory nic, List<String> ipUuids) { List<String> ips = nic.getUsedIps().stream().map(ip -> ip.getUuid()).collect(Collectors.toList()); return ips.containsAll(ipUuids); }
public static List<String> getCanAttachL3List(VmNicInventory nic, List<VmNicSpec> nicSpecs) { List<String> res = new ArrayList<>(); for (VmNicSpec nicspec : nicSpecs) { List<String> l3s = nicspec.l3Invs.stream().map(L3NetworkInventory::getUuid).collect(Collectors.toList()); if (l3s.contains(nic.getL3NetworkUuid())) { /* remove all ready attached l3 */ l3s.removeAll(nic.getUsedIps().stream().map(UsedIpInventory::getL3NetworkUuid).collect(Collectors.toList())); l3s.remove(nic.getL3NetworkUuid()); res.addAll(l3s); break; } } return res; }
public static List<String> getL3Uuids(VmNicInventory nic) { List<String> ret = new ArrayList<>(); for (UsedIpInventory ip : nic.getUsedIps()) { ret.add(ip.getL3NetworkUuid()); } ret.add(nic.getL3NetworkUuid()); return ret.stream().distinct().collect(Collectors.toList()); }
public static boolean includeAllNicL3s(VmNicInventory nic, List<String> l3Uuids) { List<String> l3s = nic.getUsedIps().stream().map(ip -> ip.getL3NetworkUuid()).collect(Collectors.toList()); l3s.add(nic.getL3NetworkUuid()); return l3Uuids.containsAll(l3s); }
public static List<String> getCanDetachL3List(VmNicInventory nic, List<VmNicSpec> nicSpecs) { List<String> res = new ArrayList<>(); for (VmNicSpec nicspec : nicSpecs) { List<String> l3s = nicspec.l3Invs.stream().map(L3NetworkInventory::getUuid).collect(Collectors.toList()); if (l3s.contains(nic.getL3NetworkUuid())) { /* detach all usedIP except the nic first l3*/ res.addAll(nic.getUsedIps().stream().filter(ip -> !ip.getL3NetworkUuid().equals(nic.getL3NetworkUuid())) .map(UsedIpInventory::getUuid).collect(Collectors.toList())); break; } } return res; }
public static boolean isL3AttachedToVmNic(VmNicInventory nic, String l3Uuid) { for (UsedIpInventory ip : nic.getUsedIps()) { if (ip.getL3NetworkUuid().equals(l3Uuid)) { return true; } } if (nic.getL3NetworkUuid().equals(l3Uuid)) { return true; } return false; }
@Override public VmNicInventory call(VmNicInventory arg) { if (arg.getUsedIps() != null && !arg.getUsedIps().isEmpty()) { for (UsedIpInventory ip : arg.getUsedIps()) { if (ip.getL3NetworkUuid().equals(l3.getUuid())) { return arg; } } } else { VmNicVO nic = dbf.findByUuid(arg.getUuid(), VmNicVO.class); for (UsedIpVO ip : nic.getUsedIps()) { if (ip.getL3NetworkUuid().equals(l3.getUuid())) { return arg; } } } return null; } });
public static boolean isDefaultNic(VmNicInventory nic, VmInstanceInventory vm) { if (nic.getVmInstanceUuid() == null || vm.getDefaultL3NetworkUuid() == null || !nic.getVmInstanceUuid().equals(vm.getUuid())) { return false; } for (UsedIpInventory ip : nic.getUsedIps()) { if (ip.getL3NetworkUuid().equals(vm.getDefaultL3NetworkUuid())) { return true; } } return false; }
private String getEipL3Network(VmNicInventory nic, EipInventory eip){ String L3NetworkUuid = nic.getL3NetworkUuid(); if (eip.getGuestIp() != null) { for (UsedIpInventory ip : nic.getUsedIps()) { if (ip.getIp().equals(eip.getGuestIp())) { L3NetworkUuid = ip.getL3NetworkUuid(); break; } } } return L3NetworkUuid; }
private void removeStaticIp() { for (UsedIpInventory ip : nic.getUsedIps()) { new StaticIpOperator().deleteStaticIpByVmUuidAndL3Uuid(self.getUuid(), ip.getL3NetworkUuid()); } }
if (guestIp == null) { List<String> nicIps = nic.getUsedIps().stream().map(UsedIpInventory::getIp).collect(Collectors.toList()); completion.fail(operr("cannot find Eip guest ip: %s in vmNic ips :%s", eip.getGuestIp(), nicIps)); return;
List<String> nicL3Uuids = nic.getUsedIps().stream().map(UsedIpInventory::getL3NetworkUuid).collect(Collectors.toList()); Map<String, List<String>> secondaryNetworksMap = getSecondaryNetworksByVmUuid(vmUuid);
msgs.add(msg); } else { for (UsedIpInventory ip : nic.getUsedIps()) { if (l3Uuids.contains(ip.getL3NetworkUuid())) { DetachIpAddressFromVmNicMsg nicMsg = new DetachIpAddressFromVmNicMsg(); for (VmDeletionStruct vm : vminvs) { for (VmNicInventory nic : vm.getInventory().getVmNics()) { List<String> rangeUuids = nic.getUsedIps().stream().map(n -> n.getIpRangeUuid()).collect(Collectors.toList()); rangeUuids.removeAll(iprUuids); if(rangeUuids.isEmpty()) { msgs.add(msg); } else { for (UsedIpInventory ip : nic.getUsedIps()) { if (iprUuids.contains(ip.getIpRangeUuid())) { DetachIpAddressFromVmNicMsg nicMsg = new DetachIpAddressFromVmNicMsg();
for (UsedIpInventory ip : nic.getUsedIps()) { if (!ip.getL3NetworkUuid().equals(l3.getUuid())) { continue;
for (UsedIpInventory ip : nic.getUsedIps()) { ReturnIpMsg msg = new ReturnIpMsg(); msg.setL3NetworkUuid(ip.getL3NetworkUuid());
List<L3NetworkInventory> l3Invs = new ArrayList<>(); if (nic.getUsedIps() != null && !nic.getUsedIps().isEmpty()) { for (UsedIpInventory ip : nic.getUsedIps()) { L3NetworkVO l3Vo = dbf.findByUuid(ip.getL3NetworkUuid(), L3NetworkVO.class); if (l3Vo != null) {
new While<>(nic.getUsedIps()).all((ip, comp) -> { ReturnIpMsg msg = new ReturnIpMsg(); msg.setUsedIpUuid(ip.getUuid());
for (UsedIpInventory ip : nicInventory.getUsedIps()) { if (ip.getIp().equals(vo.getGuestIp())) { guestIp = ip;