mirror of https://github.com/apache/cloudstack.git
Bug: CS-15443, Fix for NPE while adding Firewall Rule
This commit is contained in:
parent
38befcd228
commit
f05115a9c4
|
|
@ -33,6 +33,7 @@ import com.cloud.exception.NetworkRuleConflictException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
|
@ -117,13 +118,13 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
|
|||
public void execute() throws ResourceUnavailableException {
|
||||
UserContext callerContext = UserContext.current();
|
||||
boolean success = false;
|
||||
FirewallRule rule = _entityMgr.findById(FirewallRule.class, getEntityId());
|
||||
FirewallRule rule = _entityMgr.findById(NetworkACL.class, getEntityId());
|
||||
try {
|
||||
UserContext.current().setEventDetails("Rule Id: " + getEntityId());
|
||||
success = _firewallService.applyFirewallRules(rule.getSourceIpAddressId(), callerContext.getCaller());
|
||||
|
||||
// State is different after the rule is applied, so get new object here
|
||||
rule = _entityMgr.findById(FirewallRule.class, getEntityId());
|
||||
rule = _entityMgr.findById(NetworkACL.class, getEntityId());
|
||||
FirewallResponse fwResponse = new FirewallResponse();
|
||||
if (rule != null) {
|
||||
fwResponse = _responseGenerator.createFirewallResponse(rule);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import com.cloud.event.EventTypes;
|
|||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.NetworkACL;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Deletes a firewall rule", responseObject=SuccessResponse.class)
|
||||
|
|
@ -75,11 +76,11 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd {
|
|||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
if (ownerId == null) {
|
||||
FirewallRule rule = _entityMgr.findById(FirewallRule.class, id);
|
||||
FirewallRule rule = _entityMgr.findById(NetworkACL.class, id);
|
||||
if (rule == null) {
|
||||
throw new InvalidParameterValueException("Unable to find firewall rule by id=" + id);
|
||||
} else {
|
||||
ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId();
|
||||
ownerId = _entityMgr.findById(NetworkACL.class, id).getAccountId();
|
||||
}
|
||||
}
|
||||
return ownerId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue