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

Feature #3907: Sane defaults for Image creation fields

This commit is contained in:
Jaime Melis 2016-05-05 18:36:03 +02:00
parent 7cc2a2db7c
commit 569b0feebe
2 changed files with 91 additions and 22 deletions

View File

@ -166,7 +166,7 @@ define(function(require) {
$('#img_persistent', context).prop('disabled', false);
}
// Set the dialog
// Display adequate values in the dialog.
switch (mad) {
case "vcenter":
$(".only_vcenter").show();
@ -176,6 +176,13 @@ define(function(require) {
$(".only_vcenter").hide();
$(".not_vcenter").show();
}
// Fill in the default driver
if (tm_mad == "qcow2"){
$('select#img_driver',context).val("qcow2");
} else {
$('select#img_driver',context).val("raw");
}
},
error: function(request, error_json, container){
Notifier.onError(request, error_json, container);
@ -183,6 +190,27 @@ define(function(require) {
});
});
// Custom Adapter Type
var custom_attrs = ["adapter_type",
"disk_type",
"img_dev_prefix",
"img_driver"];
for (var i in custom_attrs){
var field = custom_attrs[i];
$('input[name="custom_'+field+'"]',context).parent().hide();
$('select#'+field,context).change(function(){
var field = $(this).attr('name');
if ($(this).val() == "custom"){
$('input[name="custom_'+field+'"]',context).parent().show();
$('input[name="custom_'+field+'"]',context).attr('required', '');
} else {
$('input[name="custom_'+field+'"]',context).parent().hide();
$('input[name="custom_'+field+'"]',context).removeAttr('required');
}
});
}
$('#img_path,#img_fstype,#img_size,#file-uploader', context).closest('.row').hide();
$("input[name='src_path']", context).change(function() {
@ -304,12 +332,12 @@ define(function(require) {
img_json["TARGET"] = target;
var adapter_type = WizardFields.retrieveInput($('#adapter_type', context));
if (adapter_type)
img_json["ADAPTER_TYPE"] = adapter_type;
var disk_type = WizardFields.retrieveInput($('#disk_type', context));
if (disk_type)
img_json["DISK_TYPE"] = disk_type;
if (adapter_type) {
if (adapter_type == "custom") {
adapter_type = WizardFields.retrieveInput($('#custom_adapter_type', context));
}
img_json["ADAPTER_TYPE"] = adapter_type;
}
switch ($('#src_path_select input:checked', context).val()){
case "path":
@ -321,6 +349,15 @@ define(function(require) {
fstype = WizardFields.retrieveInput($('#img_fstype', context));
if (size) img_json["SIZE"] = size;
if (fstype) img_json["FSTYPE"] = fstype;
var disk_type = WizardFields.retrieveInput($('#disk_type', context));
if (disk_type) {
if (disk_type == "custom"){
disk_type = WizardFields.retrieveInput($('#custom_disk_type', context));
}
img_json["DISK_TYPE"] = disk_type;
}
break;
case "upload":
upload = true;

View File

@ -116,6 +116,25 @@
</label>
<input type="text" name="img_size" id="img_size" />
</div>
<div class="medium-6 columns only_vcenter">
<label for="disk_type">
{{tr "Disk Provisioning"}}
<span class="tip">
{{tr "Parameter to instruct vCenter on the type of disk to be created"}}
{{tr "The type of disk has implications on performance and occupied space. Values (careful with the case): delta,eagerZeroedThick,flatMonolithic,preallocated,raw,rdm,rdmp,seSparse,sparse2Gb,sparseMonolithic,thick,thick2Gb,thin. Default value is thin."}}
</span>
</label>
<select name="disk_type" id="disk_type">
<option value="" selected="selected"></option>
<option value="thin">Thin</option>
<option value="thick">Thick</option>
<option value="eagerZeroedThick">Eager Zeroed Thick</option>
<option value="custom">custom</option>
</select>
<div>
<input type="text" id="custom_disk_type" name="custom_disk_type" />
</div>
</div>
</div>
</fieldset>
{{#advancedSection (tr "Advanced Options") }}
@ -130,7 +149,16 @@
{{tr "Types of adapters used by virtual disks to plug into VMs. Values (careful with the case): lsiLogic, ide, busLogic."}}
</span>
</label>
<input type="text" name="adapter_type" id="adapter_type" />
<select name="adapter_type" id="adapter_type">
<option value="" selected="selected"></option>
<option value="lsiLogic">lsiLogic</option>
<option value="ide">ide</option>
<option value="busLogic">busLogic</option>
<option value="custom">custom</option>
</select>
<div>
<input type="text" id="custom_adapter_type" name="custom_adapter_type" />
</div>
</div>
</div>
<div class="row not_vcenter">
@ -141,7 +169,16 @@
{{tr "The BUS where the image will be connected to. If a custom is selected the actual Device Prefix should be typed. For example: “hd”, “sd”. If omitted, the default value is the DEFAULT_DEV_PREFIX defined in oned.conf (installation default is “hd”)."}}
</span>
</label>
<input type="text" name="img_dev_prefix" id="img_dev_prefix" />
<select name="img_dev_prefix" id="img_dev_prefix">
<option value="" selected="selected"></option>
<option value="vd">virtio</option>
<option value="hd">ide</option>
<option value="sd">scsi</option>
<option value="custom">custom</option>
</select>
<div>
<input type="text" id="custom_img_dev_prefix" name="custom_img_dev_prefix" />
</div>
</div>
</div>
<div class="row not_vcenter">
@ -152,23 +189,18 @@
{{tr "Specific image mapping driver. KVM: raw, qcow2."}}
</span>
</label>
<input type="text" name="img_driver" id="img_driver" />
<select name="img_driver" id="img_driver">
<option value="raw" selected="selected">raw</option>
<option value="qcow2">qcow2</option>
<option value="custom">custom</option>
</select>
<div>
<input type="text" id="custom_img_driver" name="custom_img_driver" />
</div>
</div>
</div>
</div>
<div class="medium-6 columns">
<div class="row only_vcenter">
<div class="large-12 columns">
<label for="disk_type">
{{tr "Disk Provisioning"}}
<span class="tip">
{{tr "Parameter to instruct vCenter on the type of disk to be created"}}
{{tr "The type of disk has implications on performance and occupied space. Values (careful with the case): delta,eagerZeroedThick,flatMonolithic,preallocated,raw,rdm,rdmp,seSparse,sparse2Gb,sparseMonolithic,thick,thick2Gb,thin."}}
</span>
</label>
<input type="text" name="disk_type" id="disk_type" />
</div>
</div>
<div class="row not_vcenter">
<div class="large-12 columns">
<label for="img_target">