Skip to content

Commit e8e3698

Browse files
committed
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.
1 parent d64adf1 commit e8e3698

1 file changed

Lines changed: 30 additions & 19 deletions

File tree

‎ui/scripts/system.js‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6079,6 +6079,8 @@
60796079
hypervisor: {
60806080
label: 'label.hypervisor',
60816081
select: function(args) {
6082+
var vSwitchEnabled = false;
6083+
60826084
$.ajax({
60836085
url: createURL("listHypervisors"),
60846086
dataType: "json",
@@ -6093,31 +6095,47 @@
60936095
}
60946096
});
60956097

6098+
// Check whether vSwitch capability is enabled
6099+
$.ajax({
6100+
url: createURL('listConfigurations'),
6101+
data: {
6102+
name: 'vmware.use.nexus.vswitch'
6103+
},
6104+
async: false,
6105+
success: function(json) {
6106+
if (json.listconfigurationsresponse.configuration[0].value == 'true') {
6107+
vSwitchEnabled = true;
6108+
}
6109+
}
6110+
});
6111+
60966112
args.$select.bind("change", function(event) {
60976113
var $form = $(this).closest('form');
6098-
if($(this).val() == "VMware") {
6114+
var $vsmFields = $.merge(
6115+
$form.find('.form-item[rel=vsmipaddress]'),
6116+
$form.find('.form-item[rel=vsmusername]'),
6117+
$form.find('.form-item[rel=vsmpassword]')
6118+
);
6119+
6120+
if ($(this).val() == "VMware") {
60996121
//$('li[input_sub_group="external"]', $dialogAddCluster).show();
61006122
$form.find('.form-item[rel=vCenterHost]').css('display', 'inline-block');
61016123
$form.find('.form-item[rel=vCenterUsername]').css('display', 'inline-block');
61026124
$form.find('.form-item[rel=vCenterPassword]').css('display', 'inline-block');
61036125
$form.find('.form-item[rel=vCenterDatacenter]').css('display', 'inline-block');
6104-
$form.find('.form-item[rel=enableNexusVswitch]').css('display', 'inline-block');
61056126

6106-
//$("#cluster_name_label", $dialogAddCluster).text("vCenter Cluster:");
6107-
}
6108-
else {
6109-
//$('li[input_group="vmware"]', $dialogAddCluster).hide();
6127+
if (vSwitchEnabled) {
6128+
$vsmFields.css('display', 'inline-block');
6129+
} else {
6130+
$vsmFields.css('display', 'none');
6131+
}
6132+
} else {
61106133
$form.find('.form-item[rel=vCenterHost]').css('display', 'none');
61116134
$form.find('.form-item[rel=vCenterUsername]').css('display', 'none');
61126135
$form.find('.form-item[rel=vCenterPassword]').css('display', 'none');
61136136
$form.find('.form-item[rel=vCenterDatacenter]').css('display', 'none');
61146137
$form.find('.form-item[rel=enableNexusVswitch]').css('display', 'none');
6115-
$('.form-item[rel=enableNexusVswitch] input').attr('checked', false);
6116-
$form.find('.form-item[rel=nexusVswitchIpAddress]').css('display', 'none');
6117-
$form.find('.form-item[rel=nexusVswitchUsername]').css('display', 'none');
6118-
$form.find('.form-item[rel=nexusVswitchPassword]').css('display', 'none');
6119-
6120-
//$("#cluster_name_label", $dialogAddCluster).text("Cluster:");
6138+
$vsmFields.css('display', 'none');
61216139
}
61226140
});
61236141
}
@@ -6167,25 +6185,18 @@
61676185
label: 'label.vcenter.datacenter',
61686186
validation: { required: true }
61696187
},
6170-
enableNexusVswitch: {
6171-
label: 'Add Nexus vSwitch',
6172-
isBoolean: true
6173-
},
61746188
vsmipaddress: {
61756189
label: 'vSwitch IP Address',
6176-
dependsOn: 'enableNexusVswitch',
61776190
validation: { required: true },
61786191
isHidden: true
61796192
},
61806193
vsmusername: {
61816194
label: 'vSwitch Username',
6182-
dependsOn: 'enableNexusVswitch',
61836195
validation: { required: true },
61846196
isHidden: true
61856197
},
61866198
vsmpassword: {
61876199
label: 'vSwitch Password',
6188-
dependsOn: 'enableNexusVswitch',
61896200
validation: { required: true },
61906201
isPassword: true,
61916202
isHidden: true

0 commit comments

Comments
 (0)