Removing isolationMethods from UpdatePhysicalNetwork API.

This commit is contained in:
prachi 2011-10-25 11:39:41 -07:00
parent 780e0efe79
commit 07591807af
5 changed files with 27 additions and 29 deletions

View File

@ -29,6 +29,7 @@ import com.cloud.api.response.VlanIpRangeResponse;
import com.cloud.dc.Vlan;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@ -78,6 +79,20 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="the network id")
private Long networkID;
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID")
private Long physicalNetworkId;
public Long getPhysicalNetworkId() {
if (physicalNetworkId != null) {
return physicalNetworkId;
} else if (zoneId != null) {
return _networkService.translateZoneToPhysicalNetwork(zoneId);
} else {
throw new InvalidParameterValueException("Either zoneId or physicalNetworkId have to be specified");
}
}
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

View File

@ -52,9 +52,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="Tag the physical network")
private List<String> tags;
@Parameter(name=ApiConstants.ISOLATION_METHODS, type=CommandType.LIST, collectionType=CommandType.STRING, description="the isolation method for the physical network[VLAN/L3/GRE]")
private List<String> isolationMethods;
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="Enabled/Disabled")
private String state;
@ -69,10 +66,6 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
return tags;
}
public List<String> getIsolationMethods() {
return isolationMethods;
}
public String getNetworkSpeed() {
return speed;
}
@ -105,7 +98,7 @@ public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd {
@Override
public void execute(){
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getIsolationMethods(), getTags(), getVlan(), getState());
PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(),getNetworkSpeed(), getTags(), getVlan(), getState());
if (result != null) {
PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
response.setResponseName(getCommandName());

View File

@ -92,7 +92,7 @@ public interface NetworkService {
List<? extends PhysicalNetwork> searchPhysicalNetworks(Long id, Long zoneId, String keyword, Long startIndex, Long pageSize);
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> isolationMethods, List<String> tags, String newVnetRangeString, String state);
PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state);
boolean deletePhysicalNetwork(Long id);

View File

@ -3573,7 +3573,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_UPDATE, eventDescription = "updating physical network", async = true)
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> isolationMethods, List<String> tags, String newVnetRangeString, String state) {
public PhysicalNetwork updatePhysicalNetwork(Long id, String networkSpeed, List<String> tags, String newVnetRangeString, String state) {
// verify input parameters
PhysicalNetworkVO network = _physicalNetworkDao.findById(id);
@ -3585,10 +3585,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
throw new InvalidParameterException("Unable to support more than one tag on network yet");
}
if (isolationMethods != null && isolationMethods.size() > 1) {
throw new InvalidParameterException("Only one isolationMethod can be specified for a physical network at this time");
}
PhysicalNetwork.State networkState = null;
if (state != null && !state.isEmpty()) {
try {
@ -3606,21 +3602,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
network.setTags(tags);
}
if (isolationMethods != null) {
for(String isMethod : isolationMethods){
PhysicalNetwork.IsolationMethod isolationMethodVal = null;
if (isMethod != null && !isMethod.isEmpty()) {
try {
isolationMethodVal = PhysicalNetwork.IsolationMethod.valueOf(isMethod.toUpperCase());
} catch (IllegalArgumentException ex) {
throw new InvalidParameterValueException("Unable to resolve IsolationMethod '" + isMethod + "' to a supported value {VLAN or L3 or GRE}");
}
}
}
network.setIsolationMethods(isolationMethods);
}
if(networkSpeed != null){
network.setSpeed(networkSpeed);
}

View File

@ -1806,6 +1806,15 @@ CREATE TABLE `cloud`.`physical_network_traffic_types` (
UNIQUE KEY(`physical_network_id`, `traffic_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`traffic_type_details` (
`id` bigint unsigned NOT NULL auto_increment,
`traffic_type_id` bigint unsigned NOT NULL COMMENT 'traffic_type id',
`name` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_traffic_type_details__traffic_type_id` FOREIGN KEY (`traffic_type_id`) REFERENCES `physical_network_traffic_types`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`physical_network_service_providers` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',