From d0d6ba9781aa9328ccb621d0f15d07cd894d7a03 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 21 Feb 2013 12:23:27 -0800 Subject: [PATCH 1/3] Add new dropdowns to primary storage form Adds the following new fields, to support targeted storage pool: -Scope drop-down (zone/cluster/host) -Host list drop-down --- ui/scripts/system.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index e51bf90ba81..3c52442308c 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -8695,6 +8695,20 @@ createForm: { title: 'label.add.primary.storage', fields: { + scope: { + label: 'label.scope', + select: function(args) { + var scope = [ + { id: 'zone-wide', description: _l('label.zone.wide') }, + { id: 'cluster', description: _l('label.cluster') }, + { id: 'host', description: _l('label.host') } + ]; + + args.response.success({ + data: scope + }); + } + }, zoneid: { label: 'Zone', docID: 'helpPrimaryStorageZone', @@ -8768,6 +8782,29 @@ } }, + hostId: { + label: 'label.host', + validation: { required: true }, + dependsOn: 'clusterId', + select: function(args) { + $.ajax({ + url: createURL('listHosts'), + data: { + clusterid: args.clusterId + }, + success: function(json) { + var hosts = json.listhostsresponse.host ? + json.listhostsresponse.host : [] + args.response.success({ + data: $.map(hosts, function(host) { + return { id: host.id, description: host.name } + }) + }); + } + }); + } + }, + name: { label: 'label.name', docID: 'helpPrimaryStorageName', From 6ef7928a9c342a99cfec2d471da3005e99a7afac Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 22 Feb 2013 02:53:26 +0530 Subject: [PATCH 2/3] zone wide primary storage --- ui/scripts/system.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 3c52442308c..375d7778bdc 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -8707,6 +8707,37 @@ args.response.success({ data: scope }); + + args.$select.change(function() { + var $form = $(this).closest('form'); + var scope = $(this).val(); + + if(scope == 'zone-wide'){ + $form.find('.form-item[rel=podId]').hide(); + $form.find('.form-item[rel=clusterId]').hide(); + $form.find('.form-item[rel=hostId]').hide(); + + + } + + else if(scope == 'cluster'){ + + $form.find('.form-item[rel=hostId]').hide(); + $form.find('.form-item[rel=podId]').css('display', 'inline-block'); + $form.find('.form-item[rel=clusterId]').css('display', 'inline-block'); + + + } + + else if(scope == 'host'){ + $form.find('.form-item[rel=podId]').css('display', 'inline-block'); + $form.find('.form-item[rel=clusterId]').css('display', 'inline-block'); + $form.find('.form-item[rel=hostId]').css('display', 'inline-block'); + + } + + }) + } }, zoneid: { @@ -8867,6 +8898,7 @@ var protocol = $(this).val(); if(protocol == null) return; + if(protocol == "nfs") { //$("#add_pool_server_container", $dialogAddPool).show(); From 31c26beb7f29c57012b22920014f5b18ef62f83f Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Fri, 22 Feb 2013 03:28:01 +0530 Subject: [PATCH 3/3] zone wide primary storage server side changes --- ui/scripts/system.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 375d7778bdc..997bd53f9af 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -8654,7 +8654,8 @@ name: { label: 'label.name' }, ipaddress: { label: 'label.server' }, path: { label: 'label.path' }, - clustername: { label: 'label.cluster'} + clustername: { label: 'label.cluster'}, + scope:{label:'Scope'} }, dataProvider: function(args) { @@ -9218,9 +9219,24 @@ action: function(args) { var array1 = []; + array1.push("&scope=" + todb(args.data.scope)); + array1.push("&zoneid=" + args.data.zoneid); - array1.push("&podId=" + args.data.podId); + + if(args.data.scope == 'cluster'){ + + array1.push("&podid=" + args.data.podId); array1.push("&clusterid=" + args.data.clusterId); + + } + + if(args.data.scope == 'host'){ + array1.push("&podid=" + args.data.podId); + array1.push("&clusterid=" + args.data.clusterId); + array1.push("&hostid=" + args.data.hostId); + + } + array1.push("&name=" + todb(args.data.name)); var server = args.data.server;