mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-29 18:50:08 +03:00
Feature #4012: Make vcenter and opennebula contextualization mutually exclusive
This commit is contained in:
parent
639fede40d
commit
a1ba03fc74
@ -89,6 +89,21 @@ define(function(require) {
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
$("input[name='context_type']", context).on("change", function() {
|
||||
$(".context_type", context).hide();
|
||||
$("."+$(this).val(), context).show();
|
||||
});
|
||||
|
||||
$("input#context_type_opennebula", context).click();
|
||||
|
||||
$("#template_hypervisor_form input[name='hypervisor']").on("change", function(){
|
||||
if(this.value == "vcenter"){
|
||||
$("input#context_type_vcenter", context).click();
|
||||
} else {
|
||||
$("input#context_type_opennebula", context).click();
|
||||
}
|
||||
});
|
||||
|
||||
context.on("change", "select#vcenter_customizations", function(){
|
||||
var option = $("option:selected", this);
|
||||
|
||||
@ -192,67 +207,93 @@ define(function(require) {
|
||||
|
||||
function _retrieve(context) {
|
||||
var templateJSON = {};
|
||||
var contextJSON = WizardFields.retrieve(context);
|
||||
$.extend(contextJSON, CustomTagsTable.retrieve(context));
|
||||
|
||||
var customization = $('input#vcenter_customizations_value', context).val();
|
||||
if($("input[name='context_type']:checked", context).val() == "context_type_vcenter"){
|
||||
var customization = $('input#vcenter_customizations_value', context).val();
|
||||
|
||||
if (customization) {
|
||||
templateJSON["VCENTER_PUBLIC_CLOUD"] = {
|
||||
CUSTOMIZATION_SPEC : customization
|
||||
};
|
||||
if (customization) {
|
||||
templateJSON["VCENTER_PUBLIC_CLOUD"] = {
|
||||
CUSTOMIZATION_SPEC : customization
|
||||
};
|
||||
}
|
||||
} else {
|
||||
var contextJSON = WizardFields.retrieve(context);
|
||||
$.extend(contextJSON, CustomTagsTable.retrieve(context));
|
||||
|
||||
if ($("#ssh_context", context).is(":checked")) {
|
||||
var public_key = $("#ssh_public_key", context).val();
|
||||
if (public_key) {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = TemplateUtils.escapeDoubleQuotes(public_key);
|
||||
} else {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = '$USER[SSH_PUBLIC_KEY]';
|
||||
}
|
||||
}
|
||||
|
||||
if ($("#network_context", context).is(":checked")) {
|
||||
contextJSON["NETWORK"] = "YES";
|
||||
}
|
||||
|
||||
if ($("#token_context", context).is(":checked")) {
|
||||
contextJSON["TOKEN"] = "YES";
|
||||
}
|
||||
|
||||
var userInputsJSON = {};
|
||||
$(".service_custom_attrs tbody tr", context).each(function() {
|
||||
if ($(".user_input_name", $(this)).val()) {
|
||||
var attr_name = $(".user_input_name", $(this)).val();
|
||||
var attr_type = $(".user_input_type", $(this)).val();
|
||||
var attr_desc = $(".user_input_description", $(this)).val();
|
||||
userInputsJSON[attr_name] = "M|" + attr_type + "|" + attr_desc;
|
||||
contextJSON[attr_name] = "$" + attr_name.toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
var start_script = $("#START_SCRIPT", context).val();
|
||||
if (start_script != "") {
|
||||
if ($("#ENCODE_START_SCRIPT", context).is(":checked")) {
|
||||
contextJSON["START_SCRIPT_BASE64"] = btoa(start_script);
|
||||
} else {
|
||||
contextJSON["START_SCRIPT"] = start_script;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$.isEmptyObject(contextJSON)) { templateJSON['CONTEXT'] = contextJSON; };
|
||||
if (!$.isEmptyObject(userInputsJSON)) { templateJSON['USER_INPUTS'] = userInputsJSON; };
|
||||
}
|
||||
|
||||
if ($("#ssh_context", context).is(":checked")) {
|
||||
var public_key = $("#ssh_public_key", context).val();
|
||||
if (public_key) {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = TemplateUtils.escapeDoubleQuotes(public_key);
|
||||
} else {
|
||||
contextJSON["SSH_PUBLIC_KEY"] = '$USER[SSH_PUBLIC_KEY]';
|
||||
}
|
||||
};
|
||||
|
||||
if ($("#network_context", context).is(":checked")) {
|
||||
contextJSON["NETWORK"] = "YES";
|
||||
};
|
||||
|
||||
if ($("#token_context", context).is(":checked")) {
|
||||
contextJSON["TOKEN"] = "YES";
|
||||
};
|
||||
|
||||
var userInputsJSON = {};
|
||||
$(".service_custom_attrs tbody tr", context).each(function() {
|
||||
if ($(".user_input_name", $(this)).val()) {
|
||||
var attr_name = $(".user_input_name", $(this)).val();
|
||||
var attr_type = $(".user_input_type", $(this)).val();
|
||||
var attr_desc = $(".user_input_description", $(this)).val();
|
||||
userInputsJSON[attr_name] = "M|" + attr_type + "|" + attr_desc;
|
||||
contextJSON[attr_name] = "$" + attr_name.toUpperCase();
|
||||
}
|
||||
});
|
||||
|
||||
var start_script = $("#START_SCRIPT", context).val();
|
||||
if (start_script != "") {
|
||||
if ($("#ENCODE_START_SCRIPT", context).is(":checked")) {
|
||||
contextJSON["START_SCRIPT_BASE64"] = btoa(start_script);
|
||||
} else {
|
||||
contextJSON["START_SCRIPT"] = start_script;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$.isEmptyObject(contextJSON)) { templateJSON['CONTEXT'] = contextJSON; };
|
||||
if (!$.isEmptyObject(userInputsJSON)) { templateJSON['USER_INPUTS'] = userInputsJSON; };
|
||||
|
||||
return templateJSON;
|
||||
}
|
||||
|
||||
function _fill(context, templateJSON) {
|
||||
var that = this;
|
||||
$("#ssh_context", context).removeAttr('checked');
|
||||
$("#network_context", context).removeAttr('checked');
|
||||
|
||||
var contextJSON = templateJSON['CONTEXT'];
|
||||
var userInputsJSON = templateJSON['USER_INPUTS'];
|
||||
var publicClouds = templateJSON["PUBLIC_CLOUD"];
|
||||
|
||||
if (publicClouds != undefined) {
|
||||
if (!$.isArray(publicClouds)){
|
||||
publicClouds = [publicClouds];
|
||||
}
|
||||
|
||||
$.each(publicClouds, function(){
|
||||
if(this["TYPE"] == "vcenter"){
|
||||
$("input#context_type_vcenter", context).click();
|
||||
|
||||
if(this["CUSTOMIZATION_SPEC"]){
|
||||
$('input#vcenter_customizations_value', context).val(this["CUSTOMIZATION_SPEC"]).change();
|
||||
} else if(userInputsJSON || contextJSON) {
|
||||
$("input#context_type_opennebula", context).click();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#ssh_context", context).removeAttr('checked');
|
||||
$("#network_context", context).removeAttr('checked');
|
||||
|
||||
if (userInputsJSON) {
|
||||
$.each(userInputsJSON, function(key, value) {
|
||||
$(".add_service_custom_attr", context).trigger("click");
|
||||
@ -271,21 +312,6 @@ define(function(require) {
|
||||
delete templateJSON['USER_INPUTS'];
|
||||
}
|
||||
|
||||
var publicClouds = templateJSON["PUBLIC_CLOUD"];
|
||||
|
||||
if (publicClouds != undefined) {
|
||||
if (!$.isArray(publicClouds)){
|
||||
publicClouds = [publicClouds];
|
||||
}
|
||||
|
||||
$.each(publicClouds, function(){
|
||||
if(this["TYPE"] == "vcenter"){
|
||||
$('input#vcenter_customizations_value', context).val(this["CUSTOMIZATION_SPEC"]).change();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (contextJSON) {
|
||||
var file_ds_regexp = /\$FILE\[IMAGE_ID=([0-9]+)+/g;
|
||||
var net_regexp = /^NETWORK$/;;
|
||||
|
@ -14,136 +14,148 @@
|
||||
{{! limitations under the License. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<dl id="context_tabs" class="tabs vertical" data-tab>
|
||||
<dd class="active">
|
||||
<a href="#netsshTab">{{tr "Configuration"}}</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#filesTab">{{tr "Files"}}</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#zcustomTab">{{tr "Custom vars"}}</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="tabs-content vertical">
|
||||
<div class="wizard_internal_tab active content" id="netsshTab">
|
||||
<div class="row hypervisor only_vcenter" style="display: none;">
|
||||
<div class="columns medium-6">
|
||||
<label for="vcenter_customizations">{{tr "vCenter customizations"}}:</label>
|
||||
<select id="vcenter_customizations"/>
|
||||
</div>
|
||||
<div class="columns medium-6">
|
||||
<label> </label>
|
||||
<input id="vcenter_customizations_value" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="columns medium-6">
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="ssh_context" id="ssh_context" checked>
|
||||
<label for="ssh_context">
|
||||
{{tr " Add SSH contextualization"}}
|
||||
{{{tip (tr "Add an ssh public key to the context. If the Public Key textarea is empty then the user variable SSH_PUBLIC_KEY will be used.")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="ssh_public_key">{{tr "Public Key"}}:</label>
|
||||
<textarea rows="2" type="text" id="ssh_public_key" name="ssh_public_key" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns medium-6">
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="network_context" id="network_context" checked>
|
||||
<label for="network_context">
|
||||
{{tr " Add Network contextualization"}}
|
||||
{{{tip (tr "Add network contextualization parameters. For each NIC defined in the NETWORK section, ETH$i_IP, ETH$i_NETWORK... parameters will be included in the CONTEXT section and will be available in the Virtual Machine")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="token_context" id="token_context">
|
||||
<label for="token_context">
|
||||
{{tr " Add OneGate token"}}
|
||||
{{{tip (tr "Add a file (token.txt) to the context contaning the token to push custom metrics to the VirtualMachine through OneGate")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="START_SCRIPT">
|
||||
{{tr "Start Script"}}
|
||||
{{{tip (tr "Text of the script executed when the machine starts up. It can contain shebang in case it is not shell script. For example 'yum upgrade'")}}}
|
||||
</label>
|
||||
<textarea rows="4" type="text" id="START_SCRIPT" name="START_SCRIPT" />
|
||||
<input type="checkbox" name="ENCODE_START_SCRIPT" id="ENCODE_START_SCRIPT">
|
||||
<label for="ENCODE_START_SCRIPT">
|
||||
{{tr " Encode Script in Base64"}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table class="service_custom_attrs policies_table dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" style="font-size: 16px !important"> <i class="fa fa-lg fa-fw fa-cogs off-color"/>{{tr "User Inputs"}}
|
||||
{{{tip (tr "These attributes must be provided by the user when a new VM is intantatiated using each template. They will be included in the VM context")}}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:30%">{{tr "Name"}}</th>
|
||||
<th style="width:20%">{{tr "Type"}}</th>
|
||||
<th style="width:50%">{{tr "Description"}}</th>
|
||||
<th style="width:3%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<a href="#" class="add_service_custom_attr button small small-12 secondary radius">
|
||||
<i class="fa fa-plus"></i>
|
||||
{{tr "Add another attribute"}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row hypervisor only_vcenter" style="display: none;">
|
||||
<div class="large-12 columns text-center">
|
||||
<label>{{tr "Contextualization type"}}</label>
|
||||
<input type="radio" name="context_type" id="context_type_vcenter" value="context_type_vcenter">
|
||||
<label for="context_type_vcenter">{{tr "vCenter"}}</label>
|
||||
<input type="radio" name="context_type" id="context_type_opennebula" value="context_type_opennebula">
|
||||
<label for="context_type_opennebula">{{tr "OpenNebula"}}</label>
|
||||
</div>
|
||||
<div class="wizard_internal_tab content" id="filesTab">
|
||||
{{{contextFilesTableHTML}}}
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="FILES_DS">
|
||||
{{tr "FILES_DS"}}
|
||||
{{{tip (tr "Raw String for the FILE_DS attribute of the VM template, representing files that will be included in the contextualization image. Each file must be stored in a FILE_DS Datastore and must be of type CONTEXT")}}}
|
||||
</label>
|
||||
<input type="text" wizard_field="FILES_DS" id="FILES_DS" name="FILES_DS" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="INIT_SCRIPTS">
|
||||
{{tr "Init scripts"}}
|
||||
{{{tip (tr "If the VM uses the OpenNebula contextualization package the init.sh file is executed by default. When the init script added is not called init.sh or more than one init script is added, this list contains the scripts to run and the order. Ex. “init.sh users.sh mysql.sh”")}}}
|
||||
</label>
|
||||
<input type="text" wizard_field="FILES_DS" id="INIT_SCRIPTS" name="INIT_SCRIPTS" />
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
</div>
|
||||
<div class="row hypervisor only_vcenter context_type context_type_vcenter" style="display: none;">
|
||||
<div class="columns medium-6">
|
||||
<label for="vcenter_customizations">{{tr "vCenter customizations"}}:</label>
|
||||
<select id="vcenter_customizations"/>
|
||||
</div>
|
||||
<div class="wizard_internal_tab content" id="zcustomTab">
|
||||
{{{customTagsTableHTML}}}
|
||||
<div class="columns medium-6">
|
||||
<label> </label>
|
||||
<input id="vcenter_customizations_value" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="context_type context_type_opennebula">
|
||||
<dl id="context_tabs" class="tabs vertical" data-tab>
|
||||
<dd class="active">
|
||||
<a href="#netsshTab">{{tr "Configuration"}}</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#filesTab">{{tr "Files"}}</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#zcustomTab">{{tr "Custom vars"}}</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="tabs-content vertical">
|
||||
<div class="wizard_internal_tab active content" id="netsshTab">
|
||||
<div class="row">
|
||||
<div class="columns medium-6">
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="ssh_context" id="ssh_context" checked>
|
||||
<label for="ssh_context">
|
||||
{{tr " Add SSH contextualization"}}
|
||||
{{{tip (tr "Add an ssh public key to the context. If the Public Key textarea is empty then the user variable SSH_PUBLIC_KEY will be used.")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="ssh_public_key">{{tr "Public Key"}}:</label>
|
||||
<textarea rows="2" type="text" id="ssh_public_key" name="ssh_public_key" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns medium-6">
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="network_context" id="network_context" checked>
|
||||
<label for="network_context">
|
||||
{{tr " Add Network contextualization"}}
|
||||
{{{tip (tr "Add network contextualization parameters. For each NIC defined in the NETWORK section, ETH$i_IP, ETH$i_NETWORK... parameters will be included in the CONTEXT section and will be available in the Virtual Machine")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="columns large-12">
|
||||
<input type="checkbox" name="token_context" id="token_context">
|
||||
<label for="token_context">
|
||||
{{tr " Add OneGate token"}}
|
||||
{{{tip (tr "Add a file (token.txt) to the context contaning the token to push custom metrics to the VirtualMachine through OneGate")}}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="START_SCRIPT">
|
||||
{{tr "Start Script"}}
|
||||
{{{tip (tr "Text of the script executed when the machine starts up. It can contain shebang in case it is not shell script. For example 'yum upgrade'")}}}
|
||||
</label>
|
||||
<textarea rows="4" type="text" id="START_SCRIPT" name="START_SCRIPT" />
|
||||
<input type="checkbox" name="ENCODE_START_SCRIPT" id="ENCODE_START_SCRIPT">
|
||||
<label for="ENCODE_START_SCRIPT">
|
||||
{{tr " Encode Script in Base64"}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<table class="service_custom_attrs policies_table dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" style="font-size: 16px !important"> <i class="fa fa-lg fa-fw fa-cogs off-color"/>{{tr "User Inputs"}}
|
||||
{{{tip (tr "These attributes must be provided by the user when a new VM is intantatiated using each template. They will be included in the VM context")}}}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:30%">{{tr "Name"}}</th>
|
||||
<th style="width:20%">{{tr "Type"}}</th>
|
||||
<th style="width:50%">{{tr "Description"}}</th>
|
||||
<th style="width:3%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<a href="#" class="add_service_custom_attr button small small-12 secondary radius">
|
||||
<i class="fa fa-plus"></i>
|
||||
{{tr "Add another attribute"}}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wizard_internal_tab content" id="filesTab">
|
||||
{{{contextFilesTableHTML}}}
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="FILES_DS">
|
||||
{{tr "FILES_DS"}}
|
||||
{{{tip (tr "Raw String for the FILE_DS attribute of the VM template, representing files that will be included in the contextualization image. Each file must be stored in a FILE_DS Datastore and must be of type CONTEXT")}}}
|
||||
</label>
|
||||
<input type="text" wizard_field="FILES_DS" id="FILES_DS" name="FILES_DS" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<label for="INIT_SCRIPTS">
|
||||
{{tr "Init scripts"}}
|
||||
{{{tip (tr "If the VM uses the OpenNebula contextualization package the init.sh file is executed by default. When the init script added is not called init.sh or more than one init script is added, this list contains the scripts to run and the order. Ex. “init.sh users.sh mysql.sh”")}}}
|
||||
</label>
|
||||
<input type="text" wizard_field="FILES_DS" id="INIT_SCRIPTS" name="INIT_SCRIPTS" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wizard_internal_tab content" id="zcustomTab">
|
||||
{{{customTagsTableHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -109,6 +109,8 @@ define(function(require) {
|
||||
// TODO define context (for example: this.closest('form'))
|
||||
$(".hypervisor").hide();
|
||||
$(".only_" + this.value).show();
|
||||
|
||||
// There is another listener in context.js setup
|
||||
});
|
||||
|
||||
CapacityInputs.setup(context);
|
||||
|
Loading…
x
Reference in New Issue
Block a user