Skip to content

Commit d9ba234

Browse files
committed
CLOUDSTACK-2319: fix incorrect account_id in event table for Revoke SecurityGroupRule commands
1 parent 420b654 commit d9ba234

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.cloud.async.AsyncJob;
3030
import com.cloud.event.EventTypes;
3131
import com.cloud.network.security.SecurityGroup;
32+
import com.cloud.network.security.SecurityRule;
3233
import com.cloud.user.Account;
3334

3435
@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 static String getResultObjectName() {
6768

6869
@Override
6970
public long getEntityOwnerId() {
70-
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, getId());
71-
if (group != null) {
72-
return group.getAccountId();
71+
SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId());
72+
if (rule != null) {
73+
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId());
74+
if (group != null) {
75+
return group.getAccountId();
76+
}
7377
}
7478

7579
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked

api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.cloud.async.AsyncJob;
3030
import com.cloud.event.EventTypes;
3131
import com.cloud.network.security.SecurityGroup;
32+
import com.cloud.network.security.SecurityRule;
3233
import com.cloud.user.Account;
3334

3435
@APICommand(name = "revokeSecurityGroupIngress", responseObject = SuccessResponse.class, description = "Deletes a particular ingress rule from this security group")
@@ -67,9 +68,12 @@ public static String getResultObjectName() {
6768

6869
@Override
6970
public long getEntityOwnerId() {
70-
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, getId());
71-
if (group != null) {
72-
return group.getAccountId();
71+
SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId());
72+
if (rule != null) {
73+
SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId());
74+
if (group != null) {
75+
return group.getAccountId();
76+
}
7377
}
7478

7579
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked

api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import org.apache.cloudstack.api.BaseResponse;
2121
import org.apache.cloudstack.api.EntityReference;
2222

23-
import com.cloud.network.security.SecurityGroupRules;
23+
import com.cloud.network.security.SecurityRule;
2424
import com.cloud.serializer.Param;
2525
import com.google.gson.annotations.SerializedName;
2626

27-
@EntityReference(value = SecurityGroupRules.class)
27+
@EntityReference(value = SecurityRule.class)
2828
public class SecurityGroupRuleResponse extends BaseResponse {
2929
@SerializedName("ruleid") @Param(description="the id of the security group rule")
3030
private String ruleId;

engine/schema/src/com/cloud/network/security/dao/SecurityGroupRulesDaoImpl.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,4 @@ public List<SecurityGroupRulesVO> listSecurityRulesByGroupId(long groupId) {
8585
return listBy(sc, searchFilter);
8686
}
8787

88-
@Override
89-
public SecurityGroupRulesVO findByUuidIncludingRemoved(final String uuid) {
90-
SearchCriteria<SecurityGroupRulesVO> sc = createSearchCriteria();
91-
sc.addAnd("ruleUuid", SearchCriteria.Op.EQ, uuid);
92-
SecurityGroupRulesVO rule = findOneIncludingRemovedBy(sc);
93-
SecurityGroupRulesVO newRule = new SecurityGroupRulesVO(rule.getRuleId());
94-
return newRule;
95-
}
9688
}

0 commit comments

Comments
 (0)