From e8e3698e4efda5fc814e33e4d04b02641e57ec8d Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 22 May 2012 13:45:35 -0700 Subject: [PATCH] Add cluster: conditionally hide vSwitch fields -When in add cluster screen, show the add vSwitch fields when hypervisor == VMware and 'vmware.use.nexus.vswitch' configuration flag is enabled. -Remove 'add Nexus vSwitch' checkbox, as the vSwitch fields will always be shown for VMware if the above config flag is set. --- ui/scripts/system.js | 49 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index f5f1d53c6cb..bcefbdb4748 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -6079,6 +6079,8 @@ hypervisor: { label: 'label.hypervisor', select: function(args) { + var vSwitchEnabled = false; + $.ajax({ url: createURL("listHypervisors"), dataType: "json", @@ -6093,31 +6095,47 @@ } }); + // Check whether vSwitch capability is enabled + $.ajax({ + url: createURL('listConfigurations'), + data: { + name: 'vmware.use.nexus.vswitch' + }, + async: false, + success: function(json) { + if (json.listconfigurationsresponse.configuration[0].value == 'true') { + vSwitchEnabled = true; + } + } + }); + args.$select.bind("change", function(event) { var $form = $(this).closest('form'); - if($(this).val() == "VMware") { + var $vsmFields = $.merge( + $form.find('.form-item[rel=vsmipaddress]'), + $form.find('.form-item[rel=vsmusername]'), + $form.find('.form-item[rel=vsmpassword]') + ); + + if ($(this).val() == "VMware") { //$('li[input_sub_group="external"]', $dialogAddCluster).show(); $form.find('.form-item[rel=vCenterHost]').css('display', 'inline-block'); $form.find('.form-item[rel=vCenterUsername]').css('display', 'inline-block'); $form.find('.form-item[rel=vCenterPassword]').css('display', 'inline-block'); $form.find('.form-item[rel=vCenterDatacenter]').css('display', 'inline-block'); - $form.find('.form-item[rel=enableNexusVswitch]').css('display', 'inline-block'); - //$("#cluster_name_label", $dialogAddCluster).text("vCenter Cluster:"); - } - else { - //$('li[input_group="vmware"]', $dialogAddCluster).hide(); + if (vSwitchEnabled) { + $vsmFields.css('display', 'inline-block'); + } else { + $vsmFields.css('display', 'none'); + } + } else { $form.find('.form-item[rel=vCenterHost]').css('display', 'none'); $form.find('.form-item[rel=vCenterUsername]').css('display', 'none'); $form.find('.form-item[rel=vCenterPassword]').css('display', 'none'); $form.find('.form-item[rel=vCenterDatacenter]').css('display', 'none'); $form.find('.form-item[rel=enableNexusVswitch]').css('display', 'none'); - $('.form-item[rel=enableNexusVswitch] input').attr('checked', false); - $form.find('.form-item[rel=nexusVswitchIpAddress]').css('display', 'none'); - $form.find('.form-item[rel=nexusVswitchUsername]').css('display', 'none'); - $form.find('.form-item[rel=nexusVswitchPassword]').css('display', 'none'); - - //$("#cluster_name_label", $dialogAddCluster).text("Cluster:"); + $vsmFields.css('display', 'none'); } }); } @@ -6167,25 +6185,18 @@ label: 'label.vcenter.datacenter', validation: { required: true } }, - enableNexusVswitch: { - label: 'Add Nexus vSwitch', - isBoolean: true - }, vsmipaddress: { label: 'vSwitch IP Address', - dependsOn: 'enableNexusVswitch', validation: { required: true }, isHidden: true }, vsmusername: { label: 'vSwitch Username', - dependsOn: 'enableNexusVswitch', validation: { required: true }, isHidden: true }, vsmpassword: { label: 'vSwitch Password', - dependsOn: 'enableNexusVswitch', validation: { required: true }, isPassword: true, isHidden: true