CLOUDSTACK-6597: Updatevm - root admin should be allowed to change instance name

(cherry picked from commit 18c6ae0796)

Conflicts:
	api/src/com/cloud/event/EventTypes.java
This commit is contained in:
Nitin Mehta 2014-05-27 14:55:22 -07:00 committed by Daan Hoogland
parent 34f3a5fd44
commit adfb44ec33
8 changed files with 49 additions and 27 deletions

View File

@ -19,6 +19,16 @@ package com.cloud.event;
import java.util.HashMap;
import java.util.Map;
import com.cloud.network.IpAddress;
import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.HealthCheckPolicy;
import com.cloud.network.rules.StickinessPolicy;
import com.cloud.network.vpc.NetworkACL;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.server.ResourceTag;
import com.cloud.vm.ConsoleProxy;
import com.cloud.vm.SecondaryStorageVm;
import org.apache.cloudstack.config.Configuration;
import com.cloud.dc.DataCenter;
@ -32,7 +42,6 @@ import com.cloud.network.Network;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.PhysicalNetworkTrafficType;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.network.Site2SiteCustomerGateway;
import com.cloud.network.Site2SiteVpnConnection;
@ -549,24 +558,21 @@ public class EventTypes {
entityEventDetails.put(EVENT_NETWORK_DELETE, Network.class);
entityEventDetails.put(EVENT_NETWORK_UPDATE, Network.class);
entityEventDetails.put(EVENT_NETWORK_RESTART, Network.class);
entityEventDetails.put(EVENT_NET_IP_ASSIGN, PublicIpAddress.class);
entityEventDetails.put(EVENT_PORTABLE_IP_ASSIGN, PublicIpAddress.class);
entityEventDetails.put(EVENT_PORTABLE_IP_RELEASE, PublicIpAddress.class);
entityEventDetails.put(EVENT_NET_IP_RELEASE, PublicIpAddress.class);
entityEventDetails.put(EVENT_NET_IP_ASSIGN, IpAddress.class);
entityEventDetails.put(EVENT_PORTABLE_IP_ASSIGN, IpAddress.class);
entityEventDetails.put(EVENT_PORTABLE_IP_RELEASE, IpAddress.class);
entityEventDetails.put(EVENT_NET_IP_RELEASE, IpAddress.class);
entityEventDetails.put(EVENT_NET_RULE_ADD, FirewallRule.class);
entityEventDetails.put(EVENT_NET_RULE_DELETE, FirewallRule.class);
entityEventDetails.put(EVENT_NET_RULE_MODIFY, FirewallRule.class);
entityEventDetails.put(EVENT_FIREWALL_OPEN, FirewallRule.class);
entityEventDetails.put(EVENT_FIREWALL_CLOSE, FirewallRule.class);
entityEventDetails.put(EVENT_FIREWALL_EGRESS_OPEN, FirewallRule.class);
entityEventDetails.put(EVENT_FIREWALL_EGRESS_CLOSE, FirewallRule.class);
entityEventDetails.put(EVENT_FIREWALL_EGRESS_UPDATE, FirewallRule.class);
// Load Balancers
entityEventDetails.put(EVENT_ASSIGN_TO_LOAD_BALANCER_RULE, FirewallRule.class);
entityEventDetails.put(EVENT_REMOVE_FROM_LOAD_BALANCER_RULE, FirewallRule.class);
entityEventDetails.put(EVENT_LOAD_BALANCER_CREATE, LoadBalancer.class);
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, FirewallRule.class);
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, LoadBalancer.class);
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_CREATE, StickinessPolicy.class);
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_UPDATE, StickinessPolicy.class);
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_DELETE, StickinessPolicy.class);
@ -714,12 +720,12 @@ public class EventTypes {
entityEventDetails.put(EVENT_VPN_USER_REMOVE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_CREATE, Site2SiteVpnGateway.class);
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_DELETE, Site2SiteVpnGateway.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, Site2SiteCustomerGateway.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, Site2SiteCustomerGateway.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, Site2SiteCustomerGateway.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, Site2SiteVpnConnection.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, Site2SiteVpnConnection.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, Site2SiteVpnConnection.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, RemoteAccessVpn.class);
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, RemoteAccessVpn.class);
// Custom certificates
entityEventDetails.put(EVENT_UPLOAD_CUSTOM_CERTIFICATE, "Certificate");
@ -776,6 +782,15 @@ public class EventTypes {
entityEventDetails.put(EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE, PhysicalNetwork.class);
entityEventDetails.put(EVENT_EXTERNAL_FIREWALL_DEVICE_CONFIGURE, PhysicalNetwork.class);
// Network ACL
entityEventDetails.put(EVENT_NETWORK_ACL_CREATE, NetworkACL.class);
entityEventDetails.put(EVENT_NETWORK_ACL_DELETE, NetworkACL.class);
entityEventDetails.put(EVENT_NETWORK_ACL_REPLACE, NetworkACL.class);
entityEventDetails.put(EVENT_NETWORK_ACL_UPDATE, NetworkACL.class);
entityEventDetails.put(EVENT_NETWORK_ACL_ITEM_CREATE, NetworkACLItem.class);
entityEventDetails.put(EVENT_NETWORK_ACL_ITEM_UPDATE, NetworkACLItem.class);
entityEventDetails.put(EVENT_NETWORK_ACL_ITEM_DELETE, NetworkACLItem.class);
// VPC
entityEventDetails.put(EVENT_VPC_CREATE, Vpc.class);
entityEventDetails.put(EVENT_VPC_UPDATE, Vpc.class);

View File

@ -18,9 +18,10 @@
package com.cloud.network.vpc;
import org.apache.cloudstack.api.Displayable;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface NetworkACL extends InternalIdentity, Displayable {
public interface NetworkACL extends InternalIdentity, Identity, Displayable {
public static final long DEFAULT_DENY = 1;
public static final long DEFAULT_ALLOW = 2;

View File

@ -19,9 +19,10 @@ package com.cloud.network.vpc;
import java.util.List;
import org.apache.cloudstack.api.Displayable;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface NetworkACLItem extends InternalIdentity, Displayable {
public interface NetworkACLItem extends InternalIdentity, Identity, Displayable {
String getUuid();

View File

@ -147,12 +147,8 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
try {
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), isDisplay());
if (vpn != null) {
setEntityId(vpn.getServerAddressId());
// find uuid for server ip address
IpAddress ipAddr = _entityMgr.findById(IpAddress.class, vpn.getServerAddressId());
if (ipAddr != null) {
setEntityUuid(ipAddr.getUuid());
}
setEntityId(vpn.getId());
setEntityUuid(vpn.getUuid());
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create remote access vpn");
}

View File

@ -286,17 +286,17 @@ public class ActionEventUtils {
CallContext context = CallContext.current();
Map<Object, Object> contextMap = context.getContextParameters();
try{
for(Map.Entry<Object, Object> entry : contextMap.entrySet()){
for(Map.Entry<Object, Object> entry : contextMap.entrySet()){
try{
Object key = entry.getKey();
Class clz = Class.forName((String)key);
if(clz instanceof Class && Identity.class.isAssignableFrom(clz)){
String uuid = getEntityUuid(clz, entry.getValue());
eventDescription.put(ReflectUtil.getEntityName(clz), uuid);
}
} catch (Exception e){
s_logger.trace("Caught exception while populating first class entities for event bus, moving on");
}
}catch (Exception e){
s_logger.debug("Caught exception while populating first class entities for event bus, moving on", e);
}
}

View File

@ -108,6 +108,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_CREATE, eventDescription = "creating network acl list", async = true)
public NetworkACL getNetworkACL(long id) {
return _networkAclMgr.getNetworkACL(id);
}
@ -472,6 +473,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_ITEM_CREATE, eventDescription = "Applying Network ACL Item", async = true)
public boolean applyNetworkACL(long aclId) throws ResourceUnavailableException {
return _networkAclMgr.applyNetworkACL(aclId);
}
@ -602,6 +604,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_ITEM_DELETE, eventDescription = "Deleting Network ACL Item", async = true)
public boolean revokeNetworkACLItem(long ruleId) {
NetworkACLItemVO aclItem = _networkACLItemDao.findById(ruleId);
if(aclItem != null){
@ -621,6 +624,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_ACL_ITEM_UPDATE, eventDescription = "Updating Network ACL Item", async = true)
public NetworkACLItem updateNetworkACLItem(Long id, String protocol, List<String> sourceCidrList, NetworkACLItem.TrafficType trafficType, String action,
Integer number, Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType, String newUUID, Boolean forDisplay) throws ResourceUnavailableException {
NetworkACLItemVO aclItem = _networkACLItemDao.findById(id);

View File

@ -285,6 +285,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_REMOTE_ACCESS_VPN_DESTROY, eventDescription = "removing remote access vpn", async = true)
public boolean destroyRemoteAccessVpnForIp(long ipId, Account caller) throws ResourceUnavailableException {
final RemoteAccessVpnVO vpn = _remoteAccessVpnDao.findByPublicIpAddress(ipId);
if (vpn == null) {
@ -449,6 +450,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_REMOTE_ACCESS_VPN_CREATE, eventDescription = "creating remote access vpn", async = true)
public RemoteAccessVpnVO startRemoteAccessVpn(long ipAddressId, boolean openFirewall) throws ResourceUnavailableException {
Account caller = CallContext.current().getCallingAccount();

View File

@ -959,6 +959,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NIC_CREATE, eventDescription = "Creating Nic", async = true)
public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
Long vmId = cmd.getVmId();
Long networkId = cmd.getNetworkId();
@ -1043,6 +1044,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NIC_DELETE, eventDescription = "Removing Nic", async = true)
public UserVm removeNicFromVirtualMachine(RemoveNicFromVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, CloudRuntimeException {
Long vmId = cmd.getVmId();
Long nicId = cmd.getNicId();
@ -1099,6 +1101,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_NIC_UPDATE, eventDescription = "Creating Nic", async = true)
public UserVm updateDefaultNicForVirtualMachine(UpdateDefaultNicForVMCmd cmd) throws InvalidParameterValueException, CloudRuntimeException {
Long vmId = cmd.getVmId();
Long nicId = cmd.getNicId();