CLOUDSTACK-2319: fix incorrect account_id in event table for Revoke SecurityGroupRule commands

This commit is contained in:
Wei Zhou 2013-08-30 11:13:59 +02:00
parent 420b654eaf
commit d9ba234d6c
4 changed files with 16 additions and 16 deletions

View File

@ -29,6 +29,7 @@ import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
import com.cloud.user.Account;
@APICommand(name = "revokeSecurityGroupEgress", responseObject = SuccessResponse.class, description = "Deletes a particular egress rule from this security group", since="3.0.0")
@ -67,9 +68,12 @@ public class RevokeSecurityGroupEgressCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, getId());
if (group != null) {
return group.getAccountId();
SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId());
if (rule != null) {
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId());
if (group != null) {
return group.getAccountId();
}
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked

View File

@ -29,6 +29,7 @@ import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityRule;
import com.cloud.user.Account;
@APICommand(name = "revokeSecurityGroupIngress", responseObject = SuccessResponse.class, description = "Deletes a particular ingress rule from this security group")
@ -67,9 +68,12 @@ public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, getId());
if (group != null) {
return group.getAccountId();
SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId());
if (rule != null) {
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId());
if (group != null) {
return group.getAccountId();
}
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked

View File

@ -20,11 +20,11 @@ import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
import com.cloud.network.security.SecurityGroupRules;
import com.cloud.network.security.SecurityRule;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value = SecurityGroupRules.class)
@EntityReference(value = SecurityRule.class)
public class SecurityGroupRuleResponse extends BaseResponse {
@SerializedName("ruleid") @Param(description="the id of the security group rule")
private String ruleId;

View File

@ -85,12 +85,4 @@ public class SecurityGroupRulesDaoImpl extends GenericDaoBase<SecurityGroupRules
return listBy(sc, searchFilter);
}
@Override
public SecurityGroupRulesVO findByUuidIncludingRemoved(final String uuid) {
SearchCriteria<SecurityGroupRulesVO> sc = createSearchCriteria();
sc.addAnd("ruleUuid", SearchCriteria.Op.EQ, uuid);
SecurityGroupRulesVO rule = findOneIncludingRemovedBy(sc);
SecurityGroupRulesVO newRule = new SecurityGroupRulesVO(rule.getRuleId());
return newRule;
}
}