Skip to content

Commit 8d9bdb1

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-6675: updatePFRule - retrieve network sync object based on the PF rule id that is passed in to the call; not the public ip address
1 parent 961e2c4 commit 8d9bdb1

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.firewall;
1818

19-
import org.apache.log4j.Logger;
20-
2119
import org.apache.cloudstack.acl.RoleType;
2220
import org.apache.cloudstack.api.APICommand;
2321
import org.apache.cloudstack.api.ApiConstants;
@@ -27,10 +25,10 @@
2725
import org.apache.cloudstack.api.response.FirewallRuleResponse;
2826
import org.apache.cloudstack.api.response.IPAddressResponse;
2927
import org.apache.cloudstack.api.response.UserVmResponse;
28+
import org.apache.log4j.Logger;
3029

3130
import com.cloud.event.EventTypes;
3231
import com.cloud.exception.InvalidParameterValueException;
33-
import com.cloud.network.IpAddress;
3432
import com.cloud.network.rules.FirewallRule;
3533
import com.cloud.network.rules.PortForwardingRule;
3634
import com.cloud.user.Account;
@@ -94,10 +92,6 @@ public String getProtocol() {
9492
return protocol;
9593
}
9694

97-
public Long getPublicIpId() {
98-
return publicIpId;
99-
}
100-
10195
public String getPublicPort() {
10296
return publicPort;
10397
}
@@ -109,21 +103,26 @@ public Long getVirtualMachineId() {
109103
public Boolean getDisplay() {
110104
return display;
111105
}
106+
public Long getId() {
107+
return id;
108+
}
112109

113110
/////////////////////////////////////////////////////
114111
/////////////// API Implementation///////////////////
115112
/////////////////////////////////////////////////////
116113

114+
115+
117116
@Override
118117
public String getCommandName() {
119118
return s_name;
120119
}
121120

122121
@Override
123122
public long getEntityOwnerId() {
124-
IpAddress addr = _entityMgr.findById(IpAddress.class, getPublicIpId());
125-
if (addr != null) {
126-
return addr.getAccountId();
123+
PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getId());
124+
if (rule != null) {
125+
return rule.getAccountId();
127126
}
128127

129128
// bad address given, parent this command to SYSTEM so ERROR events are tracked
@@ -173,14 +172,11 @@ public String getSyncObjType() {
173172

174173
@Override
175174
public Long getSyncObjId() {
176-
return getIp().getAssociatedWithNetworkId();
177-
}
178-
179-
private IpAddress getIp() {
180-
IpAddress ip = _networkService.getIp(publicIpId);
181-
if (ip == null) {
182-
throw new InvalidParameterValueException("Unable to find ip address by id " + publicIpId);
175+
PortForwardingRule rule = _entityMgr.findById(PortForwardingRule.class, getId());
176+
if (rule != null) {
177+
return rule.getNetworkId();
178+
} else {
179+
throw new InvalidParameterValueException("Unable to find the rule by id");
183180
}
184-
return ip;
185181
}
186182
}

0 commit comments

Comments
 (0)