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

The owner would be always same as VPC owner.
This commit is contained in:
Sheng Yang 2012-08-02 16:31:00 -07:00
parent d4ce07779f
commit 263ae86311
5 changed files with 17 additions and 58 deletions

View File

@ -29,6 +29,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;
@ -49,14 +51,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 ///////////////////////
/////////////////////////////////////////////////////
@ -74,14 +68,6 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
return customerGatewayId;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -94,11 +80,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
@ -152,14 +135,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, null);
}
return ip;
private Site2SiteVpnGateway getVpnGateway() {
return _s2sVpnService.getVpnGateway(vpnGatewayId);
}
}

View File

@ -24,13 +24,14 @@ 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;
@Implementation(description="Creates site to site vpn local gateway", responseObject=Site2SiteVpnGatewayResponse.class)
public class CreateVpnGatewayCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CreateVpnGatewayCmd.class.getName());
private static final String s_name = "createvpngatewayresponse";
/////////////////////////////////////////////////////
@ -40,14 +41,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 ///////////////////////
/////////////////////////////////////////////////////
@ -60,14 +53,6 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd {
return vpcId;
}
public String getAccountName() {
return accountName;
}
public Long getDomainId() {
return domainId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -80,11 +65,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

@ -36,7 +36,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

@ -175,7 +175,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
// Default value of lifetime is 1 day
espLifetime = (long) 3600;
}
if (espLifetime > 3600) {
if (espLifetime > 86400) {
throw new InvalidParameterValueException("The ESP lifetime " + espLifetime + " of vpn connection is invalid!", null);
}
@ -278,10 +278,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
@ -398,7 +396,7 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
// Default value of lifetime is 1 day
espLifetime = (long) 3600;
}
if (espLifetime > 3600) {
if (espLifetime > 86400) {
throw new InvalidParameterValueException("The ESP lifetime " + espLifetime + " of vpn connection is invalid!", null);
}

View File

@ -313,7 +313,7 @@ CREATE TABLE `cloud`.`s2s_customer_gateway` (
`ike_policy` varchar(30) NOT NULL,
`esp_policy` varchar(30) NOT NULL,
`ike_lifetime` int NOT NULL DEFAULT 86400,
`esp_lifetime` int NOT NULL DEFAULT 86400,
`esp_lifetime` int NOT NULL DEFAULT 3600,
`dpd` int(1) NOT NULL DEFAULT 0,
`domain_id` bigint unsigned NOT NULL,
`account_id` bigint unsigned NOT NULL,