mirror of https://github.com/apache/cloudstack.git
isSameIsolationId
This commit is contained in:
parent
04570eefed
commit
2cf356e047
|
|
@ -2378,7 +2378,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
String newVlanNetmask = cmd.getNetmask();
|
||||
String vlanId = cmd.getVlan();
|
||||
// TODO decide if we should be forgiving or demand a valid and complete URI
|
||||
if(Vlan.UNTAGGED.equalsIgnoreCase(vlanId))
|
||||
if (NetUtils.isSameIsolationId(Vlan.UNTAGGED, vlanId))
|
||||
vlanId = null;
|
||||
if (!((vlanId == null) || ("".equals(vlanId)) || vlanId.startsWith(BroadcastDomainType.Vlan.scheme())))
|
||||
vlanId = BroadcastDomainType.Vlan.toUri(vlanId).toString();
|
||||
|
|
@ -2556,9 +2556,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
VlanVO vlan = vlans.get(0);
|
||||
if (vlanId == null) {
|
||||
vlanId = vlan.getVlanTag();
|
||||
} else if (!vlan.getVlanTag().equals(vlanId)) {
|
||||
throw new InvalidParameterValueException("there is already one vlan " + vlan.getVlanTag() + " on network :" + +network.getId() +
|
||||
", only one vlan is allowed on guest network");
|
||||
} else if (!NetUtils.isSameIsolationId(vlan.getVlanTag(), vlanId)) {
|
||||
throw new InvalidParameterValueException("there is already one vlan " + vlan.getVlanTag()
|
||||
+ " on network :" + +network.getId() + ", only one vlan is allowed on guest network");
|
||||
}
|
||||
}
|
||||
sameSubnet = validateIpRange(startIP, endIP, newVlanGateway, newVlanNetmask, vlans, ipv4, ipv6, ip6Gateway, ip6Cidr, startIPv6, endIPv6, network);
|
||||
|
|
@ -2792,7 +2792,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (vlanId != null) {
|
||||
// if vlan is specified, throw an error if it's not equal to
|
||||
// network's vlanId
|
||||
if (networkVlanId != null && !networkVlanId.equalsIgnoreCase(vlanId)) {
|
||||
if (networkVlanId != null && !NetUtils.isSameIsolationId(networkVlanId, vlanId)) {
|
||||
throw new InvalidParameterValueException("Vlan doesn't match vlan of the network");
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2878,9 +2878,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
continue;
|
||||
}
|
||||
// from here, subnet overlaps
|
||||
if (!vlanId.equals(vlan.getVlanTag())) {
|
||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag() + " in zone " + zone.getName() +
|
||||
" has overlapped with the subnet. Please specify a different gateway/netmask.");
|
||||
if (!NetUtils.isSameIsolationId(vlanId, vlan.getVlanTag())) {
|
||||
throw new InvalidParameterValueException("The IP range with tag: " + vlan.getVlanTag()
|
||||
+ " in zone " + zone.getName()
|
||||
+ " has overlapped with the subnet. Please specify a different gateway/netmask.");
|
||||
}
|
||||
if (vlan.getNetworkId() != networkId) {
|
||||
throw new InvalidParameterValueException("This subnet is overlapped with subnet in other network " + vlan.getNetworkId() + " in zone " +
|
||||
|
|
@ -2918,7 +2919,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (vlan.getIp6Gateway() == null) {
|
||||
continue;
|
||||
}
|
||||
if (vlanId.equals(vlan.getVlanTag())) {
|
||||
if (NetUtils.isSameIsolationId(vlanId, vlan.getVlanTag())) {
|
||||
if (NetUtils.isIp6RangeOverlap(ipv6Range, vlan.getIp6Range())) {
|
||||
throw new InvalidParameterValueException("The IPv6 range with tag: " + vlan.getVlanTag() +
|
||||
" already has IPs that overlap with the new range. Please specify a different start IP/end IP.");
|
||||
|
|
@ -3304,7 +3305,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
List<PortableIpRangeVO> existingPortableIPRanges = _portableIpRangeDao.listByRegionId(_regionDao.getRegionId());
|
||||
if (existingPortableIPRanges != null && !existingPortableIPRanges.isEmpty()) {
|
||||
for (PortableIpRangeVO portableIpRange : existingPortableIPRanges) {
|
||||
if (portableIpRange.getVlanTag().equalsIgnoreCase(vlanId)) {
|
||||
if (NetUtils.isSameIsolationId(portableIpRange.getVlanTag(), vlanId)) {
|
||||
throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for portable ip range in this region");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1388,7 +1388,7 @@ public class NetUtils {
|
|||
|
||||
static final String VLAN_UNTAGGED = "untagged";
|
||||
|
||||
public static boolean sameIsolationId(String one, String other)
|
||||
public static boolean isSameIsolationId(String one, String other)
|
||||
{
|
||||
// check nulls
|
||||
// check empty strings
|
||||
|
|
@ -1413,7 +1413,7 @@ public class NetUtils {
|
|||
other = other.substring(VLAN_PREFIX_LENGTH);
|
||||
}
|
||||
// check valid uris or numbers
|
||||
if (one.equals(other))
|
||||
if (one.equalsIgnoreCase(other))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,4 +174,10 @@ public class NetUtilsTest extends TestCase {
|
|||
public void testGetLocalIPString() {
|
||||
assertNotNull(NetUtils.getLocalIPString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameIsolationId() {
|
||||
assertTrue(NetUtils.isSameIsolationId("1", "vlan://1"));
|
||||
assertTrue(NetUtils.isSameIsolationId("", null));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue