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.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress; import com.cloud.network.IpAddress;
import com.cloud.network.Site2SiteVpnConnection; 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.Account;
import com.cloud.user.UserContext; 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") @Parameter(name=ApiConstants.S2S_CUSTOMER_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the customer gateway")
private Long customerGatewayId; 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 /////////////////////// /////////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -77,14 +71,6 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
return customerGatewayId; return customerGatewayId;
} }
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/////////////// API Implementation/////////////////// /////////////// API Implementation///////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -97,11 +83,8 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
@Override @Override
public long getEntityOwnerId() { public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true); Vpc vpc = _vpcService.getVpc(getVpnGateway().getVpcId());
if (accountId == null) { return vpc.getAccountId();
accountId = UserContext.current().getCaller().getId();
}
return accountId;
} }
@Override @Override
@ -155,14 +138,10 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
@Override @Override
public Long getSyncObjId() { public Long getSyncObjId() {
return getIp().getVpcId(); return getVpnGateway().getVpcId();
} }
private IpAddress getIp() { private Site2SiteVpnGateway getVpnGateway() {
IpAddress ip = _s2sVpnService.getVpnGatewayIp(vpnGatewayId); return _s2sVpnService.getVpnGateway(vpnGatewayId);
if (ip == null) {
throw new InvalidParameterValueException("Unable to find ip address by vpn gateway id " + vpnGatewayId);
}
return ip;
} }
} }

View File

@ -28,13 +28,14 @@ import com.cloud.api.ServerApiException;
import com.cloud.api.response.Site2SiteVpnGatewayResponse; import com.cloud.api.response.Site2SiteVpnGatewayResponse;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.network.Site2SiteVpnGateway; import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.network.vpc.Vpc;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.UserContext; import com.cloud.user.UserContext;
@Implementation(description="Creates site to site vpn local gateway", responseObject=Site2SiteVpnGatewayResponse.class) @Implementation(description="Creates site to site vpn local gateway", responseObject=Site2SiteVpnGatewayResponse.class)
public class CreateVpnGatewayCmd extends BaseAsyncCmd { public class CreateVpnGatewayCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CreateVpnGatewayCmd.class.getName()); public static final Logger s_logger = Logger.getLogger(CreateVpnGatewayCmd.class.getName());
private static final String s_name = "createvpngatewayresponse"; private static final String s_name = "createvpngatewayresponse";
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -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") @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn gateway")
private Long vpcId; 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 /////////////////////// /////////////////// Accessors ///////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -64,14 +57,6 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
return vpcId; return vpcId;
} }
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/////////////// API Implementation/////////////////// /////////////// API Implementation///////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -84,11 +69,8 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
@Override @Override
public long getEntityOwnerId() { public long getEntityOwnerId() {
Long accountId = finalyzeAccountId(accountName, domainId, null, true); Vpc vpc = _vpcService.getVpc(vpcId);
if (accountId == null) { return vpc.getAccountId();
accountId = UserContext.current().getCaller().getId();
}
return accountId;
} }
@Override @Override

View File

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

View File

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