From aae3f4a13ff04d4b570f4d8db23d3d0547627b04 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 18 Nov 2011 14:49:32 -0800 Subject: [PATCH] cloudStack 3.0 new UI - NaaS - implement add F5 load balancer device from listView. --- ui/scripts/system.js | 245 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 226 insertions(+), 19 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 076fb69e15a..804b8202efd 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -1077,7 +1077,8 @@ label: 'Private interface' }, numretries: { - label: 'Number of retries' + label: 'Number of retries', + defaultValue: '2' }, inline: { label: 'Mode', @@ -1132,14 +1133,15 @@ else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { - //alert("addNetworkServiceProvider&name=F5BigIp succeeded."); + //alert("addNetworkServiceProvider&name=F5BigIp succeeded."); + + //addF5LoadBalancer starts here var array1 = []; array1.push("&physicalnetworkid=" + physicalNetworkObj.id); array1.push("&username=" + todb(args.data.username)); array1.push("&password=" + todb(args.data.password)); array1.push("&networkdevicetype=" + todb(args.data.networkdevicetype)); - - //??? + //*** construct URL (begin) *** var url = []; @@ -1239,7 +1241,9 @@ } ); } - }); + }); + //addF5LoadBalancer ends here + } else if (result.jobstatus == 2) { alert("addNetworkServiceProvider&name=F5BigIp failed. Error: " + fromdb(result.jobresult.errortext)); @@ -1255,18 +1259,102 @@ } }); } - else { //naasStatusMap["f5"] == "enabled" + else { //naasStatusMap["f5"] == "enabled" + //addF5LoadBalancer starts here var array1 = []; - array1.push("&physicalnetworkid=" + physicalNetworkObj.id) - array1.push("&url=" + todb(args.data.url)); + array1.push("&physicalnetworkid=" + physicalNetworkObj.id); array1.push("&username=" + todb(args.data.username)); array1.push("&password=" + todb(args.data.password)); array1.push("&networkdevicetype=" + todb(args.data.networkdevicetype)); + + //*** construct URL (begin) *** + var url = []; + + var ip = args.data.ip; + url.push("https://" + ip); + + var isQuestionMarkAdded = false; + + var publicInterface = args.data.publicinterface; + if(publicInterface != null && publicInterface.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("publicinterface=" + publicInterface); + } + + var privateInterface = args.data.privateinterface; + if(privateInterface != null && privateInterface.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("privateinterface=" + privateInterface); + } + + var numretries = args.data.numretries; + if(numretries != null && numretries.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("numretries=" + numretries); + } + + var isInline = args.data.inline; + if(isInline != null && isInline.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("inline=" + isInline); + } + + var capacity = args.data.capacity; + if(capacity != null && capacity.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("capacity=" + capacity); + } + + var dedicated = (args.data.dedicated == "on"); + if(dedicated != null && dedicated.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("dedicated=" + dedicated.toString()); + } + + array1.push("&url=" + todb(url.join(""))); + //*** construct URL (end) *** + $.ajax({ url: createURL("addF5LoadBalancer" + array1.join("")), dataType: "json", - success: function(json) { - var jid = json.addf5bigiploadbalancerresponse.jobid; + success: function(json) { + var jid = json.addf5bigiploadbalancerresponse.jobid; args.response.success( {_custom: {jobId: jid, @@ -1279,6 +1367,8 @@ ); } }); + //addF5LoadBalancer ends here + } }, messages: { @@ -1328,10 +1418,11 @@ add: { label: 'Add new SRX', createForm: { - title: 'Add new SRX', + title: 'Add new SRX', + //??? fields: { - url: { - label: 'URL' + ip: { + label: 'IP address' }, username: { label: 'Username' @@ -1347,10 +1438,38 @@ items.push({id: "JuniperSRXFirewall", description: "Juniper SRX Firewall"}); args.response.success({data: items}); } - } - } + }, + publicinterface: { + label: 'Public interface' + }, + privateinterface: { + label: 'Private interface' + }, + numretries: { + label: 'Number of retries', + defaultValue: '2' + }, + inline: { + label: 'Mode', + select: function(args) { + var items = []; + items.push({id: "false", description: "side by side"}); + items.push({id: "true", description: "inline"}); + args.response.success({data: items}); + } + }, + capacity: { + label: 'Capacity', + validation: { required: false, number: true } + }, + dedicated: { + label: 'Dedicated', + isBoolean: true, + isChecked: false + } + } }, - action: function(args) { + action: function(args) { var zoneObj = args.context.zones[0]; var physicalNetworkObj; $.ajax({ @@ -1384,12 +1503,98 @@ $("body").stopTime(timerKey); if (result.jobstatus == 1) { //alert("addNetworkServiceProvider&name=JuniperSRX succeeded."); + + //??? + //addSrxFirewall starts here var array1 = []; - array1.push("&physicalnetworkid=" + physicalNetworkObj.id) - array1.push("&url=" + todb(args.data.url)); + array1.push("&physicalnetworkid=" + physicalNetworkObj.id); array1.push("&username=" + todb(args.data.username)); array1.push("&password=" + todb(args.data.password)); array1.push("&networkdevicetype=" + todb(args.data.networkdevicetype)); + + //*** construct URL (begin) *** + var url = []; + + var ip = args.data.ip; + url.push("https://" + ip); + + var isQuestionMarkAdded = false; + + var publicInterface = args.data.publicinterface; + if(publicInterface != null && publicInterface.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("publicinterface=" + publicInterface); + } + + var privateInterface = args.data.privateinterface; + if(privateInterface != null && privateInterface.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("privateinterface=" + privateInterface); + } + + var numretries = args.data.numretries; + if(numretries != null && numretries.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("numretries=" + numretries); + } + + var isInline = args.data.inline; + if(isInline != null && isInline.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("inline=" + isInline); + } + + var capacity = args.data.capacity; + if(capacity != null && capacity.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("capacity=" + capacity); + } + + var dedicated = (args.data.dedicated == "on"); + if(dedicated != null && dedicated.length > 0) { + if(isQuestionMarkAdded == false) { + url.push("?"); + isQuestionMarkAdded = true; + } + else { + url.push("&"); + } + url.push("dedicated=" + dedicated.toString()); + } + + array1.push("&url=" + todb(url.join(""))); + //*** construct URL (end) *** + $.ajax({ url: createURL("addSrxFirewall" + array1.join("")), dataType: "json", @@ -1406,7 +1611,9 @@ } ); } - }); + }); + //addSrxFirewall ends here + //??? } else if (result.jobstatus == 2) { alert("addNetworkServiceProvider&name=JuniperSRX failed. Error: " + fromdb(result.jobresult.errortext));