1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Feature #1207: Add custom input field for host drivers and user auth driver

(cherry picked from commit 01cef094183a0da70b19dcb730106950de85aa60)
This commit is contained in:
Hector Sanjuan 2012-04-25 13:13:17 +02:00 committed by Ruben S. Montero
parent 72892faa1f
commit 6c726bfe4e
2 changed files with 73 additions and 11 deletions

View File

@ -84,7 +84,11 @@ var create_host_tmpl =
<option value="vmm_vmware">' + tr("VMware") + '</option>\
<option value="vmm_ec2">' + tr("EC2") + '</option>\
<option value="vmm_dummy">' + tr("Dummy") + '</option>\
<option value="custom">' + tr("Custom") + '</option>\
</select>\
<div>\
<label>' + tr("Custom VMM_MAD") + ':</label>\
<input type="text" name="custom_vmm_mad" /></div>\
</div>\
<div class="manager clear" id="im_mads">\
<label>' + tr("Information Manager") + ':</label>\
@ -94,18 +98,28 @@ var create_host_tmpl =
<option value="im_vmware">' + tr("VMware") + '</option>\
<option value="im_ec2">' + tr("EC2") + '</option>\
<option value="im_dummy">' + tr("Dummy") + '</option>\
<option value="custom">' + tr("Custom") + '</option>\
</select>\
<div>\
<label>' + tr("Custom IM_MAD") + ':</label>\
<input type="text" name="custom_im_mad" />\
</div>\
</div>\
<div class="manager clear" id="vnm_mads">\
<label>Virtual Network Manager:</label>\
<select id="vnm_mad" name="vn">\
<option value="dummy">' + tr("Default (dummy)") +'</option>\
<option value="fw">Firewall</option>\
<option value="802.1Q">802.1Q</option>\
<option value="ebtables">Ebtables</option>\
<option value="ovswitch">Open vSwitch</option>\
<option value="vmware">VMware</option>\
<option value="fw">'+tr("Firewall")+'</option>\
<option value="802.1Q">'+tr("802.1Q")+'</option>\
<option value="ebtables">'+tr("Ebtables")+'</option>\
<option value="ovswitch">'+tr("Open vSwitch")+'</option>\
<option value="vmware">'+tr("VMware")+'</option>\
<option value="custom">' + tr("Custom") + '</option>\
</select>\
<div>\
<label>' + tr("Custom VNM_MAD") + ':</label>\
<input type="text" name="custom_vnm_mad" />\
</div>\
</div>\
<div class="manager clear" id="cluster_select">\
<label>' + tr("Cluster") + ':</label>\
@ -595,9 +609,35 @@ function setupCreateHostDialog(){
$('button',dialog).button();
$('input[name="custom_vmm_mad"],'+
'input[name="custom_im_mad"],'+
'input[name="custom_vnm_mad"]',dialog).parent().hide();
$('select#vmm_mad',dialog).change(function(){
if ($(this).val()=="custom")
$('input[name="custom_vmm_mad"]').parent().show();
else
$('input[name="custom_vmm_mad"]').parent().hide();
});
$('select#im_mad',dialog).change(function(){
if ($(this).val()=="custom")
$('input[name="custom_im_mad"]').parent().show();
else
$('input[name="custom_im_mad"]').parent().hide();
});
$('select#vnm_mad',dialog).change(function(){
if ($(this).val()=="custom")
$('input[name="custom_vnm_mad"]').parent().show();
else
$('input[name="custom_vnm_mad"]').parent().hide();
});
//Handle the form submission
$('#create_host_form',dialog).submit(function(){
if (!($('#name',this).val().length)){
var name = $('#name',this).val();
if (!name){
notifyError(tr("Host name missing!"));
return false;
}
@ -605,12 +645,19 @@ function setupCreateHostDialog(){
var cluster_id = $('#host_cluster_id',this).val();
if (!cluster_id) cluster_id = "-1";
var vmm_mad = $('select#vmm_mad',this).val();
vmm_mad = vmm_mad == "custom" ? $('input[name="custom_vmm_mad"]').val() : vmm_mad;
var im_mad = $('select#im_mad',this).val();
im_mad = im_mad == "custom" ? $('input[name="custom_im_mad"]').val() : im_mad;
var vnm_mad = $('select#vnm_mad',this).val();
vnm_mad = vnm_mad == "custom" ? $('input[name="custom_vnm_mad"]').val() : vnm_mad;
var host_json = {
"host": {
"name": $('#name',this).val(),
"vm_mad": $('#vmm_mad',this).val(),
"vnm_mad": $('#vnm_mad',this).val(),
"im_mad": $('#im_mad',this).val(),
"name": name,
"vm_mad": vmm_mad,
"vnm_mad": vnm_mad,
"im_mad": im_mad,
"cluster_id": cluster_id
}
};

View File

@ -60,7 +60,12 @@ var create_user_tmpl =
<option value="ssh">'+tr("SSH")+'</option>\
<option value="x509">'+tr("x509")+'</option>\
<option value="public">'+tr("Public")+'</option>\
<option value="custom">'+tr("Custom")+'</option>\
</select>\
<div>\
<label>'+tr("Custom auth driver")+':</label>\
<input type="text" name="custom_auth" /><br />\
</div>\
</div>\
</fieldset>\
<fieldset>\
@ -444,15 +449,25 @@ function setupCreateUserDialog(){
$('button',dialog).button();
$('input[name="custom_auth"]',dialog).parent().hide();
$('select#driver').change(function(){
if ($(this).val() == "custom")
$('input[name="custom_auth"]',dialog).parent().show();
else
$('input[name="custom_auth"]',dialog).parent().hide();
});
$('#create_user_form',dialog).submit(function(){
var user_name=$('#username',this).val();
var user_password=$('#pass',this).val();
var driver = $('#driver', this).val();
if (driver == 'custom')
driver = $('input[name="custom_auth"]').val();
if (!user_name.length || !user_password.length){
notifyError(tr("User name and password must be filled in"));
return false;
}
};
var user_json = { "user" :
{ "name" : user_name,