Skip to content

Commit 0760fdf

Browse files
author
Sheng Yang
committed
CLOUDSTACK-1332: Add IPv6 DNS for Zone
1 parent 14a22ab commit 0760fdf

13 files changed

Lines changed: 123 additions & 26 deletions

File tree

‎api/src/org/apache/cloudstack/api/ApiConstants.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class ApiConstants {
5858
public static final String DISPLAY_TEXT = "displaytext";
5959
public static final String DNS1 = "dns1";
6060
public static final String DNS2 = "dns2";
61+
public static final String IP6_DNS1 = "ip6dns1";
62+
public static final String IP6_DNS2 = "ip6dns2";
6163
public static final String DOMAIN = "domain";
6264
public static final String DOMAIN_ID = "domainid";
6365
public static final String DURATION = "duration";

‎api/src/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public class CreateZoneCmd extends BaseCmd {
4646
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
4747
private String dns2;
4848

49+
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
50+
private String ip6Dns1;
51+
52+
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
53+
private String ip6Dns2;
54+
4955
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
5056
private String guestCidrAddress;
5157

@@ -89,6 +95,14 @@ public String getDns2() {
8995
return dns2;
9096
}
9197

98+
public String getIp6Dns1() {
99+
return ip6Dns1;
100+
}
101+
102+
public String getIp6Dns2() {
103+
return ip6Dns2;
104+
}
105+
92106
public String getGuestCidrAddress() {
93107
return guestCidrAddress;
94108
}

‎api/src/org/apache/cloudstack/api/command/admin/zone/UpdateZoneCmd.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public class UpdateZoneCmd extends BaseCmd {
4848
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
4949
private String dns2;
5050

51+
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
52+
private String ip6Dns1;
53+
54+
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
55+
private String ip6Dns2;
56+
5157
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
5258
private String guestCidrAddress;
5359

@@ -105,6 +111,14 @@ public Long getId() {
105111
return id;
106112
}
107113

114+
public String getIp6Dns1() {
115+
return ip6Dns1;
116+
}
117+
118+
public String getIp6Dns2() {
119+
return ip6Dns2;
120+
}
121+
108122
public String getInternalDns1() {
109123
return internalDns1;
110124
}

‎engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
6161
@Column(name="dns2")
6262
private String dns2 = null;
6363

64+
@Column(name="ip6Dns1")
65+
private String ip6Dns1 = null;
66+
67+
@Column(name="ip6Dns2")
68+
private String ip6Dns2 = null;
69+
6470
@Column(name="internal_dns1")
6571
private String internalDns1 = null;
6672

@@ -201,13 +207,13 @@ public void setFirewallProvider(String firewallProvider) {
201207
}
202208

203209
public EngineDataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
204-
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
210+
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
205211
this.id = id;
206212
this.allocationState = Grouping.AllocationState.Enabled;
207213
this.uuid = UUID.randomUUID().toString();
208214
}
209215

210-
public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled) {
216+
public EngineDataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
211217
this.name = name;
212218
this.description = description;
213219
this.dns1 = dns1;
@@ -477,4 +483,22 @@ public Date getLastUpdated() {
477483
public State getState() {
478484
return engineState;
479485
}
486+
487+
@Override
488+
public String getIp6Dns1() {
489+
return ip6Dns1;
490+
}
491+
492+
public void setIp6Dns1(String ip6Dns1) {
493+
this.ip6Dns1 = ip6Dns1;
494+
}
495+
496+
@Override
497+
public String getIp6Dns2() {
498+
return ip6Dns2;
499+
}
500+
501+
public void setIp6Dns2(String ip6Dns2) {
502+
this.ip6Dns2 = ip6Dns2;
503+
}
480504
}

‎engine/orchestration/test/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class ProvisioningTest extends TestCase {
7474
@Before
7575
public void setUp() {
7676
EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
77-
null, null, NetworkType.Basic, null, null, true, true);
77+
null, null, NetworkType.Basic, null, null, true, true, null, null);
7878
Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc);
7979
Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc);
8080

‎engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void setUp() {
7777
}
7878
//create data center
7979
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
80-
null, null, NetworkType.Basic, null, null, true, true);
80+
null, null, NetworkType.Basic, null, null, true, true, null, null);
8181
dc = dcDao.persist(dc);
8282
dcId = dc.getId();
8383
//create pod

‎engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void setUp() {
136136
}
137137
//create data center
138138
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
139-
null, null, NetworkType.Basic, null, null, true, true);
139+
null, null, NetworkType.Basic, null, null, true, true, null, null);
140140
dc = dcDao.persist(dc);
141141
dcId = dc.getId();
142142
//create pod

‎plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class VolumeTest {
7979
public void setUp() {
8080
//create data center
8181
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
82-
null, null, NetworkType.Basic, null, null, true, true);
82+
null, null, NetworkType.Basic, null, null, true, true, null, null);
8383
dc = dcDao.persist(dc);
8484
dcId = dc.getId();
8585
//create pod
@@ -148,4 +148,4 @@ private PrimaryDataStoreInfo createPrimaryDataStore() {
148148
public void createPrimaryDataStoreTest() {
149149
createPrimaryDataStore();
150150
}
151-
}
151+
}

