From 4641559c9ed7dbfc7c12f88e1e9832011b5661dc Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 10 Jul 2012 15:31:24 -0700 Subject: [PATCH] cloudstack 3.0 UI - VPC - IP Address - create LB rule with tier id. --- ui/scripts/network.js | 62 ++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index f81c685fb13..228a6a4268d 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -2018,15 +2018,24 @@ headerFields: { tier: { label: 'Tier', - select: function(args) { - args.response.success({ - data: [ - { id: '', name: '', description: 'None' }, - { id: '1', name: 'tier1', description: 'tier1' }, - { id: '2', name: 'tier2', description: 'tier2' }, - { id: '3', name: 'tier3', description: 'tier3' } - ] - }); + select: function(args) { + if('vpc' in args.context) { + $.ajax({ + url: createURL("listNetworks"), + data: { + vpcid: args.context.vpc[0].id, + listAll: true + }, + success: function(json) { + var networks = json.listnetworksresponse.network; + var items = []; + $(networks).each(function(){ + items.push({id: this.id, description: this.displaytext}); + }); + args.response.success({ data: items }); + } + }); + } } } }, @@ -2063,28 +2072,33 @@ }, add: { label: 'label.add.vms', - action: function(args) { - var openFirewall = false; + action: function(args) { + var networkid; + if('vpc' in args.context) { //from VPC section + if(args.data.tier == null) { + args.response.error('Tier is required.'); + return; + } + networkid = args.data.tier; + } + else if('networks' in args.context) { //from Guest Network section + networkid = args.context.networks[0].id; + } var data = { algorithm: args.data.algorithm, name: args.data.name, privateport: args.data.privateport, - publicport: args.data.publicport + publicport: args.data.publicport, + openfirewall: false, + networkid: networkid, + publicipid: args.context.ipAddresses[0].id }; - var stickyData = $.extend(true, {}, args.data.sticky); - - var apiCmd = "createLoadBalancerRule"; - //if(args.context.networks[0].type == "Shared") - //apiCmd += "&domainid=" + g_domainid + "&account=" + g_account; - //else //args.context.networks[0].type == "Isolated" - apiCmd += "&publicipid=" + args.context.ipAddresses[0].id; + + var stickyData = $.extend(true, {}, args.data.sticky); $.ajax({ - url: createURL(apiCmd), - data: $.extend(data, { - openfirewall: openFirewall, - networkid: args.context.networks[0].id - }), + url: createURL('createLoadBalancerRule'), + data: data, dataType: 'json', async: true, success: function(data) {