cloudstack 3.0 UI - VPN Customer Gateway - detailView - add new action "Create VPN Connection".

This commit is contained in:
Jessica Wang 2012-07-20 11:05:26 -07:00
parent 79f7f8cc1f
commit 9dfe6eaf53
2 changed files with 114 additions and 246 deletions

View File

@ -3845,11 +3845,10 @@
items.push({id: '3des-md5', description: '3des-md5'});
items.push({id: 'aes-md5', description: 'aes-md5'});
items.push({id: 'aes128-md5', description: 'aes128-md5'});
items.push({id: 'des-md5', description: 'des-md5'});
items.push({id: '3des-sha1', description: '3des-sha1'});
items.push({id: 'aes-sha1', description: 'aes-sha1'});
items.push({id: 'aes128-sha1', description: 'aes128-sha1'});
items.push({id: 'des-sha1', description: 'des-sha1'});
items.push({id: 'aes128-sha1', description: 'aes128-sha1'});
args.response.success({data: items});
}
},
@ -3894,9 +3893,116 @@
},
detailView: {
name: 'label.details',
actions: {
name: 'label.details',
actions: {
add: {
addRow: 'false',
label: 'Create VPN Connection',
messages: {
confirm: function(args) {
return 'Are you sure you want to create VPN connection ?';
},
notification: function(args) {
return 'Create VPN Connection';
}
},
createForm: {
title: 'Create VPN Connection',
fields: {
zoneid: {
label: 'Zone',
validation: { required: true },
select: function(args) {
$.ajax({
url: createURL('listZones'),
data: {
available: true
},
success: function(json) {
var zones = json.listzonesresponse.zone;
args.response.success({
data: $.map(zones, function(zone) {
return {
id: zone.id,
description: zone.name
};
})
});
}
});
}
},
vpcid: {
label: 'VPC',
validation: { required: true },
dependsOn: 'zoneid',
select: function(args) {
$.ajax({
url: createURL('listVPCs'),
data: {
zoneid: args.zoneid,
listAll: true
},
success: function(json) {
var items = json.listvpcsresponse.vpc;
var data;
if(items != null && items.length > 0) {
data = $.map(items, function(item) {
return {
id: item.id,
description: item.name
}
});
}
args.response.success({ data: data });
}
});
}
}
}
},
action: function(args) {
var vpngatewayid;
$.ajax({
url: createURL('listVpnGateways'),
data: {
vpcid: args.data.vpcid
},
async: false,
success: function(json) {
var items = json.listvpngatewaysresponse.vpngateway;
if(items != null && items.length > 0) {
vpngatewayid = items[0].id;
}
else {
cloudStack.dialog.notice({ message: 'The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.' });
return;
}
}
});
$.ajax({
url: createURL('createVpnConnection'),
data: {
s2svpngatewayid: vpngatewayid,
s2scustomergatewayid: args.context.vpnCustomerGateway[0].id
},
success: function(json) {
var jid = json.createvpnconnectionresponse.jobid;
args.response.success(
{_custom:
{
jobId: jid
}
}
);
}
});
},
notification: {
poll: pollAsyncJobResult
}
},
remove: {
label: 'delete VPN Customer Gateway',
messages: {

View File

@ -817,7 +817,7 @@
}
}
},
vpnConnection: { //???
vpnConnection: {
type: 'select',
title: 'VPN Connection',
listView: {
@ -854,245 +854,7 @@
}
});
},
actions: {
add: {
label: 'add VPN Connection',
messages: {
notification: function(args) {
return 'add VPN Connection';
}
},
createForm: {
title: 'add VPN Connection',
fields: {
publicipid: {
label: 'label.ip.address',
select: function(args) {
$.ajax({
url: createURL('listPublicIpAddresses'),
dataType: 'json',
data: {
vpcid: args.context.vpc[0].id
},
async: true,
success: function(json) {
var items = [];
var objs = json.listpublicipaddressesresponse.publicipaddress;
if(objs != null && objs.length > 0) {
for(var i = 0; i < objs.length; i++) {
items.push({id: objs[i].id, description: objs[i].ipaddress});
}
}
args.response.success({data: items});
}
});
},
validation: { required: true }
},
gateway: {
label: 'label.gateway',
validation: { required: true }
},
cidrlist: {
label: 'CIDR list',
validation: { required: true }
},
ipsecpsk: {
label: 'IPsec Preshared-Key',
validation: { required: true }
},
ikepolicy: {
label: 'IKE policy',
select: function(args) {
var items = [];
items.push({id: '3des-md5', description: '3des-md5'});
items.push({id: 'aes-md5', description: 'aes-md5'});
items.push({id: 'aes128-md5', description: 'aes128-md5'});
items.push({id: 'des-md5', description: 'des-md5'});
items.push({id: '3des-sha1', description: '3des-sha1'});
items.push({id: 'aes-sha1', description: 'aes-sha1'});
items.push({id: 'aes128-sha1', description: 'aes128-sha1'});
items.push({id: 'des-sha1', description: 'des-sha1'});
args.response.success({data: items});
}
},
esppolicy: {
label: 'ESP policy',
select: function(args) {
var items = [];
items.push({id: '3des-md5', description: '3des-md5'});
items.push({id: 'aes-md5', description: 'aes-md5'});
items.push({id: 'aes128-md5', description: 'aes128-md5'});
items.push({id: 'des-md5', description: 'des-md5'});
items.push({id: '3des-sha1', description: '3des-sha1'});
items.push({id: 'aes-sha1', description: 'aes-sha1'});
items.push({id: 'aes128-sha1', description: 'aes128-sha1'});
items.push({id: 'des-sha1', description: 'des-sha1'});
args.response.success({data: items});
}
},
lifetime: {
label: 'Lifetime (second)',
defaultValue: '86400',
validation: { required: false, number: true }
}
}
},
action: function(args) {
var createVpnCustomerGatewayAndVpnConnection = function(vpngatewayid) {
$.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;
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;
$.ajax({
url: createURL('createVpnConnection'),
data: {
s2svpngatewayid: vpngatewayid,
s2scustomergatewayid: vpncustomergatewayid
},
dataType: 'json',
success: function(json) {
var jid = json.createvpnconnectionresponse.jobid;
var createvpnconnectionIntervalID = setInterval(function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobid=" + jid),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
}
else {
clearInterval(createvpnconnectionIntervalID);
if (result.jobstatus == 1) {
//remove loading image on table row
var $listviewTable = $("div.list-view div.data-table table.body tbody");
var $tr1 = $listviewTable.find("tr.loading").removeClass("loading");
$tr1.find("td div.loading").removeClass("loading");
var item = result.jobresult.vpnconnection;
$tr1.find("td.publicip span").text(item.publicip);
cloudStack.dialog.notice({ message: "site-to-site VPN is created successfully." });
}
else if (result.jobstatus == 2) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
}
});
}
else if (result.jobstatus == 2) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
}
});
}
var vpngatewayid;
$.ajax({
url: createURL('listVpnGateways'),
data: {
vpcid: args.context.vpc[0].id
},
async: false,
success: function(json) {
var items = json.listvpngatewaysresponse.vpngateway;
if(items != null && items.length > 0) {
vpngatewayid = items[0].id;
}
}
});
if(vpngatewayid == null) {
$.ajax({
url: createURL('createVpnGateway'),
data: {
vpcid: args.context.vpc[0].id
},
success: function(json) {
var jid = json.createvpngatewayresponse.jobid;
var createvpngatewayIntervalID = setInterval(function() {
$.ajax({
url: createURL("queryAsyncJobResult&jobid=" + jid),
dataType: "json",
success: function(json) {
var result = json.queryasyncjobresultresponse;
if (result.jobstatus == 0) {
return; //Job has not completed
}
else {
clearInterval(createvpngatewayIntervalID);
if (result.jobstatus == 1) {
var obj = result.jobresult.vpngateway;
vpngatewayid = obj.id;
createVpnCustomerGatewayAndVpnConnection(vpngatewayid);
}
else if (result.jobstatus == 2) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: _s(result.jobresult.errortext) });
}
}
},
error: function(XMLHttpResponse) {
$.removeTableRowInAction();
cloudStack.dialog.notice({ message: parseXMLHttpResponse(XMLHttpResponse) });
}
});
}, 3000);
}
});
}
else { //vpngatewayid != null
createVpnCustomerGatewayAndVpnConnection(vpngatewayid);
}
}
}
},
detailView: {
name: 'label.details',
tabs: {