From 11b42481e1ed5aea2cc971a49fa9bcb357d8b64f Mon Sep 17 00:00:00 2001 From: Mice Xia Date: Tue, 18 Sep 2012 11:02:14 +0800 Subject: [PATCH] CLOUDSTACK-114 UI - VPC related Network Offerings should not be provided as options to create a guest network for the Account before a VPC is actually present with the Account --- ui/scripts/network.js | 45 ++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index c6acc750b09..e1c32b4b5b9 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -282,25 +282,40 @@ label: 'label.network.offering', validation: { required: true }, dependsOn: 'zoneId', - select: function(args) { + select: function(args) { $.ajax({ - url: createURL('listNetworkOfferings&zoneid=' + args.zoneId), + url: createURL('listVPCs'), data: { - guestiptype: 'Isolated', - supportedServices: 'SourceNat', - specifyvlan: false, - state: 'Enabled' + listAll: true }, success: function(json) { - networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering; - args.response.success({ - data: $.map(networkOfferingObjs, function(zone) { - return { - id: zone.id, - description: zone.name - }; - }) - }); + var items = json.listvpcsresponse.vpc; + var baseUrl = 'listNetworkOfferings&zoneid=' + args.zoneId; + var listUrl; + if(items != null && items.length > 0) + listUrl = baseUrl; + else + listUrl = baseUrl + '&forVpc=false'; + $.ajax({ + url: createURL(listUrl), + data: { + guestiptype: 'Isolated', + supportedServices: 'SourceNat', + specifyvlan: false, + state: 'Enabled' + }, + success: function(json) { + networkOfferingObjs = json.listnetworkofferingsresponse.networkoffering; + args.response.success({ + data: $.map(networkOfferingObjs, function(zone) { + return { + id: zone.id, + description: zone.name + }; + }) + }); + } + }); } }); }