|
38 | 38 | import javax.inject.Inject; |
39 | 39 | import javax.naming.ConfigurationException; |
40 | 40 |
|
| 41 | +import com.cloud.utils.StringUtils; |
41 | 42 | import org.apache.log4j.Logger; |
42 | 43 |
|
43 | 44 | import org.apache.cloudstack.acl.ControlledEntity.ACLType; |
@@ -2116,16 +2117,12 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam |
2116 | 2117 |
|
2117 | 2118 | boolean ipv6 = false; |
2118 | 2119 |
|
2119 | | - if (ip6Gateway != null && ip6Cidr != null) { |
| 2120 | + if (StringUtils.isNotBlank(ip6Gateway) && StringUtils.isNotBlank(ip6Cidr)) { |
2120 | 2121 | ipv6 = true; |
2121 | 2122 | } |
2122 | 2123 | // Validate zone |
2123 | 2124 | final DataCenterVO zone = _dcDao.findById(zoneId); |
2124 | 2125 | if (zone.getNetworkType() == NetworkType.Basic) { |
2125 | | - if (ipv6) { |
2126 | | - throw new InvalidParameterValueException("IPv6 is not supported in Basic zone"); |
2127 | | - } |
2128 | | - |
2129 | 2126 | // In Basic zone the network should have aclType=Domain, domainId=1, subdomainAccess=true |
2130 | 2127 | if (aclType == null || aclType != ACLType.Domain) { |
2131 | 2128 | throw new InvalidParameterValueException("Only AclType=Domain can be specified for network creation in Basic zone"); |
@@ -2188,6 +2185,10 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam |
2188 | 2185 | } |
2189 | 2186 | } |
2190 | 2187 |
|
| 2188 | + if (ipv6 && !NetUtils.isValidIp6Cidr(ip6Cidr)) { |
| 2189 | + throw new InvalidParameterValueException("Invalid IPv6 cidr specified"); |
| 2190 | + } |
| 2191 | + |
2191 | 2192 | //TODO(VXLAN): Support VNI specified |
2192 | 2193 | // VlanId can be specified only when network offering supports it |
2193 | 2194 | final boolean vlanSpecified = vlanId != null; |
@@ -2328,7 +2329,7 @@ public Network doInTransaction(final TransactionStatus status) { |
2328 | 2329 | userNetwork.setGateway(gateway); |
2329 | 2330 | } |
2330 | 2331 |
|
2331 | | - if (ip6Cidr != null && ip6Gateway != null) { |
| 2332 | + if (StringUtils.isNotBlank(ip6Gateway) && StringUtils.isNotBlank(ip6Cidr)) { |
2332 | 2333 | userNetwork.setIp6Cidr(ip6Cidr); |
2333 | 2334 | userNetwork.setIp6Gateway(ip6Gateway); |
2334 | 2335 | } |
|
0 commit comments