bug 12964: createPhysicalNetwork/addTrafficType is no longer a part of createZone API

This commit is contained in:
Alena Prokharchyk 2012-01-10 13:54:40 -08:00
parent 3a6f94f108
commit b1c60b9d60
10 changed files with 35 additions and 54 deletions

View File

@ -30,6 +30,7 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.PhysicalNetworkResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.PhysicalNetwork;
@ -60,7 +61,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a physical network")
private Long domainId;
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]")
@Parameter(name=ApiConstants.BROADCAST_DOMAIN_RANGE, type=CommandType.STRING, description="the broadcast domain range for the physical network[Pod or Zone]. In Acton release it can be Zone only in Advance zone, and Pod in Basic")
private String broadcastDomainRange;
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")

View File

@ -118,5 +118,4 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
public String getEventType() {
return EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE;
}
}

View File

@ -19,6 +19,8 @@ package com.cloud.api.response;
import java.util.Date;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.api.ResponseObject;
@ -115,7 +117,9 @@ public class AsyncJobResponse extends BaseResponse {
this.jobInstanceId.setTableName("user_ip_address");
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.SecurityGroup.toString())) {
this.jobInstanceId.setTableName("security_group");
} else if (!jobInstanceType.equalsIgnoreCase(AsyncJob.Type.None.toString())){
} else if (jobInstanceType.equalsIgnoreCase(AsyncJob.Type.PhysicalNetwork.toString())) {
this.jobInstanceId.setTableName("physical_network");
}else if (!jobInstanceType.equalsIgnoreCase(AsyncJob.Type.None.toString())){
// TODO : when we hit here, we need to add instanceType -> UUID entity table mapping
assert(false);
}

View File

@ -22,7 +22,6 @@ import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class TrafficTypeResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="id of the network provider")

View File

@ -36,6 +36,7 @@ public interface AsyncJob extends Identity{
StoragePool,
IpAddress,
SecurityGroup,
PhysicalNetwork
}
Long getId();

View File

@ -84,7 +84,6 @@ import com.cloud.host.HostVO;
import com.cloud.host.Status;
import com.cloud.host.Status.Event;
import com.cloud.host.dao.HostDao;
import com.cloud.host.dao.HostDetailsDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorGuruManager;

View File

@ -19,7 +19,6 @@
package com.cloud.api.response;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@ -38,10 +37,6 @@ import com.cloud.api.ApiServer;
import com.cloud.api.BaseCmd;
import com.cloud.api.IdentityProxy;
import com.cloud.api.ResponseObject;
import com.cloud.api.ResponseObjectTypeAdapter;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.encoding.URLEncoder;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.uuididentity.dao.IdentityDao;

View File

@ -190,7 +190,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId, Long physicalNetworkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled, long physicalNetworkId) throws ConcurrentOperationException;
void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException;
HostPodVO getPod(long id);

View File

