mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 12483: Discard zone's cidr
status 12483: resolved fixed
This commit is contained in:
parent
255a6ae30f
commit
ab50f65ed8
@ -47,9 +47,6 @@ 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.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
@Parameter(name=ApiConstants.INTERNAL_DNS1, type=CommandType.STRING, required=true, description="the first internal DNS for the Zone")
|
||||
private String internalDns1;
|
||||
|
||||
@ -87,10 +84,6 @@ public class CreateZoneCmd extends BaseCmd {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public String getGuestCidrAddress() {
|
||||
return guestCidrAddress;
|
||||
}
|
||||
|
||||
public String getInternalDns1() {
|
||||
return internalDns1;
|
||||
}
|
||||
|
||||
@ -50,9 +50,6 @@ 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.GUEST_CIDR_ADDRESS, type=CommandType.STRING, description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Zone")
|
||||
private Long id;
|
||||
@ -96,10 +93,6 @@ public class UpdateZoneCmd extends BaseCmd {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
public String getGuestCidrAddress() {
|
||||
return guestCidrAddress;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -49,9 +49,6 @@ public class ZoneResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan range of the zone")
|
||||
private String vlan;
|
||||
|
||||
@SerializedName(ApiConstants.GUEST_CIDR_ADDRESS) @Param(description="the guest CIDR address for the Zone")
|
||||
private String guestCidrAddress;
|
||||
|
||||
//TODO - generate description
|
||||
@SerializedName("status")
|
||||
private String status;
|
||||
@ -147,14 +144,6 @@ public class ZoneResponse extends BaseResponse {
|
||||
this.vlan = vlan;
|
||||
}
|
||||
|
||||
public String getGuestCidrAddress() {
|
||||
return guestCidrAddress;
|
||||
}
|
||||
|
||||
public void setGuestCidrAddress(String guestCidrAddress) {
|
||||
this.guestCidrAddress = guestCidrAddress;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@ public interface DataCenter extends Grouping {
|
||||
long getId();
|
||||
String getDns1();
|
||||
String getDns2();
|
||||
String getGuestNetworkCidr();
|
||||
String getName();
|
||||
Long getDomainId();
|
||||
String getDescription();
|
||||
|
||||
@ -856,7 +856,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
|
||||
zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
|
||||
// FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
|
||||
zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
|
||||
}
|
||||
|
||||
if (showCapacities != null && showCapacities){
|
||||
|
||||
@ -114,7 +114,6 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @param dns2
|
||||
* @param internalDns1
|
||||
* @param internalDns2
|
||||
* @param guestCidr
|
||||
* @param zoneType
|
||||
* @param allocationState
|
||||
* @param networkDomain TODO
|
||||
@ -123,7 +122,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @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);
|
||||
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String domain, Long domainId, NetworkType zoneType, String allocationState, String networkDomain, boolean isSecurityGroupEnabled);
|
||||
|
||||
/**
|
||||
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated IP addresses.
|
||||
|
||||
@ -1279,7 +1279,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String dns2 = cmd.getDns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
List<String> dnsSearchOrder = cmd.getDnsSearchOrder();
|
||||
Boolean isPublic = cmd.isPublic();
|
||||
String allocationStateStr = cmd.getAllocationState();
|
||||
@ -1330,10 +1329,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
zoneName = zone.getName();
|
||||
}
|
||||
|
||||
if ((guestCidr != null) && !NetUtils.validateGuestCidr(guestCidr)) {
|
||||
throw new InvalidParameterValueException("Please enter a valid guest cidr");
|
||||
}
|
||||
|
||||
// Make sure the zone exists
|
||||
if (!validZone(zoneId)) {
|
||||
throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist.");
|
||||
@ -1357,10 +1352,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
internalDns1 = zone.getInternalDns1();
|
||||
}
|
||||
|
||||
if (guestCidr == null) {
|
||||
guestCidr = zone.getGuestNetworkCidr();
|
||||
}
|
||||
|
||||
// validate network domain
|
||||
if (networkDomain != null) {
|
||||
if (!NetUtils.verifyDomainName(networkDomain)) {
|
||||
@ -1389,7 +1380,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
zone.setDns2(dns2);
|
||||
zone.setInternalDns1(internalDns1);
|
||||
zone.setInternalDns2(internalDns2);
|
||||
zone.setGuestNetworkCidr(guestCidr);
|
||||
zone.setDomain(networkDomain);
|
||||
|
||||
// update a private zone to public; not vice versa
|
||||
@ -1428,15 +1418,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain, Long domainId,
|
||||
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String domain, Long domainId,
|
||||
NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled) {
|
||||
|
||||
// checking the following params outside checkzoneparams method as we do
|
||||
// not use these params for updatezone
|
||||
// hence the method below is generic to check for common params
|
||||
if ((guestCidr != null) && !NetUtils.validateGuestCidr(guestCidr)) {
|
||||
throw new InvalidParameterValueException("Please enter a valid guest cidr");
|
||||
}
|
||||
|
||||
// Validate network domain
|
||||
if (networkDomain != null) {
|
||||
@ -1455,7 +1442,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
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);
|
||||
DataCenterVO zone = new DataCenterVO(zoneName, null, dns1, dns2, internalDns1, internalDns2, domain, domainId, zoneType, zoneToken, networkDomain, isSecurityGroupEnabled);
|
||||
if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
|
||||
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
|
||||
zone.setAllocationState(allocationState);
|
||||
@ -1554,7 +1541,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String dns2 = cmd.getDns2();
|
||||
String internalDns1 = cmd.getInternalDns1();
|
||||
String internalDns2 = cmd.getInternalDns2();
|
||||
String guestCidr = cmd.getGuestCidrAddress();
|
||||
Long domainId = cmd.getDomainId();
|
||||
String type = cmd.getNetworkType();
|
||||
Boolean isBasic = false;
|
||||
@ -1574,14 +1560,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
NetworkType zoneType = isBasic ? NetworkType.Basic : NetworkType.Advanced;
|
||||
|
||||
// Guest cidr is required for Advanced zone creation; error out when the
|
||||
// parameter specified for Basic zone
|
||||
if (zoneType == NetworkType.Advanced && guestCidr == null && !isSecurityGroupEnabled) {
|
||||
throw new InvalidParameterValueException("guestCidrAddress parameter is required for Advanced zone creation");
|
||||
} else if (zoneType == NetworkType.Basic && guestCidr != null) {
|
||||
throw new InvalidParameterValueException("guestCidrAddress parameter is not supported for Basic zone");
|
||||
}
|
||||
|
||||
DomainVO domainVO = null;
|
||||
|
||||
if (userId == null) {
|
||||
@ -1596,7 +1574,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
isSecurityGroupEnabled = true;
|
||||
}
|
||||
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, guestCidr, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
|
||||
return createZone(userId, zoneName, dns1, dns2, internalDns1, internalDns2, domainVO != null ? domainVO.getName() : null, domainId, zoneType, allocationState, networkDomain,
|
||||
isSecurityGroupEnabled);
|
||||
}
|
||||
|
||||
@ -2279,30 +2257,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask);
|
||||
|
||||
// Check if the new VLAN's subnet conflicts with the guest network in
|
||||
// the specified zone (guestCidr is null for basic
|
||||
// zone)
|
||||
String guestNetworkCidr = zone.getGuestNetworkCidr();
|
||||
if (guestNetworkCidr != null) {
|
||||
String[] cidrPair = guestNetworkCidr.split("\\/");
|
||||
String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrPair[0], Long.parseLong(cidrPair[1]));
|
||||
long guestCidrSize = Long.parseLong(cidrPair[1]);
|
||||
long vlanCidrSize = NetUtils.getCidrSize(vlanNetmask);
|
||||
|
||||
long cidrSizeToUse = -1;
|
||||
if (vlanCidrSize < guestCidrSize) {
|
||||
cidrSizeToUse = vlanCidrSize;
|
||||
} else {
|
||||
cidrSizeToUse = guestCidrSize;
|
||||
}
|
||||
|
||||
String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse);
|
||||
|
||||
if (newVlanSubnet.equals(guestSubnet)) {
|
||||
throw new InvalidParameterValueException("The new IP range you have specified has the same subnet as the guest network in zone: " + zone.getName()
|
||||
+ ". Please specify a different gateway/netmask.");
|
||||
}
|
||||
}
|
||||
// TODO: Check if the new VLAN's subnet conflicts with the guest network in
|
||||
// the specified zone (guestCidr is null for basic zone)
|
||||
|
||||
// Check if there are any errors with the IP range
|
||||
checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP);
|
||||
@ -2702,21 +2658,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
// 1. The pod's CIDR subnet conflicts with the guest network subnet
|
||||
// 2. The pod's CIDR subnet conflicts with the CIDR subnet of any other
|
||||
// pod
|
||||
DataCenterVO dcVo = _zoneDao.findById(dcId);
|
||||
String guestNetworkCidr = dcVo.getGuestNetworkCidr();
|
||||
|
||||
// Guest cidr can be null for Basic zone
|
||||
String guestIpNetwork = null;
|
||||
Long guestCidrSize = null;
|
||||
if (guestNetworkCidr != null) {
|
||||
String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]));
|
||||
guestCidrSize = Long.parseLong(cidrTuple[1]);
|
||||
}
|
||||
// Iterate through all pods in this zone
|
||||
|
||||
String zoneName = getZoneName(dcId);
|
||||
|
||||
// Iterate through all pods in this zone
|
||||
for (Long podId : currentPodCidrSubnets.keySet()) {
|
||||
String podName;
|
||||
if (podId.longValue() == -1) {
|
||||
@ -2730,26 +2676,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
long cidrSize = ((Long) cidrPair.get(1)).longValue();
|
||||
|
||||
long cidrSizeToUse = -1;
|
||||
if (guestCidrSize == null || cidrSize < guestCidrSize) {
|
||||
cidrSizeToUse = cidrSize;
|
||||
} else {
|
||||
cidrSizeToUse = guestCidrSize;
|
||||
}
|
||||
cidrSizeToUse = cidrSize;
|
||||
|
||||
String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse);
|
||||
|
||||
if (guestNetworkCidr != null) {
|
||||
String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse);
|
||||
// Check that cidrSubnet does not equal guestSubnet
|
||||
if (cidrSubnet.equals(guestSubnet)) {
|
||||
if (podName.equals("newPod")) {
|
||||
throw new InvalidParameterValueException("The subnet of the pod you are adding conflicts with the subnet of the Guest IP Network. Please specify a different CIDR.");
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Warning: The subnet of pod " + podName + " in zone " + zoneName
|
||||
+ " conflicts with the subnet of the Guest IP Network. Please change either the pod's CIDR or the Guest IP Network's subnet, and re-run install-vmops-management.");
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO add checking for CIDR of guest network in this data center
|
||||
|
||||
// Iterate through the rest of the pods
|
||||
for (Long otherPodId : currentPodCidrSubnets.keySet()) {
|
||||
|
||||
@ -69,9 +69,6 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
@Column(name="router_mac_address", updatable = false, nullable=false)
|
||||
private String routerMacAddress = "02:00:00:00:00:01";
|
||||
|
||||
@Column(name="guest_network_cidr")
|
||||
private String guestNetworkCidr = null;
|
||||
|
||||
@Column(name="domain_id")
|
||||
private Long domainId = null;
|
||||
|
||||
@ -174,21 +171,20 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
this.firewallProvider = firewallProvider;
|
||||
}
|
||||
|
||||
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);
|
||||
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
|
||||
this(name, description, dns1, dns2, dns3, dns4, domain, domainId, zoneType, zoneToken, domainSuffix, false);
|
||||
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) {
|
||||
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.internalDns1 = dns3;
|
||||
this.internalDns2 = dns4;
|
||||
this.guestNetworkCidr = guestCidr;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.networkType = zoneType;
|
||||
@ -309,17 +305,6 @@ public class DataCenterVO implements DataCenter, Identity {
|
||||
this.routerMacAddress = routerMacAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuestNetworkCidr()
|
||||
{
|
||||
return guestNetworkCidr;
|
||||
}
|
||||
|
||||
public void setGuestNetworkCidr(String guestNetworkCidr)
|
||||
{
|
||||
this.guestNetworkCidr = guestNetworkCidr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
|
||||
@ -2082,15 +2082,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
if (networks == null || networks.isEmpty()) {
|
||||
throw new CloudRuntimeException("Fail to create a network");
|
||||
} else {
|
||||
if (networks.size() > 1) {
|
||||
throw new InvalidParameterValueException("Cannot determine a guest network to deploy in, please specify one");
|
||||
}
|
||||
if (networks.size() > 0 && networks.get(0).getGuestType()== Network.GuestType.Isolated && networks.get(0).getTrafficType() == TrafficType.Guest) {
|
||||
Network defaultGuestNetwork = networks.get(0);
|
||||
for (Network nw : networks) {
|
||||
if (nw.getCidr() != null && nw.getCidr().equals(zone.getGuestNetworkCidr())) {
|
||||
defaultGuestNetwork = nw;
|
||||
}
|
||||
}
|
||||
network = defaultGuestNetwork;
|
||||
network = networks.get(0);
|
||||
} else {
|
||||
// For shared network
|
||||
network = networks.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +105,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (config.isSpecifiedCidr()) {
|
||||
return super.implement(config, offering, dest, context);
|
||||
}
|
||||
|
||||
DataCenter zone = dest.getDataCenter();
|
||||
NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), State.Allocated,
|
||||
config.getDataCenterId(), config.getPhysicalNetworkId());
|
||||
@ -131,8 +135,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
int offset = getVlanOffset(config.getPhysicalNetworkId(), vlanTag);
|
||||
|
||||
// Determine the new gateway and CIDR
|
||||
String[] oldCidr = config.getCidr().split("/");
|
||||
String oldCidrAddress = oldCidr[0];
|
||||
int cidrSize = getGloballyConfiguredCidrSize();
|
||||
|
||||
// If the offset has more bits than there is room for, return null
|
||||
@ -141,7 +143,8 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
throw new CloudRuntimeException("The offset " + offset + " needs " + bitsInOffset + " bits, but only have " + (cidrSize - 8) + " bits to work with.");
|
||||
}
|
||||
|
||||
long newCidrAddress = (NetUtils.ip2Long(oldCidrAddress) & 0xff000000) | (offset << (32 - cidrSize));
|
||||
// Use 10.1.1.1 which is reserved for private address
|
||||
long newCidrAddress = (NetUtils.ip2Long("10.1.1.1") & 0xff000000) | (offset << (32 - cidrSize));
|
||||
implemented.setGateway(NetUtils.long2Ip(newCidrAddress + 1));
|
||||
implemented.setCidr(NetUtils.long2Ip(newCidrAddress) + "/" + cidrSize);
|
||||
implemented.setState(State.Implemented);
|
||||
@ -197,6 +200,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
if (config.isSpecifiedCidr()) {
|
||||
return super.allocate(config, nic, vm);
|
||||
}
|
||||
|
||||
if (nic != null && nic.getRequestedIp() != null) {
|
||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||
}
|
||||
@ -224,6 +231,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.isSpecifiedCidr()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nic.setIp4Address(null);
|
||||
nic.setGateway(null);
|
||||
nic.setNetmask(null);
|
||||
@ -238,6 +249,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
|
||||
if (_ovsNetworkMgr.isOvsNetworkEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (config.isSpecifiedCidr()) {
|
||||
super.reserve(nic, config, vm, dest, context);
|
||||
return;
|
||||
}
|
||||
|
||||
DataCenter dc = _dcDao.findById(config.getDataCenterId());
|
||||
|
||||
nic.setBroadcastUri(config.getBroadcastUri());
|
||||
|
||||
@ -109,28 +109,16 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
}
|
||||
|
||||
if (userSpecified.getCidr() != null) {
|
||||
//TODO add cidr checking
|
||||
network.setCidr(userSpecified.getCidr());
|
||||
network.setGateway(userSpecified.getGateway());
|
||||
network.setSpecifiedCidr(true);
|
||||
} else {
|
||||
String guestNetworkCidr = dc.getGuestNetworkCidr();
|
||||
// guest network cidr can be null for Basic zone
|
||||
if (guestNetworkCidr != null) {
|
||||
String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1])));
|
||||
network.setCidr(guestNetworkCidr);
|
||||
}
|
||||
}
|
||||
|
||||
if (userSpecified.getBroadcastUri() != null) {
|
||||
network.setBroadcastUri(userSpecified.getBroadcastUri());
|
||||
network.setState(State.Setup);
|
||||
}
|
||||
} else {
|
||||
String guestNetworkCidr = dc.getGuestNetworkCidr();
|
||||
String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
network.setGateway(NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1])));
|
||||
network.setCidr(guestNetworkCidr);
|
||||
}
|
||||
|
||||
return network;
|
||||
@ -186,21 +174,23 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
|
||||
if (nic.getIp4Address() == null) {
|
||||
nic.setBroadcastUri(network.getBroadcastUri());
|
||||
nic.setIsolationUri(network.getBroadcastUri());
|
||||
nic.setGateway(network.getGateway());
|
||||
if (network.isSpecifiedCidr()) {
|
||||
nic.setBroadcastUri(network.getBroadcastUri());
|
||||
nic.setIsolationUri(network.getBroadcastUri());
|
||||
nic.setGateway(network.getGateway());
|
||||
|
||||
String guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
|
||||
if (guestIp == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + network, DataCenter.class, dc.getId());
|
||||
String guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
|
||||
if (guestIp == null) {
|
||||
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + network, DataCenter.class, dc.getId());
|
||||
}
|
||||
|
||||
nic.setIp4Address(guestIp);
|
||||
nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
|
||||
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
nic.setIp4Address(guestIp);
|
||||
nic.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
|
||||
nic.setFormat(AddressFormat.Ip4);
|
||||
|
||||
nic.setDns1(dc.getDns1());
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
nic.setStrategy(ReservationStrategy.Start);
|
||||
|
||||
@ -641,7 +641,6 @@ public class DatabaseConfig {
|
||||
String internalDns1 = _currentObjectParams.get("internalDns1");
|
||||
String internalDns2 = _currentObjectParams.get("internalDns2");
|
||||
//String vnetRange = _currentObjectParams.get("vnet");
|
||||
String guestNetworkCidr = _currentObjectParams.get("guestNetworkCidr");
|
||||
String networkType = _currentObjectParams.get("networktype");
|
||||
|
||||
// Check that all IPs are valid
|
||||
@ -658,11 +657,8 @@ public class DatabaseConfig {
|
||||
if (!IPRangeConfig.validOrBlankIP(internalDns2)) {
|
||||
printError(ipError + "internalDns2");
|
||||
}
|
||||
if (!IPRangeConfig.validCIDR(guestNetworkCidr)) {
|
||||
printError("Please enter a valid value for guestNetworkCidr");
|
||||
}
|
||||
|
||||
pzc.saveZone(false, id, name, dns1, dns2, internalDns1, internalDns2, guestNetworkCidr, networkType);
|
||||
pzc.saveZone(false, id, name, dns1, dns2, internalDns1, internalDns2, networkType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -82,14 +82,6 @@ public class PodZoneConfig {
|
||||
//get the guest network cidr and guest netmask from the zone
|
||||
// DataCenterVO dcVo = _dcDao.findById(dcId);
|
||||
|
||||
String guestNetworkCidr = IPRangeConfig.getGuestNetworkCidr(dcId);
|
||||
|
||||
if (guestNetworkCidr == null || guestNetworkCidr.isEmpty()) return "Please specify a valid guest cidr";
|
||||
String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
|
||||
String guestIpNetwork = NetUtils.getIpRangeStartIpFromCidr(cidrTuple[0], Long.parseLong(cidrTuple[1]));
|
||||
long guestCidrSize = Long.parseLong(cidrTuple[1]);
|
||||
|
||||
// Iterate through all pods in this zone
|
||||
for (Long podId : currentPodCidrSubnets.keySet()) {
|
||||
String podName;
|
||||
@ -101,20 +93,9 @@ public class PodZoneConfig {
|
||||
long cidrSize = ((Long) cidrPair.get(1)).longValue();
|
||||
|
||||
long cidrSizeToUse = -1;
|
||||
if (cidrSize < guestCidrSize) cidrSizeToUse = cidrSize;
|
||||
else cidrSizeToUse = guestCidrSize;
|
||||
cidrSizeToUse = cidrSize;
|
||||
|
||||
String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse);
|
||||
String guestSubnet = NetUtils.getCidrSubNet(guestIpNetwork, cidrSizeToUse);
|
||||
|
||||
// Check that cidrSubnet does not equal guestSubnet
|
||||
if (cidrSubnet.equals(guestSubnet)) {
|
||||
if (podName.equals("newPod")) {
|
||||
return "The subnet of the pod you are adding conflicts with the subnet of the Guest IP Network. Please specify a different CIDR.";
|
||||
} else {
|
||||
return "Warning: The subnet of pod " + podName + " in zone " + zoneName + " conflicts with the subnet of the Guest IP Network. Please change either the pod's CIDR or the Guest IP Network's subnet, and re-run install-vmops-management.";
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through the rest of the pods
|
||||
for (Long otherPodId : currentPodCidrSubnets.keySet()) {
|
||||
@ -261,7 +242,7 @@ public class PodZoneConfig {
|
||||
}
|
||||
|
||||
@DB
|
||||
public void saveZone(boolean printOutput, long id, String name, String dns1, String dns2, String dns3, String dns4, String guestNetworkCidr, String networkType) {
|
||||
public void saveZone(boolean printOutput, long id, String name, String dns1, String dns2, String dns3, String dns4, String networkType) {
|
||||
|
||||
if (printOutput) System.out.println("Saving zone, please wait...");
|
||||
|
||||
@ -296,11 +277,6 @@ public class PodZoneConfig {
|
||||
values += ",'" + dns4 + "'";
|
||||
}
|
||||
|
||||
if(guestNetworkCidr != null) {
|
||||
columns += ", guest_network_cidr";
|
||||
values += ",'" + guestNetworkCidr + "'";
|
||||
}
|
||||
|
||||
if(networkType != null) {
|
||||
columns += ", networktype";
|
||||
values += ",'" + networkType + "'";
|
||||
|
||||
@ -505,7 +505,6 @@ CREATE TABLE `cloud`.`data_center` (
|
||||
`netmask` varchar(15),
|
||||
`router_mac_address` varchar(17) NOT NULL DEFAULT '02:00:00:00:00:01' COMMENT 'mac address for the router within the domain',
|
||||
`mac_address` bigint unsigned NOT NULL DEFAULT '1' COMMENT 'Next available mac address for the ethernet card interacting with public internet',
|
||||
`guest_network_cidr` varchar(18),
|
||||
`domain` varchar(100) COMMENT 'Network domain name of the Vms of the zone',
|
||||
`domain_id` bigint unsigned COMMENT 'domain id for the parent domain to this zone (null signifies public zone)',
|
||||
`networktype` varchar(255) NOT NULL DEFAULT 'Basic' COMMENT 'Network type of the zone',
|
||||
|
||||
@ -152,6 +152,7 @@ ALTER TABLE `cloud`.`project_invitations` ADD CONSTRAINT `uc_project_invitations
|
||||
|
||||
ALTER TABLE `cloud`.`data_center` ADD COLUMN `uuid` varchar(40);
|
||||
ALTER TABLE `cloud`.`data_center` ADD CONSTRAINT `uc_data_center__uuid` UNIQUE (`uuid`);
|
||||
ALTER TABLE `cloud`.`data_center` DROP COLUMN `guest_network_cidr`;
|
||||
|
||||
ALTER TABLE `cloud`.`host` ADD COLUMN `uuid` varchar(40);
|
||||
ALTER TABLE `cloud`.`host` ADD CONSTRAINT `uc_host__uuid` UNIQUE (`uuid`);
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
<internalDns2>4.2.2.2</internalDns2>
|
||||
<netmask>255.255.255.0</netmask>
|
||||
<vnet>560-579</vnet>
|
||||
<guestNetworkCidr>10.1.1.0/24</guestNetworkCidr>
|
||||
<networktype>Advanced</networktype>
|
||||
</zone>
|
||||
</zones>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user