CLOUDSTACK-1332: Add IPv6 DNS for Zone

This commit is contained in:
Sheng Yang 2013-02-25 12:34:16 -08:00
parent c1d513ef12
commit 1b408509d6
13 changed files with 123 additions and 26 deletions

View File

@ -59,6 +59,8 @@ public class ApiConstants {
public static final String DISPLAY_TEXT = "displaytext";
public static final String DNS1 = "dns1";
public static final String DNS2 = "dns2";
public static final String IP6_DNS1 = "ip6dns1";
public static final String IP6_DNS2 = "ip6dns2";
public static final String DOMAIN = "domain";
public static final String DOMAIN_ID = "domainid";
public static final String DURATION = "duration";

View File

@ -46,6 +46,12 @@ public class CreateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2;
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
private String ip6Dns1;
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
private String ip6Dns2;
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
private String guestCidrAddress;
@ -89,6 +95,14 @@ public class CreateZoneCmd extends BaseCmd {
return dns2;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public String getGuestCidrAddress() {
return guestCidrAddress;
}

View File

@ -48,6 +48,12 @@ public class UpdateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2;
@Parameter(name=ApiConstants.IP6_DNS1, type=CommandType.STRING, description="the first DNS for IPv6 network in the Zone")
private String ip6Dns1;
@Parameter(name=ApiConstants.IP6_DNS2, type=CommandType.STRING, description="the second DNS for IPv6 network in the Zone")
private String ip6Dns2;
@Parameter(name=ApiConstants.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
private String guestCidrAddress;
@ -105,6 +111,14 @@ public class UpdateZoneCmd extends BaseCmd {
return id;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public String getInternalDns1() {
return internalDns1;
}

View File

@ -61,6 +61,12 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
@Column(name="dns2")
private String dns2 = null;
@Column(name="ip6Dns1")
private String ip6Dns1 = null;
@Column(name="ip6Dns2")
private String ip6Dns2 = null;
@Column(name="internal_dns1")
private String internalDns1 = null;
@ -201,13 +207,13 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
}
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) {
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
this.id = id;
this.allocationState = Grouping.AllocationState.Enabled;
this.uuid = UUID.randomUUID().toString();
}
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) {
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) {
this.name = name;
this.description = description;
this.dns1 = dns1;
@ -477,4 +483,22 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
public State getState() {
return engineState;
}
@Override
public String getIp6Dns1() {
return ip6Dns1;
}
public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}
@Override
public String getIp6Dns2() {
return ip6Dns2;
}
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
}

View File

@ -74,7 +74,7 @@ public class ProvisioningTest extends TestCase {
@Before
public void setUp() {
EngineDataCenterVO dc = new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
null, null, NetworkType.Basic, null, null, true, true);
null, null, NetworkType.Basic, null, null, true, true, null, null);
Mockito.when(dcDao.findByUuid(Mockito.anyString())).thenReturn(dc);
Mockito.when(dcDao.persist((EngineDataCenterVO) Mockito.anyObject())).thenReturn(dc);

View File

@ -77,7 +77,7 @@ public class DirectAgentTest extends CloudStackTestNGBase {
}
//create data center
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
null, null, NetworkType.Basic, null, null, true, true);
null, null, NetworkType.Basic, null, null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
//create pod

View File

@ -138,7 +138,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
}
//create data center
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
null, null, NetworkType.Basic, null, null, true, true);
null, null, NetworkType.Basic, null, null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
//create pod

View File

@ -79,7 +79,7 @@ public class VolumeTest {
public void setUp() {
//create data center
DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24",
null, null, NetworkType.Basic, null, null, true, true);
null, null, NetworkType.Basic, null, null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
//create pod
@ -148,4 +148,4 @@ public class VolumeTest {
public void createPrimaryDataStoreTest() {
createPrimaryDataStore();
}
}
}

View File

