mirror of https://github.com/apache/cloudstack.git
bug 8862: added updateNetwork api command. Can update name/displayText only
This commit is contained in:
parent
7f12876be1
commit
718386a2b6
|
|
@ -58,6 +58,7 @@ public class EventTypes {
|
|||
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";
|
||||
public static final String EVENT_NETWORK_CREATE = "NETWORK.CREATE";
|
||||
public static final String EVENT_NETWORK_DELETE = "NETWORK.DELETE";
|
||||
public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE";
|
||||
|
||||
// Load Balancers
|
||||
public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
||||
public interface NetworkService {
|
||||
|
|
@ -74,4 +75,6 @@ public interface NetworkService {
|
|||
boolean isNetworkAvailableInDomain(long networkId, long domainId);
|
||||
|
||||
Long getDedicatedNetworkDomain(long networkId);
|
||||
|
||||
Network updateNetwork(long networkId, String name, String displayText, Account caller);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,8 @@ listNetworkOfferings=com.cloud.api.commands.ListNetworkOfferingsCmd;15
|
|||
createNetwork=com.cloud.api.commands.CreateNetworkCmd;15
|
||||
deleteNetwork=com.cloud.api.commands.DeleteNetworkCmd;15
|
||||
listNetworks=com.cloud.api.commands.ListNetworksCmd;15
|
||||
restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
|
||||
restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
|
||||
updateNetwork=com.cloud.api.commands.UpdateNetworkCmd;15
|
||||
|
||||
#### SSH key pair commands
|
||||
registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
|
||||
|
|
|
|||
|
|
@ -2717,4 +2717,35 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override @ActionEvent (eventType=EventTypes.EVENT_NETWORK_UPDATE, eventDescription="updating network", async=false)
|
||||
public Network updateNetwork(long networkId, String name, String displayText, 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");
|
||||
}
|
||||
|
||||
//Don't allow to update system network
|
||||
NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||
if (offering.isSystemOnly()) {
|
||||
throw new InvalidParameterValueException("Can't update system networks");
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(caller, network);
|
||||
|
||||
if (name != null) {
|
||||
network.setName(name);
|
||||
}
|
||||
|
||||
if (displayText != null) {
|
||||
network.setDisplayText(displayText);
|
||||
}
|
||||
|
||||
_networksDao.update(networkId, network);
|
||||
|
||||
return network;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue