@Override public String getNetmask() { return _vlan.getVlanNetmask(); }
@Override public String getVlanNetmask() { return _vlan.getVlanNetmask(); }
for (VlanVO emptyVlan : emptyVlans) { if (fullVlan.getVlanTag().equals(emptyVlan.getVlanTag()) && fullVlan.getVlanGateway().equals(emptyVlan.getVlanGateway()) && fullVlan.getVlanNetmask().equals(emptyVlan.getVlanNetmask())) { return emptyVlan;
public VspNetwork updateVspNetworkByPublicIp(VspNetwork vspNetwork, Network network, String publicIp) { List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(network.getId()); final long ip = NetUtils.ip2Long(publicIp); VlanVO matchingVlan = vlans.stream() .filter(vlan -> isVlanContainingIp(vlan, ip)) .findFirst() .get(); boolean underlayEnabled = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, matchingVlan); return new VspNetwork.Builder().fromObject(vspNetwork) .gateway(matchingVlan.getVlanGateway()) .cidr(NetUtils.getCidrFromGatewayAndNetmask(matchingVlan.getVlanGateway(), matchingVlan.getVlanNetmask())) .vlanUnderlay(underlayEnabled) .build(); }
List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id); for (VlanVO vlan : vlan_list) { String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask()); dbSubnets.add(vlan.getVlanGateway() + cidr);
private void checkVlanUnderlayCompatibility(VlanVO newVlan) throws ResourceUnavailableException { List<VlanVO> vlans = _vlanDao.listByZone(newVlan.getDataCenterId()); if (CollectionUtils.isNotEmpty(vlans)) { boolean newVlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, newVlan); final String newCidr = NetUtils.getCidrFromGatewayAndNetmask(newVlan.getVlanGateway(), newVlan.getVlanNetmask()); for (VlanVO vlan : vlans) { if (vlan.getId() == newVlan.getId()) continue; final String existingCidr = NetUtils.getCidrFromGatewayAndNetmask(vlan.getVlanGateway(), vlan.getVlanNetmask()); NetUtils.SupersetOrSubset supersetOrSubset = NetUtils.isNetowrkASubsetOrSupersetOfNetworkB(newCidr, existingCidr); if (supersetOrSubset == NetUtils.SupersetOrSubset.sameSubnet) { boolean vlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan); if (newVlanUnderlay != vlanUnderlay) { throw new ResourceUnavailableException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported", Vlan.class, newVlan.getId()); } break; } } } }
String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask()); int slash = cidr.indexOf('/'); String ip_addr = cidr.substring(0, slash);
String ipv4Netmask = vlanVo.getVlanNetmask();
srcIpVlan = publicVlan.getVlanTag(); srcIpGateway = publicVlan.getVlanGateway(); srcIpNetmask = publicVlan.getVlanNetmask();
String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask()); int slash = cidr.indexOf('/'); String ip_addr = cidr.substring(0, slash);
for (final VlanVO vlan : vlans) { vlanGateway = vlan.getVlanGateway(); vlanNetmask = vlan.getVlanNetmask(); sameSubnet = hasSameSubnet(ipv4, vlanGateway, vlanNetmask, newVlanGateway, newVlanNetmask, startIP, endIP, ipv6, ip6Gateway, ip6Cidr, startIPv6, endIPv6, network);
List<VspAddressRange> vspAddressRanges = vlans.stream() .map(vlan -> new VspAddressRange.Builder().gateway(vlan.getVlanGateway()).netmask(vlan.getVlanNetmask()).build()) .collect(Collectors.toList());
for (final VlanVO vlan : vlans) { final String otherVlanGateway = vlan.getVlanGateway(); final String otherVlanNetmask = vlan.getVlanNetmask(); if (!vlanGateway.equals(otherVlanGateway) || !vlanNetmask.equals(vlan.getVlanNetmask())) { throw new InvalidParameterValueException("The IP range has already been added with gateway " + otherVlanGateway + " ,and netmask " + otherVlanNetmask
public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, VspNic vspNic) { VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder() .ipUuid(staticNatIp.getUuid()) .ipAddress(staticNatIp.getAddress().addr()) .revoke(forRevoke) .oneToOneNat(staticNatIp.isOneToOneNat()) .state(getEnumValue(staticNatIp.getState(), VspStaticNat.State.class)) .vlanUuid(staticNatVlan.getUuid()) .vlanGateway(staticNatVlan.getVlanGateway()) .vlanNetmask(staticNatVlan.getVlanNetmask()) .vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan)); if (staticNatIp.getVmIp() != null) { vspStaticNatBuilder.destinationIp(staticNatIp.getVmIp() + "/32"); } if (vspNic != null) { vspStaticNatBuilder.nic(vspNic); } return vspStaticNatBuilder.build(); }