bug 12483: Discard zone's cidr

status 12483: resolved fixed
This commit is contained in:
Sheng Yang 2011-12-14 17:23:11 -08:00
parent 255a6ae30f
commit ab50f65ed8
16 changed files with 59 additions and 196 deletions

View File

@ -47,9 +47,6 @@ public class CreateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone") @Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2; 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") @Parameter(name=ApiConstants.INTERNAL_DNS1, type=CommandType.STRING, required=true, description="the first internal DNS for the Zone")
private String internalDns1; private String internalDns1;
@ -87,10 +84,6 @@ public class CreateZoneCmd extends BaseCmd {
return dns2; return dns2;
} }
public String getGuestCidrAddress() {
return guestCidrAddress;
}
public String getInternalDns1() { public String getInternalDns1() {
return internalDns1; return internalDns1;
} }

View File

@ -50,9 +50,6 @@ public class UpdateZoneCmd extends BaseCmd {
@Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone") @Parameter(name=ApiConstants.DNS2, type=CommandType.STRING, description="the second DNS for the Zone")
private String dns2; 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") @IdentityMapper(entityTableName="data_center")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Zone") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Zone")
private Long id; private Long id;
@ -96,10 +93,6 @@ public class UpdateZoneCmd extends BaseCmd {
return dns2; return dns2;
} }
public String getGuestCidrAddress() {
return guestCidrAddress;
}
public Long getId() { public Long getId() {
return id; return id;
} }

View File

@ -49,9 +49,6 @@ public class ZoneResponse extends BaseResponse {
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan range of the zone") @SerializedName(ApiConstants.VLAN) @Param(description="the vlan range of the zone")
private String vlan; private String vlan;
@SerializedName(ApiConstants.GUEST_CIDR_ADDRESS) @Param(description="the guest CIDR address for the Zone")
private String guestCidrAddress;
//TODO - generate description //TODO - generate description
@SerializedName("status") @SerializedName("status")
private String status; private String status;
@ -147,14 +144,6 @@ public class ZoneResponse extends BaseResponse {
this.vlan = vlan; this.vlan = vlan;
} }
public String getGuestCidrAddress() {
return guestCidrAddress;
}
public void setGuestCidrAddress(String guestCidrAddress) {
this.guestCidrAddress = guestCidrAddress;
}
public String getStatus() { public String getStatus() {
return status; return status;
} }

View File