‎server/src/com/cloud/configuration/ConfigurationManager.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMa
128128
* TODO
129129
* @param isSecurityGroupEnabled
130130
* TODO
131+
* @param ip6Dns1 TODO
132+
* @param ip6Dns2 TODO
131133
* @return
132134
* @throws
133135
* @throws
134136
*/
135137
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType, String allocationState,
136-
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled);
138+
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2);
137139

138140
/**
139141
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated

‎server/src/com/cloud/configuration/ConfigurationManagerImpl.java‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,8 @@ protected void checkIfZoneIsDeletable(long zoneId) {
10931093

10941094
}
10951095

1096-
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr) {
1096+
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr,
1097+
String ip6Dns1, String ip6Dns2) {
10971098
if (checkForDuplicates) {
10981099
// Check if a zone with the specified name already exists
10991100
if (validZone(zoneName)) {
@@ -1128,6 +1129,14 @@ private void checkZoneParameters(String zoneName, String dns1, String dns2, Stri
11281129
throw new InvalidParameterValueException("Please enter a valid IP address for internal DNS2");
11291130
}
11301131

1132+
if (ip6Dns1 != null && ip6Dns1.length() > 0 && !NetUtils.isValidIpv6(ip6Dns1)) {
1133+
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS1");
1134+
}
1135+
1136+
if (ip6Dns2 != null && ip6Dns2.length() > 0 && !NetUtils.isValidIpv6(ip6Dns2)) {
1137+
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS2");
1138+
}
1139+
11311140
Grouping.AllocationState allocationState = null;
11321141
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
11331142
try {
@@ -1372,6 +1381,8 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
13721381
String zoneName = cmd.getZoneName();
13731382
String dns1 = cmd.getDns1();
13741383
String dns2 = cmd.getDns2();
1384+
String ip6Dns1 = cmd.getIp6Dns1();
1385+
String ip6Dns2 = cmd.getIp6Dns2();
13751386
String internalDns1 = cmd.getInternalDns1();
13761387
String internalDns2 = cmd.getInternalDns2();
13771388
String guestCidr = cmd.getGuestCidrAddress();
@@ -1449,6 +1460,14 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
14491460
dns2 = zone.getDns2();
14501461
}
14511462

1463+
if (ip6Dns1 == null) {
1464+
ip6Dns1 = zone.getIp6Dns1();
1465+
}
1466+
1467+
if (ip6Dns2 == null) {
1468+
ip6Dns2 = zone.getIp6Dns2();
1469+
}
1470+
14521471
if (internalDns1 == null) {
14531472
internalDns1 = zone.getInternalDns1();
14541473
}
@@ -1471,20 +1490,13 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
14711490
}
14721491

14731492
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
1474-
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr);// not
1475-
// allowing
1476-
// updating
1477-
// domain
1478-
// associated
1479-
// with
1480-
// a
1481-
// zone,
1482-
// once
1483-
// created
1493+
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating domain associated with a zone, once created
14841494

14851495
zone.setName(zoneName);
14861496
zone.setDns1(dns1);
14871497
zone.setDns2(dns2);
1498+
zone.setIp6Dns1(ip6Dns1);
1499+
zone.setIp6Dns2(ip6Dns2);
14881500
zone.setInternalDns1(internalDns1);
14891501
zone.setInternalDns2(internalDns2);
14901502
zone.setGuestNetworkCidr(guestCidr);
@@ -1564,7 +1576,7 @@ public DataCenter editZone(UpdateZoneCmd cmd) {
15641576
@Override
15651577
@DB
15661578
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId,
1567-
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled) {
1579+
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2) {
15681580

15691581
// checking the following params outside checkzoneparams method as we do
15701582
// not use these params for updatezone
@@ -1582,15 +1594,15 @@ public DataCenterVO createZone(long userId, String zoneName, String dns1, String
15821594
}
15831595
}
15841596

1585-
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr);
1597+
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr, ip6Dns1, ip6Dns2);
15861598

15871599
byte[] bytes = (zoneName + System.currentTimeMillis()).getBytes();
15881600
String zoneToken = UUID.nameUUIDFromBytes(bytes).toString();
15891601
Transaction txn = Transaction.currentTxn();
15901602
try {
15911603
txn.start();
15921604
// Create the new zone in the database
1593-
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled);
1605+
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
15941606
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
15951607
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
15961608
zone.setAllocationState(allocationState);
@@ -1662,6 +1674,8 @@ public DataCenter createZone(CreateZoneCmd cmd) {
16621674
String zoneName = cmd.getZoneName();
16631675
String dns1 = cmd.getDns1();
16641676
String dns2 = cmd.getDns2();
1677+
String ip6Dns1 = cmd.getIp6Dns1();
1678+
String ip6Dns2 = cmd.getIp6Dns2();
16651679
String internalDns1 = cmd.getInternalDns1();
16661680
String internalDns2 = cmd.getInternalDns2();
16671681
String guestCidr = cmd.getGuestCidrAddress();
@@ -1705,7 +1719,7 @@ public DataCenter createZone(CreateZoneCmd cmd) {
17051719
}
17061720

17071721
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
1708-
isSecurityGroupEnabled, isLocalStorageEnabled);
1722+
isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
17091723
}
17101724

17111725
@Override

0 commit comments

Comments
 (0)