mirror of https://github.com/apache/cloudstack.git
CS-6840: Add commands for site-to-site vpn
This commit is contained in:
parent
67a434243b
commit
52e80e5fb0
|
|
@ -363,6 +363,15 @@ public class ApiConstants {
|
|||
public static final String GATEWAY_ID = "gatewayid";
|
||||
|
||||
|
||||
public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid";
|
||||
public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid";
|
||||
public static final String IPSEC_PSK = "ipsecpsk";
|
||||
public static final String GUEST_IP = "guestip";
|
||||
public static final String REMOVED = "removed";
|
||||
public static final String IKE_POLICY = "ikepolicy";
|
||||
public static final String ESP_POLICY = "esppolicy";
|
||||
public static final String LIFETIME = "lifetime";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import com.cloud.network.rules.RulesService;
|
|||
import com.cloud.network.security.SecurityGroupService;
|
||||
import com.cloud.network.vpc.VpcService;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnService;
|
||||
import com.cloud.network.vpn.Site2SiteVpnService;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectService;
|
||||
import com.cloud.resource.ResourceService;
|
||||
|
|
@ -129,6 +130,7 @@ public abstract class BaseCmd {
|
|||
public static TaggedResourceService _taggedResourceService;
|
||||
public static VpcService _vpcService;
|
||||
public static NetworkACLService _networkACLService;
|
||||
public static Site2SiteVpnService _s2sVpnService;
|
||||
|
||||
static void setComponents(ResponseGenerator generator) {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
|
|
@ -159,6 +161,7 @@ public abstract class BaseCmd {
|
|||
_taggedResourceService = locator.getManager(TaggedResourceService.class);
|
||||
_vpcService = locator.getManager(VpcService.class);
|
||||
_networkACLService = locator.getManager(NetworkACLService.class);
|
||||
_s2sVpnService = locator.getManager(Site2SiteVpnService.class);
|
||||
}
|
||||
|
||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ import com.cloud.api.response.ResourceTagResponse;
|
|||
import com.cloud.api.response.SecurityGroupResponse;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.api.response.SnapshotPolicyResponse;
|
||||
import com.cloud.api.response.SnapshotResponse;
|
||||
import com.cloud.api.response.StaticRouteResponse;
|
||||
|
|
@ -98,6 +101,9 @@ import com.cloud.network.PhysicalNetwork;
|
|||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
|
@ -281,7 +287,7 @@ public interface ResponseGenerator {
|
|||
LDAPConfigResponse createLDAPConfigResponse(String hostname, Integer port, Boolean useSSL, String queryFilter, String baseSearch, String dn);
|
||||
|
||||
StorageNetworkIpRangeResponse createStorageNetworkIpRangeResponse(StorageNetworkIpRange result);
|
||||
|
||||
|
||||
/**
|
||||
* @param tableName TODO
|
||||
* @param token
|
||||
|
|
@ -295,6 +301,7 @@ public interface ResponseGenerator {
|
|||
*/
|
||||
ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
|
||||
|
||||
Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
|
|
@ -325,4 +332,10 @@ public interface ResponseGenerator {
|
|||
* @return
|
||||
*/
|
||||
StaticRouteResponse createStaticRouteResponse(StaticRoute result);
|
||||
|
||||
PrivateGatewayResponse createPrivateGatewayResponseResponse(PrivateGateway result);
|
||||
|
||||
Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(Site2SiteCustomerGateway result);
|
||||
|
||||
Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,144 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
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.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Create site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createvpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.S2S_VPN_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the vpn gateway")
|
||||
private Long vpnGatewayId;
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.S2S_CUSTOMER_GATEWAY_ID, type=CommandType.LONG, required=true, description="id of the customer gateway")
|
||||
private Long customerGatewayId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getVpnGatewayId() {
|
||||
return vpnGatewayId;
|
||||
}
|
||||
|
||||
public Long getCustomerGatewayId() {
|
||||
return customerGatewayId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN connection";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
try {
|
||||
Site2SiteVpnConnection conn = _s2sVpnService.createVpnConnection(this);
|
||||
if (conn != null) {
|
||||
this.setEntityId(conn.getId());
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create site to site vpn connection");
|
||||
}
|
||||
} catch (NetworkRuleConflictException e) {
|
||||
s_logger.info("Network rule conflict: " + e.getMessage());
|
||||
s_logger.trace("Network Rule Conflict: ", e);
|
||||
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.startVpnConnection(this.getEntityId());
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create site to site vpn connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
return getIp().getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Creates site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "createcustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, required=true, description="guest cidr list of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@Parameter(name=ApiConstants.IPSEC_PSK, type=CommandType.STRING, required=true, description="IPsec Preshared-Key of the customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@Parameter(name=ApiConstants.IKE_POLICY, type=CommandType.STRING, required=true, description="IKE policy of the customer gateway")
|
||||
private String ikePolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.ESP_POLICY, type=CommandType.STRING, required=true, description="ESP policy of the customer gateway")
|
||||
private String espPolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.STRING, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
|
||||
private Long lifetime;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public String getIpsecPsk() {
|
||||
return ipsecPsk;
|
||||
}
|
||||
|
||||
public String getGuestCidrList() {
|
||||
return guestCidrList;
|
||||
}
|
||||
|
||||
public String getGatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public Long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN customer gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.createCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
||||
@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";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="user_ip_address")
|
||||
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn gateway")
|
||||
private Long publicIpId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "user_ip_address";
|
||||
}
|
||||
|
||||
public Long getPublicIpId() {
|
||||
return publicIpId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
IpAddress ip = _networkService.getIp(publicIpId);
|
||||
|
||||
if (ip == null) {
|
||||
throw new InvalidParameterValueException("Unable to find ip address by id=" + publicIpId);
|
||||
}
|
||||
|
||||
return ip.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Create site-to-site VPN gateway for account " + getEntityOwnerId() + " using public ip id=" + publicIpId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_VPN_GATEWAY_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteVpnGateway result = _s2sVpnService.createVpnGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create VPN gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyncObjType() {
|
||||
return BaseAsyncCmd.networkSyncObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getSyncObjId() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class DeleteVpnConnectionCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletevpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of vpn connection")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for connection. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for connection. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN connection for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.deleteVpnConnection(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete site to site VPN connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletecustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for gateway. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId fo: gateway. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN customer gateway for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.deleteCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Delete site to site vpn gateway", responseObject=Site2SiteVpnGatewayResponse.class)
|
||||
public class DeleteVpnGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteVpnGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "deletevpngatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for gateway. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId fo: gateway. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_gateway";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Delete site-to-site VPN gateway for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_VPN_GATEWAY_DELETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteVpnGateway result = _s2sVpnService.deleteVpnGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
|
||||
@Implementation(description="Lists site to site vpn connection gateways", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnCustomerGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpnconnectionsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of the vpn connection")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteVpnConnection> conns = _s2sVpnService.searchForVpnConnections(this);
|
||||
ListResponse<Site2SiteVpnConnectionResponse> response = new ListResponse<Site2SiteVpnConnectionResponse>();
|
||||
List<Site2SiteVpnConnectionResponse> connResponses = new ArrayList<Site2SiteVpnConnectionResponse>();
|
||||
if (conns != null && !conns.isEmpty()) {
|
||||
for (Site2SiteVpnConnection conn : conns) {
|
||||
connResponses.add(_responseGenerator.createSite2SiteVpnConnectionResponse(conn));
|
||||
}
|
||||
}
|
||||
response.setResponses(connResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
|
||||
@Implementation(description="Lists site to site vpn customer gateways", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnCustomerGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpncustomergatewaysresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of the customer gateway")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteCustomerGateway> gws = _s2sVpnService.searchForCustomerGateways(this);
|
||||
ListResponse<Site2SiteCustomerGatewayResponse> response = new ListResponse<Site2SiteCustomerGatewayResponse>();
|
||||
List<Site2SiteCustomerGatewayResponse> gwResponses = new ArrayList<Site2SiteCustomerGatewayResponse>();
|
||||
if (gws != null && !gws.isEmpty()) {
|
||||
for (Site2SiteCustomerGateway gw : gws) {
|
||||
gwResponses.add(_responseGenerator.createSite2SiteCustomerGatewayResponse(gw));
|
||||
}
|
||||
}
|
||||
response.setResponses(gwResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
||||
@Implementation(description="Lists site 2 site vpn gateways", responseObject=Site2SiteVpnGatewayResponse.class)
|
||||
public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger (ListVpnGatewaysCmd.class.getName());
|
||||
|
||||
private static final String s_name = "listvpngatewaysresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="s2s_vpn_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of the vpn gateway")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
List<Site2SiteVpnGateway> gws = _s2sVpnService.searchForVpnGateways(this);
|
||||
ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<Site2SiteVpnGatewayResponse>();
|
||||
List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<Site2SiteVpnGatewayResponse>();
|
||||
if (gws != null && !gws.isEmpty()) {
|
||||
for (Site2SiteVpnGateway gw : gws) {
|
||||
gwResponses.add(_responseGenerator.createSite2SiteVpnGatewayResponse(gw));
|
||||
}
|
||||
}
|
||||
response.setResponses(gwResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description="Reset site to site vpn connection", responseObject=Site2SiteVpnConnectionResponse.class)
|
||||
public class ResetVpnConnectionCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ResetVpnConnectionCmd.class.getName());
|
||||
|
||||
private static final String s_name = "resetvpnconnectionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_vpn_connection")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of vpn connection")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for connection. Must be used with domainId.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for connection. If the account parameter is used, domainId must also be used.")
|
||||
private Long domainId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_vpn_connection";
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return getEntityOwnerId();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Long accountId = finalyzeAccountId(accountName, domainId, null, true);
|
||||
if (accountId == null) {
|
||||
return UserContext.current().getCaller().getId();
|
||||
}
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Reset site-to-site VPN connection for account " + getEntityOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CONNECTION_RESET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
try {
|
||||
Site2SiteVpnConnection result = _s2sVpnService.resetVpnConnection(this);
|
||||
if (result != null) {
|
||||
Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reset site to site VPN connection");
|
||||
}
|
||||
} catch (ResourceUnavailableException ex) {
|
||||
s_logger.warn("Exception: ", ex);
|
||||
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.IdentityMapper;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description="Update site to site vpn customer gateway", responseObject=Site2SiteCustomerGatewayResponse.class)
|
||||
public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateVpnCustomerGatewayCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatecustomergatewayresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="s2s_customer_gateway")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="id of customer gateway")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY, type=CommandType.STRING, required=true, description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_IP, type=CommandType.STRING, required=true, description="guest ip of the customer gateway")
|
||||
private String guestIp;
|
||||
|
||||
@Parameter(name=ApiConstants.CIDR_LIST, type=CommandType.STRING, required=true, description="guest cidr of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@Parameter(name=ApiConstants.IPSEC_PSK, type=CommandType.STRING, required=true, description="IPsec Preshared-Key of the customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@Parameter(name=ApiConstants.IKE_POLICY, type=CommandType.STRING, required=true, description="IKE policy of the customer gateway")
|
||||
private String ikePolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.ESP_POLICY, type=CommandType.STRING, required=true, description="ESP policy of the customer gateway")
|
||||
private String espPolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.STRING, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
|
||||
private Long lifetime;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public String getEntityTable() {
|
||||
return "s2s_customer_gateway";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIpsecPsk() {
|
||||
return ipsecPsk;
|
||||
}
|
||||
|
||||
public String getGuestCidrList() {
|
||||
return guestCidrList;
|
||||
}
|
||||
|
||||
public String getGuestIp() {
|
||||
return guestIp;
|
||||
}
|
||||
|
||||
public String getGatewayIp() {
|
||||
return gatewayIp;
|
||||
}
|
||||
|
||||
public String getIkePolicy() {
|
||||
return ikePolicy;
|
||||
}
|
||||
|
||||
public String getEspPolicy() {
|
||||
return espPolicy;
|
||||
}
|
||||
|
||||
public Long getLifetime() {
|
||||
return lifetime;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Update site-to-site VPN customer gateway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_S2S_CUSTOMER_GATEWAY_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Site2SiteCustomerGateway result = _s2sVpnService.updateCustomerGateway(this);
|
||||
if (result != null) {
|
||||
Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update customer VPN gateway");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Site2SiteCustomerGatewayResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the vpn gateway ID")
|
||||
private IdentityProxy id = new IdentityProxy("s2s_vpn_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.GATEWAY) @Param(description="public ip address id of the customer gateway")
|
||||
private String gatewayIp;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="guest ip of the customer gateway")
|
||||
private String guestIp;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="guest cidr list of the customer gateway")
|
||||
private String guestCidrList;
|
||||
|
||||
@SerializedName(ApiConstants.IPSEC_PSK) @Param(description="IPsec preshared-key of customer gateway")
|
||||
private String ipsecPsk;
|
||||
|
||||
@SerializedName(ApiConstants.REMOVED) @Param(description="the date and time the host was removed")
|
||||
private Date removed;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setGatewayIp(String gatewayIp) {
|
||||
this.gatewayIp = gatewayIp;
|
||||
}
|
||||
|
||||
public void setGuestIp(String guestIp) {
|
||||
this.guestIp = guestIp;
|
||||
}
|
||||
|
||||
public void setGuestCidrList(String guestCidrList) {
|
||||
this.guestCidrList = guestCidrList;
|
||||
}
|
||||
|
||||
public void setIpsecPsk(String ipsecPsk) {
|
||||
this.ipsecPsk = ipsecPsk;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Site2SiteVpnConnectionResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the vpn gateway ID")
|
||||
private IdentityProxy id = new IdentityProxy("s2s_vpn_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.S2S_VPN_GATEWAY_ID) @Param(description="the vpn gateway ID")
|
||||
private IdentityProxy vpnGatewayId= new IdentityProxy("s2s_vpn_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.S2S_CUSTOMER_GATEWAY_ID) @Param(description="the customer gateway ID")
|
||||
private IdentityProxy customerGatewayId = new IdentityProxy("s2s_customer_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.CREATED) @Param(description="the date and time the host was created")
|
||||
private Date created;
|
||||
|
||||
@SerializedName(ApiConstants.REMOVED) @Param(description="the date and time the host was removed")
|
||||
private Date removed;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setVpnGatewayId(Long vpnGatewayId) {
|
||||
this.vpnGatewayId.setValue(vpnGatewayId);
|
||||
}
|
||||
|
||||
public void setCustomerGatewayId(Long customerGatewayId) {
|
||||
this.customerGatewayId.setValue(customerGatewayId);
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Site2SiteVpnGatewayResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the vpn gateway ID")
|
||||
private IdentityProxy id = new IdentityProxy("s2s_vpn_gateway");
|
||||
|
||||
@SerializedName(ApiConstants.PUBLIC_IP) @Param(description="the public IP address")
|
||||
private String ip;
|
||||
|
||||
@SerializedName(ApiConstants.REMOVED) @Param(description="the date and time the host was removed")
|
||||
private Date removed;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public void setRemoved(Date removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +196,14 @@ public class EventTypes {
|
|||
public static final String EVENT_REMOTE_ACCESS_VPN_DESTROY = "VPN.REMOTE.ACCESS.DESTROY";
|
||||
public static final String EVENT_VPN_USER_ADD = "VPN.USER.ADD";
|
||||
public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE";
|
||||
public static final String EVENT_S2S_VPN_GATEWAY_CREATE = "VPN.S2S.VPN.GATEWAY.CREATE";
|
||||
public static final String EVENT_S2S_VPN_GATEWAY_DELETE = "VPN.S2S.VPN.GATEWAY.DELETE";
|
||||
public static final String EVENT_S2S_CUSTOMER_GATEWAY_CREATE = "VPN.S2S.CUSTOMER.GATEWAY.CREATE";
|
||||
public static final String EVENT_S2S_CUSTOMER_GATEWAY_DELETE = "VPN.S2S.CUSTOMER.GATEWAY.DELETE";
|
||||
public static final String EVENT_S2S_CUSTOMER_GATEWAY_UPDATE = "VPN.S2S.CUSTOMER.GATEWAY.UPDATE";
|
||||
public static final String EVENT_S2S_CONNECTION_CREATE = "VPN.S2S.CONNECTION.CREATE";
|
||||
public static final String EVENT_S2S_CONNECTION_DELETE = "VPN.S2S.CONNECTION.DELETE";
|
||||
public static final String EVENT_S2S_CONNECTION_RESET = "VPN.S2S.CONNECTION.RESET";
|
||||
|
||||
// Network
|
||||
public static final String EVENT_NETWORK_RESTART = "NETWORK.RESTART";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by the License.
|
||||
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.network.vpn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.commands.CreateVpnConnectionCmd;
|
||||
import com.cloud.api.commands.CreateVpnCustomerGatewayCmd;
|
||||
import com.cloud.api.commands.CreateVpnGatewayCmd;
|
||||
import com.cloud.api.commands.DeleteVpnConnectionCmd;
|
||||
import com.cloud.api.commands.DeleteVpnCustomerGatewayCmd;
|
||||
import com.cloud.api.commands.DeleteVpnGatewayCmd;
|
||||
import com.cloud.api.commands.ListVpnConnectionsCmd;
|
||||
import com.cloud.api.commands.ListVpnCustomerGatewaysCmd;
|
||||
import com.cloud.api.commands.ListVpnGatewaysCmd;
|
||||
import com.cloud.api.commands.ResetVpnConnectionCmd;
|
||||
import com.cloud.api.commands.UpdateVpnCustomerGatewayCmd;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
|
||||
public interface Site2SiteVpnService {
|
||||
Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd);
|
||||
Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCmd cmd);
|
||||
Site2SiteVpnConnection startVpnConnection(long id) throws ResourceUnavailableException;
|
||||
IpAddress getVpnGatewayIp(Long vpnGatewayId);
|
||||
Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException;
|
||||
Site2SiteCustomerGateway deleteCustomerGateway(DeleteVpnCustomerGatewayCmd deleteVpnCustomerGatewayCmd);
|
||||
Site2SiteVpnGateway deleteVpnGateway(DeleteVpnGatewayCmd deleteVpnGatewayCmd);
|
||||
Site2SiteVpnConnection deleteVpnConnection(DeleteVpnConnectionCmd deleteVpnConnectionCmd);
|
||||
Site2SiteVpnConnection resetVpnConnection(ResetVpnConnectionCmd resetVpnConnectionCmd);
|
||||
List<Site2SiteCustomerGateway> searchForCustomerGateways(ListVpnCustomerGatewaysCmd listVpnCustomerGatewaysCmd);
|
||||
List<Site2SiteVpnGateway> searchForVpnGateways(ListVpnGatewaysCmd listVpnGatewaysCmd);
|
||||
List<Site2SiteVpnConnection> searchForVpnConnections(ListVpnConnectionsCmd listVpnConnectionsCmd);
|
||||
Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd updateVpnCustomerGatewayCmd);
|
||||
}
|
||||
|
|
@ -365,3 +365,16 @@ listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15
|
|||
createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15
|
||||
deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15
|
||||
listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15
|
||||
|
||||
### Site-to-site VPN commands
|
||||
createVpnCustomerGateway=com.cloud.api.commands.CreateVpnCustomerGatewayCmd;1
|
||||
createVpnGateway=com.cloud.api.commands.CreateVpnGatewayCmd;1
|
||||
createVpnConnection=com.cloud.api.commands.CreateVpnConnectionCmd;1
|
||||
deleteVpnCustomerGateway=com.cloud.api.commands.DeleteVpnCustomerGatewayCmd;1
|
||||
deleteVpnGateway=com.cloud.api.commands.DeleteVpnGatewayCmd;1
|
||||
deleteVpnConnection=com.cloud.api.commands.DeleteVpnConnectionCmd;1
|
||||
updateVpnCustomerGateway=com.cloud.api.commands.UpdateVpnCustomerGatewayCmd;1
|
||||
resetVpnConnection=com.cloud.api.commands.ResetVpnConnectionCmd;1
|
||||
listVpnCustomerGateway=com.cloud.api.commands.ListVpnCustomerGatewayCmd;1
|
||||
listVpnGateway=com.cloud.api.commands.ListVpnGatewayCmd;1
|
||||
listVpnConnection=com.cloud.api.commands.ListVpnConnectionCmd;1
|
||||
|
|
|
|||
|
|
@ -183,5 +183,8 @@
|
|||
<dao name="NetworkOfferingServiceDao" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" singleton="false"/>
|
||||
<dao name="VirtualRouterProviderDao" class="com.cloud.network.dao.VirtualRouterProviderDaoImpl" singleton="false"/>
|
||||
<dao name="IdentityDao" class="com.cloud.uuididentity.dao.IdentityDaoImpl" singleton="false"/>
|
||||
<dao name="Site2SiteCustomerGatewayDao" class="com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl" singleton="false"/>
|
||||
<dao name="Site2SiteVpnGatewayDao" class="com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl" singleton="false"/>
|
||||
<dao name="Site2SiteVpnConnectionDao" class="com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl" singleton="false"/>
|
||||
</configuration-server>
|
||||
</components.xml>
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ import com.cloud.api.response.SecurityGroupRuleResponse;
|
|||
import com.cloud.api.response.SecurityGroupRuleResultObject;
|
||||
import com.cloud.api.response.ServiceOfferingResponse;
|
||||
import com.cloud.api.response.ServiceResponse;
|
||||
import com.cloud.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnConnectionResponse;
|
||||
import com.cloud.api.response.Site2SiteVpnGatewayResponse;
|
||||
import com.cloud.api.response.SnapshotPolicyResponse;
|
||||
import com.cloud.api.response.SnapshotResponse;
|
||||
import com.cloud.api.response.StaticRouteResponse;
|
||||
|
|
@ -136,6 +139,9 @@ import com.cloud.network.PhysicalNetwork;
|
|||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkTrafficType;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.router.VirtualRouter;
|
||||
|
|
@ -3485,7 +3491,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering) {
|
||||
VpcOfferingResponse response = new VpcOfferingResponse();
|
||||
|
|
@ -3588,7 +3593,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StaticRouteResponse createStaticRouteResponse(StaticRoute result) {
|
||||
StaticRouteResponse response = new StaticRouteResponse();
|
||||
|
|
@ -3609,4 +3613,40 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivateGatewayResponse createPrivateGatewayResponseResponse(PrivateGateway result) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVpnGateway result) {
|
||||
Site2SiteVpnGatewayResponse response = new Site2SiteVpnGatewayResponse();
|
||||
response.setId(result.getId());
|
||||
response.setIp(ApiDBUtils.findIpAddressById(result.getAddrId()).getAddress().toString());
|
||||
response.setRemoved(result.getRemoved());
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteCustomerGatewayResponse createSite2SiteCustomerGatewayResponse(Site2SiteCustomerGateway result) {
|
||||
Site2SiteCustomerGatewayResponse response = new Site2SiteCustomerGatewayResponse();
|
||||
response.setId(result.getId());
|
||||
response.setGatewayIp(result.getGatewayIp());
|
||||
response.setGuestCidrList(result.getGuestCidrList());
|
||||
response.setIpsecPsk(result.getIpsecPsk());
|
||||
response.setRemoved(result.getRemoved());
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result) {
|
||||
Site2SiteVpnConnectionResponse response = new Site2SiteVpnConnectionResponse();
|
||||
response.setId(result.getId());
|
||||
response.setVpnGatewayId(result.getVpnGatewayId());
|
||||
response.setCustomerGatewayId(result.getCustomerGatewayId());
|
||||
response.setCreated(result.getCreated());
|
||||
response.setRemoved(result.getRemoved());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDaoImpl;
|
|||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
|
||||
import com.cloud.network.dao.PortProfileDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.Site2SiteCustomerGatewayDaoImpl;
|
||||
import com.cloud.network.dao.Site2SiteVpnConnectionDaoImpl;
|
||||
import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.element.CiscoNexusVSMElement;
|
||||
|
|
@ -131,6 +134,7 @@ import com.cloud.network.vpc.Dao.VpcGatewayDaoImpl;
|
|||
import com.cloud.network.vpc.Dao.VpcOfferingDaoImpl;
|
||||
import com.cloud.network.vpc.Dao.VpcOfferingServiceMapDaoImpl;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnManagerImpl;
|
||||
import com.cloud.network.vpn.Site2SiteVpnManagerImpl;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
|
||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl;
|
||||
import com.cloud.projects.ProjectManagerImpl;
|
||||
|
|
@ -345,6 +349,9 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addDao("PrivateIpDao", PrivateIpDaoImpl.class);
|
||||
addDao("VpcGatewayDao", VpcGatewayDaoImpl.class);
|
||||
addDao("StaticRouteDao", StaticRouteDaoImpl.class);
|
||||
addDao("Site2SiteVpnGatewayDao", Site2SiteVpnGatewayDaoImpl.class);
|
||||
addDao("Site2SiteCustomerGatewayDao", Site2SiteCustomerGatewayDaoImpl.class);
|
||||
addDao("Site2SiteVpnConnnectionDao", Site2SiteVpnConnectionDaoImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -405,6 +412,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||
addManager("VPC Manager", VpcManagerImpl.class);
|
||||
addManager("VpcVirtualRouterManager", VpcVirtualNetworkApplianceManagerImpl.class);
|
||||
addManager("NetworkACLManager", NetworkACLManagerImpl.class);
|
||||
addManager("Site2SiteVpnManager", Site2SiteVpnManagerImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,267 @@
|
|||
package com.cloud.network.vpn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.commands.CreateVpnConnectionCmd;
|
||||
import com.cloud.api.commands.CreateVpnCustomerGatewayCmd;
|
||||
import com.cloud.api.commands.CreateVpnGatewayCmd;
|
||||
import com.cloud.api.commands.DeleteVpnConnectionCmd;
|
||||
import com.cloud.api.commands.DeleteVpnCustomerGatewayCmd;
|
||||
import com.cloud.api.commands.DeleteVpnGatewayCmd;
|
||||
import com.cloud.api.commands.ListVpnConnectionsCmd;
|
||||
import com.cloud.api.commands.ListVpnCustomerGatewaysCmd;
|
||||
import com.cloud.api.commands.ListVpnGatewaysCmd;
|
||||
import com.cloud.api.commands.ResetVpnConnectionCmd;
|
||||
import com.cloud.api.commands.UpdateVpnCustomerGatewayCmd;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteCustomerGatewayVO;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Site2SiteVpnConnection.State;
|
||||
import com.cloud.network.Site2SiteVpnConnectionVO;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.Site2SiteVpnGatewayVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.Site2SiteCustomerGatewayDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnConnectionDao;
|
||||
import com.cloud.network.dao.Site2SiteVpnGatewayDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Local(value = Site2SiteVpnService.class)
|
||||
public class Site2SiteVpnManagerImpl implements Site2SiteVpnService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(Site2SiteVpnManagerImpl.class);
|
||||
|
||||
@Inject Site2SiteCustomerGatewayDao _customerGatewayDao;
|
||||
@Inject Site2SiteVpnGatewayDao _vpnGatewayDao;
|
||||
@Inject Site2SiteVpnConnectionDao _vpnConnectionDao;
|
||||
@Inject NetworkManager _networkMgr;
|
||||
@Inject NetworkDao _networkDao;
|
||||
|
||||
String _name;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd) {
|
||||
Long ipId = cmd.getPublicIpId();
|
||||
IpAddress ip = _networkMgr.getIp(ipId);
|
||||
Network network = _networkDao.findById(ip.getAssociatedWithNetworkId());
|
||||
if (network.getGuestType() != GuestType.Isolated) {
|
||||
throw new InvalidParameterValueException("The VPN gateway cannot create with non-isolated network " + ip.getAssociatedWithNetworkId());
|
||||
}
|
||||
Long domainId = ip.getDomainId();
|
||||
Long accountId = ip.getAccountId();
|
||||
if (_vpnGatewayDao.findByIpAddrId(ipId) != null) {
|
||||
throw new InvalidParameterValueException("The VPN gateway with ip ID " + ipId + " already existed!");
|
||||
}
|
||||
Site2SiteVpnGatewayVO gw = new Site2SiteVpnGatewayVO(ipId);
|
||||
_vpnGatewayDao.persist(gw);
|
||||
return gw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCmd cmd) {
|
||||
String gatewayIp = cmd.getGatewayIp();
|
||||
if (!NetUtils.isValidIp(gatewayIp)) {
|
||||
throw new InvalidParameterValueException("The customer gateway ip " + gatewayIp + " is invalid!");
|
||||
}
|
||||
String guestCidrList = cmd.getGuestCidrList();
|
||||
if (!NetUtils.validateGuestCidrList(guestCidrList)) {
|
||||
throw new InvalidParameterValueException("The customer gateway guest cidr list " + guestCidrList + " is invalid guest cidr!");
|
||||
}
|
||||
String ipsecPsk = cmd.getIpsecPsk();
|
||||
String ikePolicy = cmd.getIkePolicy();
|
||||
String espPolicy = cmd.getEspPolicy();
|
||||
if (!NetUtils.isValidS2SVpnPolicy(ikePolicy)) {
|
||||
throw new InvalidParameterValueException("The customer gateway IKE policy" + ikePolicy + " is invalid!");
|
||||
}
|
||||
if (!NetUtils.isValidS2SVpnPolicy(espPolicy)) {
|
||||
throw new InvalidParameterValueException("The customer gateway ESP policy" + espPolicy + " is invalid!");
|
||||
}
|
||||
Long lifetime = cmd.getLifetime();
|
||||
if (lifetime == null) {
|
||||
// Default value of lifetime is 1 day
|
||||
lifetime = (long) 86400;
|
||||
}
|
||||
if (lifetime > 86400) {
|
||||
throw new InvalidParameterValueException("The lifetime " + lifetime + " of vpn connection is invalid!");
|
||||
}
|
||||
if (_customerGatewayDao.findByGatewayIp(gatewayIp) != null) {
|
||||
throw new InvalidParameterValueException("The customer gateway with ip " + gatewayIp + " already existed!");
|
||||
}
|
||||
Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO(gatewayIp, guestCidrList, ipsecPsk,
|
||||
ikePolicy, espPolicy, lifetime);
|
||||
_customerGatewayDao.persist(gw);
|
||||
return gw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnection createVpnConnection(CreateVpnConnectionCmd cmd) throws NetworkRuleConflictException {
|
||||
Long customerGatewayId = cmd.getCustomerGatewayId();
|
||||
Site2SiteCustomerGateway customerGateway = _customerGatewayDao.findById(customerGatewayId);
|
||||
Long vpnGatewayId = cmd.getVpnGatewayId();
|
||||
Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(vpnGatewayId);
|
||||
if (_vpnConnectionDao.findByCustomerGatewayId(customerGatewayId) != null ||
|
||||
_vpnConnectionDao.findByVpnGatewayId(vpnGatewayId) != null) {
|
||||
throw new InvalidParameterValueException("The vpn connection with customer gateway id " + customerGatewayId + " or vpn gateway id "
|
||||
+ vpnGatewayId + " already existed!");
|
||||
}
|
||||
Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(vpnGatewayId, customerGatewayId);
|
||||
_vpnConnectionDao.persist(conn);
|
||||
return conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnection startVpnConnection(long id) throws ResourceUnavailableException {
|
||||
Site2SiteVpnConnectionVO conn = _vpnConnectionDao.findById(id);
|
||||
if (conn.getState() != State.Pending && conn.getState() != State.Disconnected) {
|
||||
throw new InvalidParameterValueException("Site to site VPN connection " + id + " not in correct state(pending or disconnected) to process!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpAddress getVpnGatewayIp(Long vpnGatewayId) {
|
||||
Site2SiteVpnGatewayVO gateway = _vpnGatewayDao.findById(vpnGatewayId);
|
||||
IpAddress ip = _networkMgr.getIp(gateway.getAddrId());
|
||||
return ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteCustomerGateway deleteCustomerGateway(DeleteVpnCustomerGatewayCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Site2SiteCustomerGateway customerGateway = _customerGatewayDao.findById(id);
|
||||
if (customerGateway == null) {
|
||||
throw new InvalidParameterValueException("Fail to find customer gateway with " + id + " !");
|
||||
}
|
||||
_customerGatewayDao.remove(id);
|
||||
return customerGateway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnGateway deleteVpnGateway(DeleteVpnGatewayCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(id);
|
||||
if (vpnGateway == null) {
|
||||
throw new InvalidParameterValueException("Fail to find vpn gateway with " + id + " !");
|
||||
}
|
||||
_vpnGatewayDao.remove(id);
|
||||
return vpnGateway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Site2SiteCustomerGatewayVO gw = _customerGatewayDao.findById(id);
|
||||
if (gw == null) {
|
||||
throw new InvalidParameterValueException("Find to find customer gateway with id " + id);
|
||||
}
|
||||
Site2SiteVpnConnection conn = _vpnConnectionDao.findByCustomerGatewayId(id);
|
||||
if (conn != null && (conn.getState() != State.Disconnected || conn.getState() != State.Error)) {
|
||||
throw new InvalidParameterValueException("Unable to update customer gateway because there is the correlate VPN connection " + conn.getId()
|
||||
+ " still active!");
|
||||
}
|
||||
String gatewayIp = cmd.getGatewayIp();
|
||||
if (!NetUtils.isValidIp(gatewayIp)) {
|
||||
throw new InvalidParameterValueException("The customer gateway ip " + gatewayIp + " is invalid!");
|
||||
}
|
||||
String guestCidrList = cmd.getGuestCidrList();
|
||||
if (!NetUtils.validateGuestCidrList(guestCidrList)) {
|
||||
throw new InvalidParameterValueException("The customer gateway guest cidr list " + guestCidrList + " contains invalid guest cidr!");
|
||||
}
|
||||
String ipsecPsk = cmd.getIpsecPsk();
|
||||
String ikePolicy = cmd.getIkePolicy();
|
||||
String espPolicy = cmd.getEspPolicy();
|
||||
if (!NetUtils.isValidS2SVpnPolicy(ikePolicy)) {
|
||||
throw new InvalidParameterValueException("The customer gateway IKE policy" + ikePolicy + " is invalid!");
|
||||
}
|
||||
if (!NetUtils.isValidS2SVpnPolicy(espPolicy)) {
|
||||
throw new InvalidParameterValueException("The customer gateway ESP policy" + espPolicy + " is invalid!");
|
||||
}
|
||||
Long lifetime = cmd.getLifetime();
|
||||
if (lifetime == null) {
|
||||
// Default value of lifetime is 1 day
|
||||
lifetime = (long) 86400;
|
||||
}
|
||||
if (lifetime > 86400) {
|
||||
throw new InvalidParameterValueException("The lifetime " + lifetime + " of vpn connection is invalid!");
|
||||
}
|
||||
gw.setGatewayIp(gatewayIp);
|
||||
gw.setGuestCidrList(guestCidrList);
|
||||
gw.setIkePolicy(ikePolicy);
|
||||
gw.setEspPolicy(espPolicy);
|
||||
gw.setIpsecPsk(ipsecPsk);
|
||||
gw.setLifetime(lifetime);
|
||||
_customerGatewayDao.persist(gw);
|
||||
return gw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnection deleteVpnConnection(DeleteVpnConnectionCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Site2SiteVpnConnectionVO conn = _vpnConnectionDao.findById(id);
|
||||
if (conn.getState() == State.Connected) {
|
||||
//TODO disconnect it first
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnection resetVpnConnection(ResetVpnConnectionCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Site2SiteVpnConnectionVO conn = _vpnConnectionDao.findById(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Site2SiteCustomerGateway> searchForCustomerGateways(ListVpnCustomerGatewaysCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Site2SiteVpnGateway> searchForVpnGateways(ListVpnGatewaysCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Site2SiteVpnConnection> searchForVpnConnections(ListVpnConnectionsCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1058,4 +1058,43 @@ public class NetUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean isValidS2SVpnPolicy(String policys) {
|
||||
if (policys == null || policys.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (String policy : policys.split(",")) {
|
||||
if (policy.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String cipherHash = policy.split(";")[0];
|
||||
if (cipherHash.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String pfsGroup = null;
|
||||
if (!policy.equals(cipherHash)) {
|
||||
pfsGroup = policy.split(";")[1];
|
||||
}
|
||||
String cipher = cipherHash.split("-")[0];
|
||||
String hash = cipherHash.split("-")[1];
|
||||
if (!cipher.matches("des|3des|aes|aes128|aes256")) {
|
||||
return false;
|
||||
}
|
||||
if (!hash.matches("md5|sha1")) {
|
||||
return false;
|
||||
}
|
||||
if (pfsGroup != null && !pfsGroup.matches("modp768|modp1024|modp2048")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean validateGuestCidrList(String guestCidrList) {
|
||||
for (String guestCidr : guestCidrList.split(";")) {
|
||||
if (!validateGuestCidr(guestCidr)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,5 +47,18 @@ public class NetUtilsTest extends TestCase {
|
|||
avoid.add(ip);
|
||||
ip = NetUtils.getRandomIpFromCidr(cidr, 30, avoid);
|
||||
assertEquals("This should be -1 because we ran out of ip addresses: " + ip, ip, -1);
|
||||
}
|
||||
|
||||
public void testVpnPolicy() {
|
||||
assertTrue(NetUtils.isValidS2SVpnPolicy("aes-sha1"));
|
||||
assertTrue(NetUtils.isValidS2SVpnPolicy("des-md5;modp768"));
|
||||
assertTrue(NetUtils.isValidS2SVpnPolicy("des-md5;modp768,aes-sha1;modp2048"));
|
||||
assertTrue(NetUtils.isValidS2SVpnPolicy("3des-sha1,aes-sha1;modp2048"));
|
||||
assertTrue(NetUtils.isValidS2SVpnPolicy("3des-sha1,aes-sha1"));
|
||||
assertFalse(NetUtils.isValidS2SVpnPolicy("abc-123,ase-sha1"));
|
||||
assertFalse(NetUtils.isValidS2SVpnPolicy("de-sh,aes-sha1"));
|
||||
assertFalse(NetUtils.isValidS2SVpnPolicy(""));
|
||||
assertFalse(NetUtils.isValidS2SVpnPolicy(";modp2048"));
|
||||
assertFalse(NetUtils.isValidS2SVpnPolicy(",aes;modp2048,,,"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue