S2S VPN: CS-15820: Remove account information of vpn gateway and vpn connection

The owner would be always same as VPC owner.

Conflicts:

	api/src/com/cloud/api/commands/CreateVpnConnectionCmd.java
	server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
	setup/db/db/schema-304to305.sql
This commit is contained in:
Sheng Yang 2012-08-02 16:31:00 -07:00
parent 70d704c786
commit a8cbba9e82
4 changed files with 14 additions and 55 deletions

View File

@ -33,6 +33,8 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.Site2SiteVpnConnection;
import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@ -53,14 +55,6 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.S2S_CUSTOMER_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the customer gateway")
private Long customerGatewayId;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the connection. Must be used with the domainId parameter.")
private String accountName;
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the connection. " +
"If used with the account parameter returns the connection associated with the account for the specified domain.")
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -77,14 +71,6 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
return customerGatewayId;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -97,11 +83,8 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
accountId = UserContext.current().getCaller().getId();
}
return accountId;
Vpc vpc = _vpcService.getVpc(getVpnGateway().getVpcId());
return vpc.getAccountId();
}
@Override
@ -155,14 +138,10 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
@Override
public Long getSyncObjId() {
return getIp().getVpcId();
return getVpnGateway().getVpcId();
}
private IpAddress getIp() {
IpAddress ip = _s2sVpnService.getVpnGatewayIp(vpnGatewayId);
if (ip == null) {
throw new InvalidParameterValueException("Unable to find ip address by vpn gateway id " + vpnGatewayId);
}
return ip;
private Site2SiteVpnGateway getVpnGateway() {
return _s2sVpnService.getVpnGateway(vpnGatewayId);
}
}

View File

@ -28,6 +28,7 @@ import com.cloud.api.ServerApiException;
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
import com.cloud.event.EventTypes;
import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@ -44,14 +45,6 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn gateway")
private Long vpcId;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the connection. Must be used with the domainId parameter.")
private String accountName;
@IdentityMapper(entityTableName="domain")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the connection. " +
"If used with the account parameter returns the connection associated with the account for the specified domain.")
private Long domainId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -64,14 +57,6 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
return vpcId;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -84,11 +69,8 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
if (accountId == null) {
accountId = UserContext.current().getCaller().getId();
}
return accountId;
Vpc vpc = _vpcService.getVpc(vpcId);
return vpc.getAccountId();
}
@Override

View File

@ -40,7 +40,7 @@ public interface Site2SiteVpnService {
Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd);
Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCmd cmd);
Site2SiteVpnConnection startVpnConnection(long id) throws ResourceUnavailableException;
IpAddress getVpnGatewayIp(Long vpnGatewayId);
Site2SiteVpnGateway getVpnGateway(Long vpnGatewayId);
Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException;
boolean deleteCustomerGateway(DeleteVpnCustomerGatewayCmd deleteVpnCustomerGatewayCmd);
boolean deleteVpnGateway(DeleteVpnGatewayCmd deleteVpnGatewayCmd);

View File

@ -265,10 +265,8 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
}
@Override
public IpAddress getVpnGatewayIp(Long vpnGatewayId) {
Site2SiteVpnGatewayVO gateway = _vpnGatewayDao.findById(vpnGatewayId);
IpAddress ip = _networkMgr.getIp(gateway.getAddrId());
return ip;
public Site2SiteVpnGateway getVpnGateway(Long vpnGatewayId) {
return _vpnGatewayDao.findById(vpnGatewayId);
}
@Override