@ -37,7 +37,6 @@ public interface DataCenter extends Grouping {
long getId(); long getId();
String getDns1(); String getDns1();
String getDns2(); String getDns2();
String getGuestNetworkCidr();
String getName(); String getName();
Long getDomainId(); Long getDomainId();
String getDescription(); String getDescription();

View File

@ -856,7 +856,6 @@ public class ApiResponseHelper implements ResponseGenerator {
zoneResponse.setInternalDns1(dataCenter.getInternalDns1()); zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
zoneResponse.setInternalDns2(dataCenter.getInternalDns2()); zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
// FIXME zoneResponse.setVlan(dataCenter.get.getVnet()); // FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
} }
if (showCapacities != null && showCapacities){ if (showCapacities != null && showCapacities){

View File

@ -114,7 +114,6 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
* @param dns2 * @param dns2
* @param internalDns1 * @param internalDns1
* @param internalDns2 * @param internalDns2
* @param guestCidr
* @param zoneType * @param zoneType
* @param allocationState * @param allocationState
* @param networkDomain TODO * @param networkDomain TODO
@ -123,7 +122,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
* @throws * @throws
* @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. * Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated IP addresses.

View File

@ -1279,7 +1279,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String dns2 = cmd.getDns2(); String dns2 = cmd.getDns2();
String internalDns1 = cmd.getInternalDns1(); String internalDns1 = cmd.getInternalDns1();
String internalDns2 = cmd.getInternalDns2(); String internalDns2 = cmd.getInternalDns2();
String guestCidr = cmd.getGuestCidrAddress();
List<String> dnsSearchOrder = cmd.getDnsSearchOrder(); List<String> dnsSearchOrder = cmd.getDnsSearchOrder();
Boolean isPublic = cmd.isPublic(); Boolean isPublic = cmd.isPublic();
String allocationStateStr = cmd.getAllocationState(); String allocationStateStr = cmd.getAllocationState();
@ -1330,10 +1329,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
zoneName = zone.getName(); zoneName = zone.getName();
} }
if ((guestCidr != null) && !NetUtils.validateGuestCidr(guestCidr)) {
throw new InvalidParameterValueException("Please enter a valid guest cidr");
}
// Make sure the zone exists // Make sure the zone exists
if (!validZone(zoneId)) { if (!validZone(zoneId)) {
throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist."); throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist.");
@ -1357,10 +1352,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
internalDns1 = zone.getInternalDns1(); internalDns1 = zone.getInternalDns1();
} }
if (guestCidr == null) {
guestCidr = zone.getGuestNetworkCidr();
}
// validate network domain // validate network domain
if (networkDomain != null) { if (networkDomain != null) {
if (!NetUtils.verifyDomainName(networkDomain)) { if (!NetUtils.verifyDomainName(networkDomain)) {
@ -1389,7 +1380,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
zone.setDns2(dns2); zone.setDns2(dns2);
zone.setInternalDns1(internalDns1); zone.setInternalDns1(internalDns1);
zone.setInternalDns2(internalDns2); zone.setInternalDns2(internalDns2);
zone.setGuestNetworkCidr(guestCidr);
zone.setDomain(networkDomain); zone.setDomain(networkDomain);
// update a private zone to public; not vice versa // update a private zone to public; not vice versa
@ -1428,15 +1418,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
@Override @Override
@DB @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) { NetworkType zoneType, String allocationStateStr, String networkDomain, boolean isSecurityGroupEnabled) {
// checking the following params outside checkzoneparams method as we do // checking the following params outside checkzoneparams method as we do
// not use these params for updatezone // not use these params for updatezone
// hence the method below is generic to check for common params // 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 // Validate network domain
if (networkDomain != null) { if (networkDomain != null) {
@ -1455,7 +1442,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
try { try {
txn.start(); txn.start();
// Create the new zone in the database // 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()) { if (allocationStateStr != null && !allocationStateStr.isEmpty()) {
Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr); Grouping.AllocationState allocationState = Grouping.AllocationState.valueOf(allocationStateStr);
zone.setAllocationState(allocationState); zone.setAllocationState(allocationState);
@ -1554,7 +1541,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String dns2 = cmd.getDns2(); String dns2 = cmd.getDns2();
String internalDns1 = cmd.getInternalDns1(); String internalDns1 = cmd.getInternalDns1();
String internalDns2 = cmd.getInternalDns2(); String internalDns2 = cmd.getInternalDns2();
String guestCidr = cmd.getGuestCidrAddress();
Long domainId = cmd.getDomainId(); Long domainId = cmd.getDomainId();
String type = cmd.getNetworkType(); String type = cmd.getNetworkType();
Boolean isBasic = false; Boolean isBasic = false;
@ -1574,14 +1560,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
NetworkType zoneType = isBasic ? NetworkType.Basic : NetworkType.Advanced; 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; DomainVO domainVO = null;
if (userId == null) { if (userId == null) {
@ -1596,7 +1574,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
isSecurityGroupEnabled = true; 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); isSecurityGroupEnabled);
} }
@ -2279,30 +2257,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask); String newVlanSubnet = NetUtils.getSubNet(vlanGateway, vlanNetmask);
// Check if the new VLAN's subnet conflicts with the guest network in // TODO: Check if the new VLAN's subnet conflicts with the guest network in
// the specified zone (guestCidr is null for basic // the specified zone (guestCidr is null for basic zone)
// 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.");
}
}
// Check if there are any errors with the IP range // Check if there are any errors with the IP range
checkPublicIpRangeErrors(zoneId, vlanId, vlanGateway, vlanNetmask, startIP, endIP); 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 // 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 // 2. The pod's CIDR subnet conflicts with the CIDR subnet of any other
// pod // 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]);
}
String zoneName = getZoneName(dcId);
// Iterate through all pods in this zone // Iterate through all pods in this zone
String zoneName = getZoneName(dcId);
for (Long podId : currentPodCidrSubnets.keySet()) { for (Long podId : currentPodCidrSubnets.keySet()) {
String podName; String podName;
if (podId.longValue() == -1) { if (podId.longValue() == -1) {
@ -2730,26 +2676,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
long cidrSize = ((Long) cidrPair.get(1)).longValue(); long cidrSize = ((Long) cidrPair.get(1)).longValue();
long cidrSizeToUse = -1; long cidrSizeToUse = -1;
if (guestCidrSize == null || cidrSize < guestCidrSize) { cidrSizeToUse = cidrSize;
cidrSizeToUse = cidrSize;
} else {
cidrSizeToUse = guestCidrSize;
}
String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse); String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse);
if (guestNetworkCidr != null) { //TODO add checking for CIDR of guest network in this data center
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.");
}
}
}
// Iterate through the rest of the pods // Iterate through the rest of the pods
for (Long otherPodId : currentPodCidrSubnets.keySet()) { for (Long otherPodId : currentPodCidrSubnets.keySet()) {

View File

@ -69,9 +69,6 @@ public class DataCenterVO implements DataCenter, Identity {
@Column(name="router_mac_address", updatable = false, nullable=false) @Column(name="router_mac_address", updatable = false, nullable=false)
private String routerMacAddress = "02:00:00:00:00:01"; private String routerMacAddress = "02:00:00:00:00:01";
@Column(name="guest_network_cidr")
private String guestNetworkCidr = null;
@Column(name="domain_id") @Column(name="domain_id")
private Long domainId = null; private Long domainId = null;
@ -174,21 +171,20 @@ public class DataCenterVO implements DataCenter, Identity {
this.firewallProvider = firewallProvider; 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) { 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, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false); this(name, description, dns1, dns2, dns3, dns4, domain, domainId, zoneType, zoneToken, domainSuffix, false);
this.id = id; this.id = id;
this.allocationState = Grouping.AllocationState.Enabled; this.allocationState = Grouping.AllocationState.Enabled;
this.uuid = UUID.randomUUID().toString(); 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.name = name;
this.description = description; this.description = description;
this.dns1 = dns1; this.dns1 = dns1;
this.dns2 = dns2; this.dns2 = dns2;
this.internalDns1 = dns3; this.internalDns1 = dns3;
this.internalDns2 = dns4; this.internalDns2 = dns4;
this.guestNetworkCidr = guestCidr;
this.domain = domain; this.domain = domain;
this.domainId = domainId; this.domainId = domainId;
this.networkType = zoneType; this.networkType = zoneType;
@ -309,17 +305,6 @@ public class DataCenterVO implements DataCenter, Identity {
this.routerMacAddress = routerMacAddress; this.routerMacAddress = routerMacAddress;
} }
@Override
public String getGuestNetworkCidr()
{
return guestNetworkCidr;
}
public void setGuestNetworkCidr(String guestNetworkCidr)
{
this.guestNetworkCidr = guestNetworkCidr;
}
@Override @Override
public String getDomain() { public String getDomain() {
return domain; return domain;

View File

@ -2082,15 +2082,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (networks == null || networks.isEmpty()) { if (networks == null || networks.isEmpty()) {
throw new CloudRuntimeException("Fail to create a network"); throw new CloudRuntimeException("Fail to create a network");
} else { } 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) { if (networks.size() > 0 && networks.get(0).getGuestType()== Network.GuestType.Isolated && networks.get(0).getTrafficType() == TrafficType.Guest) {
Network defaultGuestNetwork = networks.get(0); network = networks.get(0);
for (Network nw : networks) {
if (nw.getCidr() != null && nw.getCidr().equals(zone.getGuestNetworkCidr())) {
defaultGuestNetwork = nw;
}
}
network = defaultGuestNetwork;
} else { } else {
// For shared network
network = networks.get(0); network = networks.get(0);
} }
} }

View File

@ -104,6 +104,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
if (_ovsNetworkMgr.isOvsNetworkEnabled() || _tunnelMgr.isOvsTunnelEnabled()) { if (_ovsNetworkMgr.isOvsNetworkEnabled() || _tunnelMgr.isOvsTunnelEnabled()) {
return null; return null;
} }
if (config.isSpecifiedCidr()) {
return super.implement(config, offering, dest, context);
}
DataCenter zone = dest.getDataCenter(); DataCenter zone = dest.getDataCenter();
NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), State.Allocated, NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), State.Allocated,
@ -131,8 +135,6 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
int offset = getVlanOffset(config.getPhysicalNetworkId(), vlanTag); int offset = getVlanOffset(config.getPhysicalNetworkId(), vlanTag);
// Determine the new gateway and CIDR // Determine the new gateway and CIDR
String[] oldCidr = config.getCidr().split("/");
String oldCidrAddress = oldCidr[0];
int cidrSize = getGloballyConfiguredCidrSize(); int cidrSize = getGloballyConfiguredCidrSize();
// If the offset has more bits than there is room for, return null // 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."); 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.setGateway(NetUtils.long2Ip(newCidrAddress + 1));
implemented.setCidr(NetUtils.long2Ip(newCidrAddress) + "/" + cidrSize); implemented.setCidr(NetUtils.long2Ip(newCidrAddress) + "/" + cidrSize);
implemented.setState(State.Implemented); implemented.setState(State.Implemented);
@ -196,6 +199,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
@Override @Override
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException { InsufficientAddressCapacityException {
if (config.isSpecifiedCidr()) {
return super.allocate(config, nic, vm);
}
if (nic != null && nic.getRequestedIp() != null) { if (nic != null && nic.getRequestedIp() != null) {
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
@ -223,6 +230,10 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
if (_ovsNetworkMgr.isOvsNetworkEnabled() || _tunnelMgr.isOvsTunnelEnabled()) { if (_ovsNetworkMgr.isOvsNetworkEnabled() || _tunnelMgr.isOvsTunnelEnabled()) {
return; return;
} }
if (config.isSpecifiedCidr()) {
return;
}
nic.setIp4Address(null); nic.setIp4Address(null);
nic.setGateway(null); nic.setGateway(null);
@ -238,6 +249,11 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
if (_ovsNetworkMgr.isOvsNetworkEnabled()) { if (_ovsNetworkMgr.isOvsNetworkEnabled()) {
return; return;
} }
if (config.isSpecifiedCidr()) {
super.reserve(nic, config, vm, dest, context);
return;
}
DataCenter dc = _dcDao.findById(config.getDataCenterId()); DataCenter dc = _dcDao.findById(config.getDataCenterId());
nic.setBroadcastUri(config.getBroadcastUri()); nic.setBroadcastUri(config.getBroadcastUri());

View File

@ -109,28 +109,16 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
} }
if (userSpecified.getCidr() != null) { if (userSpecified.getCidr() != null) {
//TODO add cidr checking
network.setCidr(userSpecified.getCidr()); network.setCidr(userSpecified.getCidr());
network.setGateway(userSpecified.getGateway()); network.setGateway(userSpecified.getGateway());
network.setSpecifiedCidr(true); 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) { if (userSpecified.getBroadcastUri() != null) {
network.setBroadcastUri(userSpecified.getBroadcastUri()); network.setBroadcastUri(userSpecified.getBroadcastUri());
network.setState(State.Setup); 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; return network;
@ -186,21 +174,23 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
DataCenter dc = _dcDao.findById(network.getDataCenterId()); DataCenter dc = _dcDao.findById(network.getDataCenterId());
if (nic.getIp4Address() == null) { if (nic.getIp4Address() == null) {
nic.setBroadcastUri(network.getBroadcastUri()); if (network.isSpecifiedCidr()) {
nic.setIsolationUri(network.getBroadcastUri()); nic.setBroadcastUri(network.getBroadcastUri());
nic.setGateway(network.getGateway()); nic.setIsolationUri(network.getBroadcastUri());
nic.setGateway(network.getGateway());
String guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp()); String guestIp = _networkMgr.acquireGuestIpAddress(network, nic.getRequestedIp());
if (guestIp == null) { if (guestIp == null) {
throw new InsufficientVirtualNetworkCapcityException("Unable to acquire guest IP address for network " + network, DataCenter.class, dc.getId()); 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.setFormat(AddressFormat.Ip4);
nic.setDns1(dc.getDns1());
nic.setDns2(dc.getDns2());
} }
nic.setStrategy(ReservationStrategy.Start); nic.setStrategy(ReservationStrategy.Start);

View File

@ -641,7 +641,6 @@ public class DatabaseConfig {
String internalDns1 = _currentObjectParams.get("internalDns1"); String internalDns1 = _currentObjectParams.get("internalDns1");
String internalDns2 = _currentObjectParams.get("internalDns2"); String internalDns2 = _currentObjectParams.get("internalDns2");
//String vnetRange = _currentObjectParams.get("vnet"); //String vnetRange = _currentObjectParams.get("vnet");
String guestNetworkCidr = _currentObjectParams.get("guestNetworkCidr");
String networkType = _currentObjectParams.get("networktype"); String networkType = _currentObjectParams.get("networktype");
// Check that all IPs are valid // Check that all IPs are valid
@ -658,11 +657,8 @@ public class DatabaseConfig {
if (!IPRangeConfig.validOrBlankIP(internalDns2)) { if (!IPRangeConfig.validOrBlankIP(internalDns2)) {
printError(ipError + "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);
} }

View File

@ -82,14 +82,6 @@ public class PodZoneConfig {
//get the guest network cidr and guest netmask from the zone //get the guest network cidr and guest netmask from the zone
// DataCenterVO dcVo = _dcDao.findById(dcId); // 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 // Iterate through all pods in this zone
for (Long podId : currentPodCidrSubnets.keySet()) { for (Long podId : currentPodCidrSubnets.keySet()) {
String podName; String podName;
@ -101,20 +93,9 @@ public class PodZoneConfig {
long cidrSize = ((Long) cidrPair.get(1)).longValue(); long cidrSize = ((Long) cidrPair.get(1)).longValue();
long cidrSizeToUse = -1; long cidrSizeToUse = -1;
if (cidrSize < guestCidrSize) cidrSizeToUse = cidrSize; cidrSizeToUse = cidrSize;
else cidrSizeToUse = guestCidrSize;
String cidrSubnet = NetUtils.getCidrSubNet(cidrAddress, cidrSizeToUse); 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 // Iterate through the rest of the pods
for (Long otherPodId : currentPodCidrSubnets.keySet()) { for (Long otherPodId : currentPodCidrSubnets.keySet()) {
@ -261,7 +242,7 @@ public class PodZoneConfig {
} }
@DB @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..."); if (printOutput) System.out.println("Saving zone, please wait...");
@ -296,11 +277,6 @@ public class PodZoneConfig {
values += ",'" + dns4 + "'"; values += ",'" + dns4 + "'";
} }
if(guestNetworkCidr != null) {
columns += ", guest_network_cidr";
values += ",'" + guestNetworkCidr + "'";
}
if(networkType != null) { if(networkType != null) {
columns += ", networktype"; columns += ", networktype";
values += ",'" + networkType + "'"; values += ",'" + networkType + "'";

View File

@ -505,7 +505,6 @@ CREATE TABLE `cloud`.`data_center` (
`netmask` varchar(15), `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', `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', `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` 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)', `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', `networktype` varchar(255) NOT NULL DEFAULT 'Basic' COMMENT 'Network type of the zone',

View File

@ -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 COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`data_center` ADD CONSTRAINT `uc_data_center__uuid` UNIQUE (`uuid`); 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 COLUMN `uuid` varchar(40);
ALTER TABLE `cloud`.`host` ADD CONSTRAINT `uc_host__uuid` UNIQUE (`uuid`); ALTER TABLE `cloud`.`host` ADD CONSTRAINT `uc_host__uuid` UNIQUE (`uuid`);

View File

@ -20,7 +20,6 @@
<internalDns2>4.2.2.2</internalDns2> <internalDns2>4.2.2.2</internalDns2>
<netmask>255.255.255.0</netmask> <netmask>255.255.255.0</netmask>
<vnet>560-579</vnet> <vnet>560-579</vnet>
<guestNetworkCidr>10.1.1.0/24</guestNetworkCidr>
<networktype>Advanced</networktype> <networktype>Advanced</networktype>
</zone> </zone>
</zones> </zones>