mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Sync on network instead of ipAddressId when do create PF/StaticNat/LB rules
This commit is contained in:
parent
96ef94eb37
commit
504ab73ae5
@ -222,11 +222,19 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return ipAddressId;
|
||||
return getIp().getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _networkService.getIp(ipAddressId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.FirewallRuleResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
@ -228,12 +229,20 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return ipAddressId;
|
||||
return getIp().getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _networkService.getIp(ipAddressId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,8 +29,10 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
@ -156,11 +158,19 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return publicIpId;
|
||||
return getIp().getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _networkService.getIp(publicIpId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id " + publicIpId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,12 +104,12 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return _rulesService.getFirewallRule(id).getSourceIpAddressId();
|
||||
return _rulesService.getFirewallRule(id).getNetworkId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -103,11 +103,11 @@ public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return _rulesService.getPortForwardigRule(id).getSourceIpAddressId();
|
||||
return _rulesService.getPortForwardigRule(id).getNetworkId();
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,12 +82,12 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return publicIpId;
|
||||
return _ravService.getRemoteAccessVpn(publicIpId).getNetworkId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.SuccessResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
|
||||
@ -88,11 +89,19 @@ public class DisableStaticNatCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.ipAddressSyncObject;
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return ipAddressId;
|
||||
return getIp().getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
private IpAddress getIp() {
|
||||
IpAddress ip = _networkService.getIp(ipAddressId);
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id " + ipAddressId);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,4 +104,15 @@ public class RestartNetworkCmd extends BaseAsyncCmd {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to restart network");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,5 +42,7 @@ public interface RemoteAccessVpnService {
|
||||
List<? extends VpnUser> searchForVpnUsers(ListVpnUsersCmd cmd);
|
||||
|
||||
List<? extends RemoteAccessVpn> listRemoteAccessVpns(long networkId);
|
||||
|
||||
RemoteAccessVpn getRemoteAccessVpn(long vpnId);
|
||||
|
||||
}
|
||||
|
||||
@ -580,5 +580,10 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
|
||||
public List<? extends RemoteAccessVpn> listRemoteAccessVpns(long networkId) {
|
||||
return _remoteAccessVpnDao.listByNetworkId(networkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteAccessVpn getRemoteAccessVpn(long vpnId) {
|
||||
return _remoteAccessVpnDao.findById(vpnId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user