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
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f69a151f Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f69a151f Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f69a151f Branch: refs/heads/4.0 Commit: f69a151fd7370481cfa55194edbc0581f1780a11 Parents: 03dc31f Author: Mice Xia <[email protected]> Authored: Tue Sep 18 11:02:14 2012 +0800 Committer: Edison Su <[email protected]> Committed: Tue Sep 18 15:48:52 2012 -0700 ---------------------------------------------------------------------- ui/scripts/network.js | 45 +++++++++++++++++++++++++++++-------------- 1 files changed, 30 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f69a151f/ui/scripts/network.js ---------------------------------------------------------------------- diff --git a/ui/scripts/network.js b/ui/scripts/network.js index c6acc75..e1c32b4 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 + }; + }) + }); + } + }); } }); }
