bug 9651: update now also shows tags

This commit is contained in:
Alex Huang 2011-06-01 17:49:56 -07:00
parent 072fd1b1c5
commit bc67b2a973
3 changed files with 24 additions and 7 deletions

View File

@ -18,6 +18,8 @@
package com.cloud.api.commands;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
@ -44,12 +46,15 @@ public class UpdateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the network")
private Long id;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the new name for the network")
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the new name for the network")
private String name;
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the new display text for the network")
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the new display text for the network")
private String displayText;
@Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="tags for the network")
private List<String> tags;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -65,7 +70,11 @@ public class UpdateNetworkCmd extends BaseCmd {
public String getDisplayText() {
return displayText;
}
}
public List<String> getTags() {
return tags;
}
/////////////////////////////////////////////////////
@ -90,7 +99,7 @@ public class UpdateNetworkCmd extends BaseCmd {
@Override
public void execute() throws InsufficientCapacityException, ConcurrentOperationException{
Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), UserContext.current().getCaller());
Network result = _networkService.updateNetwork(getId(), getNetworkName(), getDisplayText(), tags, UserContext.current().getCaller());
if (result != null) {
NetworkResponse response = _responseGenerator.createNetworkResponse(result);
response.setResponseName(getCommandName());

View File

@ -81,7 +81,7 @@ public interface NetworkService {
Long getDedicatedNetworkDomain(long networkId);
Network updateNetwork(long networkId, String name, String displayText, Account caller);
Network updateNetwork(long networkId, String name, String displayText, List<String> tags, Account caller);
Integer getNetworkRate(long networkId, Long vmId);

View File

@ -2834,14 +2834,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = false)
public Network updateNetwork(long networkId, String name, String displayText, Account caller) {
public Network updateNetwork(long networkId, String name, String displayText, List<String> tags, Account caller) {
// verify input parameters
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system");
}
if (tags != null && tags.size() > 1) {
throw new InvalidParameterException("Unable to support more than one tag on network yet");
}
// Don't allow to update system network
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
if (offering.isSystemOnly()) {
@ -2857,6 +2861,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (displayText != null) {
network.setDisplayText(displayText);
}
if (tags != null) {
network.setTags(tags);
}
_networksDao.update(networkId, network);