@ -129,12 +129,14 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
* TODO
* @param isSecurityGroupEnabled
* TODO
* @param ip6Dns1 TODO
* @param ip6Dns2 TODO
* @return
* @throws
* @throws
*/
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType, String allocationState,
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled);
String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2);
/**
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated

View File

@ -1092,7 +1092,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr) {
private void checkZoneParameters(String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, boolean checkForDuplicates, Long domainId, String allocationStateStr,
String ip6Dns1, String ip6Dns2) {
if (checkForDuplicates) {
// Check if a zone with the specified name already exists
if (validZone(zoneName)) {
@ -1127,6 +1128,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
throw new InvalidParameterValueException("Please enter a valid IP address for internal DNS2");
}
if (ip6Dns1 != null && ip6Dns1.length() > 0 && !NetUtils.isValidIpv6(ip6Dns1)) {
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS1");
}
if (ip6Dns2 != null && ip6Dns2.length() > 0 && !NetUtils.isValidIpv6(ip6Dns2)) {
throw new InvalidParameterValueException("Please enter a valid IPv6 address for IP6 DNS2");
}
Grouping.AllocationState allocationState = null;
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
try {
@ -1396,6 +1405,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
String zoneName = cmd.getZoneName();
String dns1 = cmd.getDns1();
String dns2 = cmd.getDns2();
String ip6Dns1 = cmd.getIp6Dns1();
String ip6Dns2 = cmd.getIp6Dns2();
String internalDns1 = cmd.getInternalDns1();
String internalDns2 = cmd.getInternalDns2();
String guestCidr = cmd.getGuestCidrAddress();
@ -1473,6 +1484,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
dns2 = zone.getDns2();
}
if (ip6Dns1 == null) {
ip6Dns1 = zone.getIp6Dns1();
}
if (ip6Dns2 == null) {
ip6Dns2 = zone.getIp6Dns2();
}
if (internalDns1 == null) {
internalDns1 = zone.getInternalDns1();
}
@ -1495,20 +1514,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
boolean checkForDuplicates = !zoneName.equals(oldZoneName);
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr);// not
// allowing
// updating
// domain
// associated
// with
// a
// zone,
// once
// created
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, checkForDuplicates, null, allocationStateStr, ip6Dns1, ip6Dns2);// not allowing updating domain associated with a zone, once created
zone.setName(zoneName);
zone.setDns1(dns1);
zone.setDns2(dns2);
zone.setIp6Dns1(ip6Dns1);
zone.setIp6Dns2(ip6Dns2);
zone.setInternalDns1(internalDns1);
zone.setInternalDns2(internalDns2);
zone.setGuestNetworkCidr(guestCidr);
@ -1588,7 +1600,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Override
@DB
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId,
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled) {
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2) {
// checking the following params outside checkzoneparams method as we do
// not use these params for updatezone
@ -1606,7 +1618,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
}
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr);
checkZoneParameters(zoneName, dns1, dns2, internalDns1, internalDns2, true, domainId, allocationStateStr, ip6Dns1, ip6Dns2);
byte[] bytes = (zoneName + System.currentTimeMillis()).getBytes();
String zoneToken = UUID.nameUUIDFromBytes(bytes).toString();
@ -1614,7 +1626,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
try {
txn.start();
// Create the new zone in the database
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled);
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, guestCidr, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
zone.setAllocationState(allocationState);
@ -1686,6 +1698,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
String zoneName = cmd.getZoneName();
String dns1 = cmd.getDns1();
String dns2 = cmd.getDns2();
String ip6Dns1 = cmd.getIp6Dns1();
String ip6Dns2 = cmd.getIp6Dns2();
String internalDns1 = cmd.getInternalDns1();
String internalDns2 = cmd.getInternalDns2();
String guestCidr = cmd.getGuestCidrAddress();
@ -1729,7 +1743,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
isSecurityGroupEnabled, isLocalStorageEnabled);
isSecurityGroupEnabled, isLocalStorageEnabled, ip6Dns1, ip6Dns2);
}
@Override

View File

@ -59,6 +59,12 @@ public class DataCenterVO implements DataCenter {
@Column(name="dns2")
private String dns2 = null;
@Column(name="ip6_dns1")
private String ip6Dns1 = null;
@Column(name="ip6_dns2")
private String ip6Dns2 = null;
@Column(name="internal_dns1")
private String internalDns1 = null;
@ -177,17 +183,19 @@ public class DataCenterVO implements DataCenter {
}
public DataCenterVO(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) {
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false);
this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
this.id = id;
this.allocationState = Grouping.AllocationState.Enabled;
this.uuid = UUID.randomUUID().toString();
}
public DataCenterVO(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) {
public DataCenterVO(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) {
this.name = name;
this.description = description;
this.dns1 = dns1;
this.dns2 = dns2;
this.ip6Dns1 = ip6Dns1;
this.ip6Dns2 = ip6Dns2;
this.internalDns1 = dns3;
this.internalDns2 = dns4;
this.guestNetworkCidr = guestCidr;
@ -431,4 +439,20 @@ public class DataCenterVO implements DataCenter {
public void setMacAddress(long macAddress) {
this.macAddress = macAddress;
}
public String getIp6Dns1() {
return ip6Dns1;
}
public void setIp6Dns1(String ip6Dns1) {
this.ip6Dns1 = ip6Dns1;
}
public String getIp6Dns2() {
return ip6Dns2;
}
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
}

View File

@ -608,7 +608,7 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
*/
@Override
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId, NetworkType zoneType,
String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled) {
String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1, String ip6Dns2) {
// TODO Auto-generated method stub
return null;
}

View File

@ -490,6 +490,9 @@ ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_gateway` varchar(255);
ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_cidr` varchar(255);
ALTER TABLE `cloud`.`vlan` ADD COLUMN `ip6_range` varchar(255);
ALTER TABLE `cloud`.`data_center` ADD COLUMN `ip6_dns1` varchar(255);
ALTER TABLE `cloud`.`data_center` ADD COLUMN `ip6_dns2` varchar(255);
-- DB views for list api
DROP VIEW IF EXISTS `cloud`.`user_vm_view`;