Skip to content

Commit 9733a10

Browse files
widoDaanHoogland
authored andcommitted
CLOUDSTACK-10221: Allow IPv6 when creating a Basic Network (#2397)
Since CloudStack 4.10 Basic Networking supports IPv6 and thus should be allowed to be specified when creating a network. Signed-off-by: Wido den Hollander <wido@widodh.nl>
1 parent ca1760a commit 9733a10

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import javax.inject.Inject;
3939
import javax.naming.ConfigurationException;
4040

41+
import com.cloud.utils.StringUtils;
4142
import org.apache.log4j.Logger;
4243

4344
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
@@ -2116,16 +2117,12 @@ public Network createGuestNetwork(final long networkOfferingId, final String nam
21162117

21172118
boolean ipv6 = false;
21182119

2119-
if (ip6Gateway != null && ip6Cidr != null) {
2120+
if (StringUtils.isNotBlank(ip6Gateway) && StringUtils.isNotBlank(ip6Cidr)) {
21202121
ipv6 = true;
21212122
}
21222123
// Validate zone
21232124
final DataCenterVO zone = _dcDao.findById(zoneId);
21242125
if (zone.getNetworkType() == NetworkType.Basic) {
2125-
if (ipv6) {
2126-
throw new InvalidParameterValueException("IPv6 is not supported in Basic zone");
2127-
}
2128-
21292126
// In Basic zone the network should have aclType=Domain, domainId=1, subdomainAccess=true
21302127
if (aclType == null || aclType != ACLType.Domain) {
21312128
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
21882185
}
21892186
}
21902187

2188+
if (ipv6 && !NetUtils.isValidIp6Cidr(ip6Cidr)) {
2189+
throw new InvalidParameterValueException("Invalid IPv6 cidr specified");
2190+
}
2191+
21912192
//TODO(VXLAN): Support VNI specified
21922193
// VlanId can be specified only when network offering supports it
21932194
final boolean vlanSpecified = vlanId != null;
@@ -2328,7 +2329,7 @@ public Network doInTransaction(final TransactionStatus status) {
23282329
userNetwork.setGateway(gateway);
23292330
}
23302331

2331-
if (ip6Cidr != null && ip6Gateway != null) {
2332+
if (StringUtils.isNotBlank(ip6Gateway) && StringUtils.isNotBlank(ip6Cidr)) {
23322333
userNetwork.setIp6Cidr(ip6Cidr);
23332334
userNetwork.setIp6Gateway(ip6Gateway);
23342335
}

0 commit comments

Comments
 (0)