cloudstack 3.0: (1) API - CreateVpnCustomerGateway API: correct parameter type on server-side.

(2) UI - Add site-to-site VPN dialog - call CreateVpnCustomerGateway API after CreateVpnGateway API returns success.
This commit is contained in:
Jessica Wang 2012-06-29 14:21:13 -07:00
parent 07ef43bc84
commit 68a82ae1e3
2 changed files with 48 additions and 5 deletions

View File

@ -32,7 +32,7 @@ import com.cloud.user.UserContext;
public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CreateVpnCustomerGatewayCmd.class.getName());
private static final String s_name = "createcustomergatewayresponse";
private static final String s_name = "createvpncustomergatewayresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
@ -52,7 +52,7 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd {
@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")
@Parameter(name=ApiConstants.LIFETIME, type=CommandType.LONG, required=false, description="Lifetime of vpn connection to the customer gateway, in seconds")
private Long lifetime;
/////////////////////////////////////////////////////

View File

@ -3305,8 +3305,7 @@
}
}
},
action: function(args) {
var s2svpngatewayid;
action: function(args) {
$.ajax({
url: createURL('createVpnGateway'),
data: {
@ -3328,7 +3327,51 @@
clearInterval(createvpngatewayIntervalID);
if (result.jobstatus == 1) {
var obj = result.jobresult.vpngateway;
s2svpngatewayid = obj.id;
var vpngatewayid = obj.id;
//???
$.ajax({
url: createURL('createVpnCustomerGateway'),
data: {
gateway: args.data.gateway,
cidrlist: args.data.cidrlist,
ipsecpsk: args.data.ipsecpsk,
ikepolicy: args.data.ikepolicy,
esppolicy: args.data.esppolicy,
lifetime: args.data.lifetime
},
dataType: 'json',
success: function(json) {
var jid = json.createvpncustomergatewayresponse.jobid;
var createvpncustomergatewayIntervalID = setInterval(function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobid=" + jid),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
debugger;
if (result.jobstatus == 0) {
return; //Job has not completed
}
else {
clearInterval(createvpncustomergatewayIntervalID);
if (result.jobstatus == 1) {
var obj = result.jobresult.vpncustomergateway;
var vpncustomergatewayid = obj.id;
}
else if (result.jobstatus == 2) {
alert("Failed to create VPN customer gateway. Error: " + _s(result.jobresult.errortext));
}
}
},
error: function(XMLHttpResponse) {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
alert("Failed to create VPN customer gateway. Error: " + errorMsg);
}
});
}, 3000);
}
});
//???
}
else if (result.jobstatus == 2) {
alert("Failed to create VPN gateway. Error: " + _s(result.jobresult.errortext));