@ -1486,19 +1486,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
//Zone will be disabled since 3.0. Admin shoul enable it after physical network and providers setup.
zone.setAllocationState(Grouping.AllocationState.Disabled);
}
zone = _zoneDao.persist(zone);
// Create default Physical Network
long physicalNetworkId = createDefaultPhysicalNetwork(zone, domainId);
zone = _zoneDao.persist(zone);
//add VirtualRouter as the default network service provider
_networkMgr.addDefaultVirtualRouterToPhysicalNetwork(physicalNetworkId);
//add security group provider to the physical network
_networkMgr.addDefaultSecurityGroupProviderToPhysicalNetwork(physicalNetworkId);
// Create deafult networks
createDefaultNetworks(zone.getId(), isSecurityGroupEnabled, physicalNetworkId);
// Create default system networks
createDefaultSystemNetworks(zone.getId());
_swiftMgr.propagateSwiftTmplteOnZone(zone.getId());
txn.commit();
@ -1512,31 +1503,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
}
private long createDefaultPhysicalNetwork(DataCenter zone, Long domainId){
//create entry
String broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.POD.toString();
if(zone.getNetworkType() == NetworkType.Basic){
broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.POD.toString();
}else{
broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.ZONE.toString();
}
String pNtwkName = zone.getName() + "-pNtwk";
PhysicalNetwork defaultNetwork = _networkMgr.createPhysicalNetwork(zone.getId(), null, null, null, broadcastDomainRange, domainId, null, pNtwkName);
//String defaultXenLabel = "cloud-private";
//add default Traffic types to the physical network
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Guest.toString(), null, null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Public.toString(), null, null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Management.toString(), null, null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Storage.toString(), null, null, null, null, null);
return defaultNetwork.getId();
}
@Override
public void createDefaultNetworks(long zoneId, boolean isSecurityGroupEnabled, long physicalNetworkId) throws ConcurrentOperationException {
public void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException {
DataCenterVO zone = _zoneDao.findById(zoneId);
String networkDomain = null;
// Create public, management, control and storage networks as a part of
@ -1551,7 +1520,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
Account systemAccount = _accountDao.findById(Account.ACCOUNT_ID_SYSTEM);
BroadcastDomainType broadcastDomainType = null;
boolean isNetworkDefault = false;
if (offering.getTrafficType() == TrafficType.Management) {
broadcastDomainType = BroadcastDomainType.Native;
} else if (offering.getTrafficType() == TrafficType.Control) {

View File

@ -4226,7 +4226,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@DB
@ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_CREATE, eventDescription = "Creating Physical Network", create = true)
public PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String> isolationMethods, String broadcastDomainRangeStr, Long domainId, List<String> tags, String name) {
// Check if zone exists
// Check if zone exists
if (zoneId == null) {
throw new InvalidParameterValueException("Please specify a valid zone.");
}
@ -4235,8 +4236,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (zone == null) {
throw new InvalidParameterValueException("Please specify a valid zone.");
}
NetworkType zoneType = zone.getNetworkType();
if(zone.getNetworkType() == NetworkType.Basic){
if(zoneType == NetworkType.Basic){
if(!_physicalNetworkDao.listByZone(zoneId).isEmpty()){
throw new CloudRuntimeException("Cannot add the physical network to basic zone id: "+zoneId+", there is a physical network already existing in this basic Zone");
}
@ -4252,11 +4255,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
int vnetStart = 0;
int vnetEnd = 0;
if (vnetRange != null) {
//Verify zone type
if (zone.getNetworkType() == NetworkType.Basic
|| (zone.getNetworkType() == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
throw new InvalidParameterValueException("Can't add vnet range to the physical network in the zone that supports " + zone.getNetworkType() + " network, Security Group enabled: "+ zone.isSecurityGroupEnabled());
if (zoneType == NetworkType.Basic
|| (zoneType == NetworkType.Advanced && zone.isSecurityGroupEnabled())) {
throw new InvalidParameterValueException("Can't add vnet range to the physical network in the zone that supports " + zoneType + " network, Security Group enabled: "+ zone.isSecurityGroupEnabled());
}
String[] tokens = vnetRange.split("-");
@ -4284,10 +4286,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} catch (IllegalArgumentException ex) {
throw new InvalidParameterValueException("Unable to resolve broadcastDomainRange '" + broadcastDomainRangeStr + "' to a supported value {Pod or Zone}");
}
//in Acton release you can specify only Zone broadcastdomain type in Advance zone, and Pod in Basic
if (zoneType == NetworkType.Basic && broadcastDomainRange != null && broadcastDomainRange != BroadcastDomainRange.POD) {
throw new InvalidParameterValueException("Basic zone can have broadcast domain type of value " + BroadcastDomainRange.POD + " only");
} else if (zoneType == NetworkType.Advanced && broadcastDomainRange != null && broadcastDomainRange != BroadcastDomainRange.ZONE) {
throw new InvalidParameterValueException("Advance zone can have broadcast domain type of value " + BroadcastDomainRange.ZONE + " only");
}
}
if(broadcastDomainRange == null){
if(zone.getNetworkType() == NetworkType.Basic){
if(zoneType == NetworkType.Basic){
broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.POD;
}else{
broadcastDomainRange = PhysicalNetwork.BroadcastDomainRange.ZONE;
@ -4308,6 +4317,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (vnetRange != null) {
_dcDao.addVnet(zone.getId(), pNetwork.getId(), vnetStart, vnetEnd);
}
//add VirtualRouter as the default network service provider
addDefaultVirtualRouterToPhysicalNetwork(pNetwork.getId());
//add security group provider to the physical network
addDefaultSecurityGroupProviderToPhysicalNetwork(pNetwork.getId());
txn.commit();
return pNetwork;