From 24bd6a39e642625728cff42886f6d6947602e43e Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Mon, 4 Oct 2010 10:36:32 -0700 Subject: [PATCH] Fix the type of the id attribute in BaseAsyncCmd (it should be Long), deleteNetworkRuleConfig is async command again (this was a regression), misc event and account verification fixes --- .../api/commands/AssignPortForwardingServiceCmd.java | 2 +- .../commands/DeletePortForwardingServiceRuleCmd.java | 4 ++-- server/src/com/cloud/network/NetworkManagerImpl.java | 12 ++++++------ .../src/com/cloud/server/ManagementServerImpl.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java b/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java index b279ab6fcea..a1b977b646c 100644 --- a/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java +++ b/server/src/com/cloud/api/commands/AssignPortForwardingServiceCmd.java @@ -37,7 +37,7 @@ public class AssignPortForwardingServiceCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name="id", type=CommandType.STRING) + @Parameter(name="id", type=CommandType.LONG) private Long id; @Parameter(name="ids", type=CommandType.LIST, collectionType=CommandType.LONG) diff --git a/server/src/com/cloud/api/commands/DeletePortForwardingServiceRuleCmd.java b/server/src/com/cloud/api/commands/DeletePortForwardingServiceRuleCmd.java index cfd64de8635..a73ffc8ad35 100644 --- a/server/src/com/cloud/api/commands/DeletePortForwardingServiceRuleCmd.java +++ b/server/src/com/cloud/api/commands/DeletePortForwardingServiceRuleCmd.java @@ -20,14 +20,14 @@ package com.cloud.api.commands; import org.apache.log4j.Logger; -import com.cloud.api.BaseCmd; +import com.cloud.api.BaseAsyncCmd; import com.cloud.api.BaseCmd.Manager; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.response.SuccessResponse; @Implementation(method="deleteNetworkRuleConfig", manager=Manager.NetworkManager) -public class DeletePortForwardingServiceRuleCmd extends BaseCmd { +public class DeletePortForwardingServiceRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortForwardingServiceRuleCmd.class.getName()); private static final String s_name = "deleteportforwardingserviceruleresponse"; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index d66719b78de..290f018dc68 100644 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -3624,14 +3624,14 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager NetworkRuleConfigVO netRule = _networkRuleConfigDao.findById(netRuleId); if (netRule != null) { SecurityGroupVO sg = _securityGroupDao.findById(netRule.getSecurityGroupId()); - if (account != null) { - if (!BaseCmd.isAdmin(account.getType())) { - if (sg.getAccountId() != account.getId()) { - throw new PermissionDeniedException("Unable to delete port forwarding service rule " + netRuleId + "; account: " + account.getAccountName() + " is not the owner"); - } - } else if (!_domainDao.isChildDomain(account.getDomainId(), sg.getDomainId())) { + if ((account == null) || BaseCmd.isAdmin(account.getType())) { + if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), sg.getDomainId())) { throw new PermissionDeniedException("Unable to delete port forwarding service rule " + netRuleId + "; account: " + account.getAccountName() + " is not an admin in the domain hierarchy."); } + } else { + if (sg.getAccountId() != account.getId()) { + throw new PermissionDeniedException("Unable to delete port forwarding service rule " + netRuleId + "; account: " + account.getAccountName() + " is not the owner"); + } } } else { return false; // failed to delete due to netRule not found diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 7731aac667f..f29c35244b5 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2210,7 +2210,7 @@ public class ManagementServerImpl implements ManagementServer { String description = "created new ip forwarding rule [" + newFwRule.getPublicIpAddress() + ":" + newFwRule.getPublicPort() + "]->[" + newFwRule.getPrivateIpAddress() + ":" + newFwRule.getPrivatePort() + "]" + " " + newFwRule.getProtocol(); - EventUtils.saveEvent(userId, account.getId(), EventVO.LEVEL_INFO, EventTypes.EVENT_NET_RULE_ADD, description); + EventUtils.saveEvent(userId, userVm.getId(), EventVO.LEVEL_INFO, EventTypes.EVENT_NET_RULE_ADD, description); } // now that individual rules have been created from the security group, save the security group mapping for this ip/vm instance