bug 7957: set network domain for domain router based on Network networkDomain parameter. Default networkDomain is "cloud.internal"

status 7957: resolved fixed
This commit is contained in:
alena 2011-01-13 10:58:39 -08:00
parent 3b3aa07a6f
commit 877741030c
10 changed files with 52 additions and 12 deletions

View File

@ -76,6 +76,9 @@ public class CreateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise")
private Boolean isDefault;
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
private String networkDomain;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -132,6 +135,9 @@ public class CreateNetworkCmd extends BaseCmd {
return isDefault;
}
public String getNetworkDomain() {
return networkDomain;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -91,7 +91,10 @@ public class NetworkResponse extends BaseResponse{
@SerializedName("service") @Param(description="the list of services", responseObject = ServiceResponse.class)
private List<ServiceResponse> services;
@SerializedName("networkdomain") @Param(description="the network domain")
private String networkDomain;
public Long getId() {
return id;
}
@ -315,4 +318,13 @@ public class NetworkResponse extends BaseResponse{
public void setIsDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
public String getNetworkDomain() {
return networkDomain;
}
public void setNetworkDomain(String networkDomain) {
this.networkDomain = networkDomain;
}
}

View File

@ -203,5 +203,7 @@ public interface Network extends ControlledEntity {
String getReservationId();
boolean isDefault();
String getNetworkDomain();
}

View File

@ -102,9 +102,11 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
long domainId,
long accountId,
long networkConfigurationId,
boolean haEnabled) {
boolean haEnabled,
String networkDomain) {
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.networkId = networkConfigurationId;
this.domain = networkDomain;
}
public void setGateway(String gateway) {

View File

@ -2234,6 +2234,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setRelated(network.getRelated());
response.setDns1(network.getDns1());
response.setDns2(network.getDns2());
response.setNetworkDomain(network.getNetworkDomain());
//populate capability
Map<Service, Map<Capability, String>> serviceCapabilitiesMap = ApiDBUtils.getZoneCapabilities(network.getDataCenterId());

View File

@ -58,7 +58,7 @@ public enum Config {
GuestVlanBits("Network", ManagementServer.class, Integer.class, "guest.vlan.bits", "12", "The number of bits to reserve for the VLAN identifier in the guest subnet.", null),
MulticastThrottlingRate("Network", ManagementServer.class, Integer.class, "multicast.throttling.rate", "10", "Default multicast rate in megabits per second allowed.", null),
NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed.", null),
GuestDomainSuffix("Network", AgentManager.class, String.class, "guest.domain.suffix", "cloud-test.cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", null),
GuestDomainSuffix("Network", AgentManager.class, String.class, "guest.domain.suffix", "cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", null),
DirectNetworkNoDefaultRoute("Network", ManagementServer.class, Boolean.class, "direct.network.no.default.route", "false", "Direct Network Dhcp Server should not send a default route", "true/false"),
OvsNetwork("Network", ManagementServer.class, Boolean.class, "open.vswitch.network", "false", "enable/disable open vswitch network", null),

View File

@ -185,6 +185,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
int _networkGcWait;
int _networkGcInterval;
String _networkDomain;
private Map<String, String> _configs;
@ -685,6 +686,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Integer multicastRateMbps = getIntegerConfigValue(Config.MulticastThrottlingRate.key(), null);
_networkGcWait = NumbersUtil.parseInt(_configs.get(Config.NetworkGcWait.key()), 600);
_networkGcInterval = NumbersUtil.parseInt(_configs.get(Config.NetworkGcInterval.key()), 600);
_configs = _configDao.getConfiguration("Network", params);
_networkDomain = _configs.get(Config.GuestDomainSuffix.key());
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public);
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
@ -1288,6 +1292,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
String startIP = cmd.getStartIp();
String endIP = cmd.getEndIp();
String netmask = cmd.getNetmask();
String networkDomain = cmd.getNetworkDomain();
String cidr = null;
Boolean isDefault = cmd.isDefault();
if (gateway != null && netmask != null) {
@ -1324,6 +1329,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
//If networkDomain is not specified, take it from the global configuration
if (networkDomain == null) {
networkDomain = _networkDomain;
}
//Check if zone exists
if (zoneId == null || ((_dcDao.findById(zoneId)) == null)) {
throw new InvalidParameterValueException("Please specify a valid zone.");
@ -1356,6 +1366,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
//Create network
DataCenterDeployment plan = new DataCenterDeployment(zoneId, null, null, null);
NetworkVO userNetwork = new NetworkVO();
userNetwork.setNetworkDomain(networkDomain);
//cidr should be set only when the user is admin
if (ctxAccount.getType() == Account.ACCOUNT_TYPE_ADMIN) {

View File

@ -171,6 +171,7 @@ public class NetworkVO implements Network {
this.broadcastDomainType = that.getBroadcastDomainType();
this.guruName = guruName;
this.state = that.getState();
this.networkDomain = that.getNetworkDomain();
if (state == null) {
state = State.Allocated;
}
@ -284,6 +285,7 @@ public class NetworkVO implements Network {
this.broadcastDomainType = broadcastDomainType;
}
@Override
public String getNetworkDomain() {
return networkDomain;
}

View File

@ -117,6 +117,10 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
network.setBroadcastUri(userSpecified.getBroadcastUri());
network.setState(State.Setup);
}
if (userSpecified.getNetworkDomain() != null) {
network.setNetworkDomain(userSpecified.getNetworkDomain());
}
} else {
String guestNetworkCidr = dc.getGuestNetworkCidr();
String[] cidrTuple = guestNetworkCidr.split("\\/");

View File

@ -72,9 +72,9 @@ import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.configuration.dao.ResourceLimitDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.AccountVlanMapDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao;
@ -104,18 +104,18 @@ import com.cloud.network.IPAddressVO;
import com.cloud.network.IpAddress;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.Network;
import com.cloud.network.Network.GuestIpType;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.network.SshKeysDistriMonitor;
import com.cloud.network.VirtualNetworkApplianceService;
import com.cloud.network.VpnUser;
import com.cloud.network.VpnUserVO;
import com.cloud.network.Network.GuestIpType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.addr.PublicIp;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
@ -126,8 +126,8 @@ import com.cloud.network.dao.NetworkRuleConfigDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.VpnUserDao;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
import com.cloud.network.lb.LoadBalancingRulesManager;
import com.cloud.network.ovs.GreTunnelException;
import com.cloud.network.ovs.OvsNetworkManager;
import com.cloud.network.router.VirtualRouter.Role;
@ -176,11 +176,11 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachineGuru;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineName;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.UserVmDao;
@ -1026,7 +1026,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(),
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA(), guestNetwork.getNetworkDomain());
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
if(router != null){
EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ROUTER_CREATE, "successfully create router : " + router.getName(), startEventId);
@ -1090,7 +1090,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(),
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA());
_template.getHypervisorType(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), _offering.getOfferHA(), guestNetwork.getNetworkDomain());
router.setRole(Role.DHCP_USERDATA);
router = _itMgr.allocate(router, _template, _offering, networks, plan, null, owner);
if(router != null){