mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 20:02:38 +09:00
feature #3748: Add host form panel creation
This commit is contained in:
1 parent
885975fc5d
commit
17daf6bcae
5 files changed
+700
-6
No files matched your search
@@ -20,6 +20,10 @@ define(function(require) {
|
||||
require('./hosts-tab/panels/esx')
|
||||
];
|
||||
|
||||
var _formPanels = [
|
||||
require('./hosts-tab/form-panels/create')
|
||||
]
|
||||
|
||||
var Tab = {
|
||||
tabId: TAB_ID,
|
||||
title: Locale.tr("Hosts"),
|
||||
@@ -37,6 +41,7 @@ define(function(require) {
|
||||
actions: Actions,
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
panels: _panels,
|
||||
formPanels: _formPanels,
|
||||
//dialogs: _dialogs
|
||||
};
|
||||
|
||||
|
||||
@@ -6,25 +6,29 @@ define(function(require) {
|
||||
var OpenNebulaHost = require('opennebula/host');
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
var CREATE_DIALOG_ID = require('./dialogs/create/dialogId');
|
||||
var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
|
||||
var _actions = {
|
||||
"Host.create" : {
|
||||
type: "create",
|
||||
call : OpenNebulaHost.create,
|
||||
callback : function(request, response) {
|
||||
Sunstone.getDialog(CREATE_DIALOG_ID).hide();
|
||||
Sunstone.getDialog(CREATE_DIALOG_ID).reset();
|
||||
DataTable.addElement(request, response);
|
||||
$("a[href=back]", $("#"+TAB_ID)).trigger("click");
|
||||
Sunstone.hideFormPanelLoading($("#"+TAB_ID));
|
||||
Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading($("#" + TAB_ID));
|
||||
Notifier.onError(request, response);
|
||||
},
|
||||
error: Notifier.onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Host.create_dialog" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
Sunstone.getDialog(CREATE_DIALOG_ID).show();
|
||||
Sunstone.showFormPanel(TAB_ID, CREATE_DIALOG_ID, "create");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,543 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseFormPanel = require('utils/form-panels/form-panel');
|
||||
var Sunstone = require('sunstone');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var Notifier = require('utils/notifier');
|
||||
var ResourceSelect = require('utils/resource-select')
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
*/
|
||||
|
||||
var TemplateWizardHTML = require('hbs!./create/wizard');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var FORM_PANEL_ID = require('./create/formPanelId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function FormPanel() {
|
||||
this.formPanelId = FORM_PANEL_ID;
|
||||
this.actions = {
|
||||
'create': {
|
||||
'title': Locale.tr("Create Host"),
|
||||
'buttonText': Locale.tr("Create"),
|
||||
'resetButton': true
|
||||
}
|
||||
}
|
||||
|
||||
BaseFormPanel.call(this);
|
||||
};
|
||||
|
||||
FormPanel.FORM_PANEL_ID = FORM_PANEL_ID;
|
||||
FormPanel.prototype = Object.create(BaseFormPanel.prototype);
|
||||
FormPanel.prototype.constructor = FormPanel;
|
||||
FormPanel.prototype.htmlWizard = _htmlWizard;
|
||||
FormPanel.prototype.submitWizard = _submitWizard;
|
||||
FormPanel.prototype.onShow = _onShow;
|
||||
FormPanel.prototype.setup = _setup;
|
||||
|
||||
return FormPanel;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _htmlWizard() {
|
||||
return TemplateWizardHTML({formPanelId: this.formPanelId});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
|
||||
$(".drivers", context).hide();
|
||||
|
||||
$("#host_type_mad", context).on("change", function() {
|
||||
$("#vmm_mad", context).val(this.value).change();
|
||||
$("#im_mad", context).val(this.value).change();
|
||||
|
||||
if (this.value == "custom") {
|
||||
$(".vcenter_credentials", context).hide();
|
||||
$("#vnm_mads", context).show();
|
||||
$("#name_container", context).show();
|
||||
$("#create_host_submit", context).show();
|
||||
$(".drivers", context).show();
|
||||
} else if (this.value == "vcenter") {
|
||||
$("#vnm_mads", context).hide();
|
||||
$("#name_container", context).hide();
|
||||
$(".vcenter_credentials", context).show();
|
||||
$("#create_host_submit", context).hide();
|
||||
$(".drivers", context).hide();
|
||||
} else {
|
||||
$(".vcenter_credentials", context).hide();
|
||||
$("#vnm_mads", context).show();
|
||||
$("#name_container", context).show();
|
||||
$("#create_host_submit", context).show();
|
||||
$(".drivers", context).hide();
|
||||
}
|
||||
})
|
||||
|
||||
/* TODO
|
||||
$("#get_vcenter_clusters", context).on("click", function() {
|
||||
// TODO notify if credentials empty
|
||||
var container = $(".vcenter_clusters", context);
|
||||
|
||||
container.html(generateAdvancedSection({
|
||||
html_id: "/vcenter",
|
||||
title: Locale.tr("Clusters"),
|
||||
content: '<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>'
|
||||
}))
|
||||
|
||||
$('a', container).trigger("click")
|
||||
|
||||
$.ajax({
|
||||
url: 'vcenter',
|
||||
type: "GET",
|
||||
data: {timeout: false},
|
||||
dataType: "json",
|
||||
headers: {
|
||||
"X_VCENTER_USER": $("#vcenter_user", context).val(),
|
||||
"X_VCENTER_PASSWORD": $("#vcenter_password", context).val(),
|
||||
"X_VCENTER_HOST": $("#vcenter_host", context).val()
|
||||
},
|
||||
success: function(response) {
|
||||
$("#vcenter_user", context).atLocale.tr("disabled", "disabled")
|
||||
$("#vcenter_password", context).atLocale.tr("disabled", "disabled")
|
||||
$("#vcenter_host", context).atLocale.tr("disabled", "disabled")
|
||||
$("#get_vcenter_clusters", context).hide();
|
||||
$(".import_vcenter_clusters_div", context).show();
|
||||
|
||||
$(".content", container).html("");
|
||||
|
||||
$('<div class="row">' +
|
||||
'<div class="large-12 columns">' +
|
||||
'<p style="color: #999">' + Locale.tr("Please select the vCenter Clusters to be imported to OpenNebula. Each vCenter Cluster will be included as a new OpenNebula Host") + '</p>' +
|
||||
'</div>' +
|
||||
'</div>').appendTo($(".content", container))
|
||||
|
||||
$.each(response, function(datacenter_name, clusters) {
|
||||
$('<div class="row">' +
|
||||
'<div class="large-12 columns">' +
|
||||
'<h5>' +
|
||||
datacenter_name + ' ' + Locale.tr("Datacenter") +
|
||||
'</h5>' +
|
||||
'</div>' +
|
||||
'</div>').appendTo($(".content", container))
|
||||
|
||||
if (clusters.length == 0) {
|
||||
$('<div class="row">' +
|
||||
'<div class="large-12 columns">' +
|
||||
'<label>' +
|
||||
Locale.tr("No clusters found in this DataCenter") +
|
||||
'</label>' +
|
||||
'</div>' +
|
||||
'</div>').appendTo($(".content", container))
|
||||
} else {
|
||||
$.each(clusters, function(id, cluster_name) {
|
||||
var row = $('<div class="vcenter_cluster">' +
|
||||
'<div class="row">' +
|
||||
'<div class="large-10 columns">' +
|
||||
'<label>' +
|
||||
'<input type="checkbox" class="cluster_name"/> ' +
|
||||
cluster_name +
|
||||
'</label>' +
|
||||
'<div class="large-12 columns vcenter_host_response">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="large-2 columns vcenter_host_result">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>').appendTo($(".content", container))
|
||||
|
||||
$(".cluster_name", row).data("cluster_name", cluster_name)
|
||||
$(".cluster_name", row).data("datacenter_name", datacenter_name)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var templates_container = $(".vcenter_templates", context);
|
||||
var vms_container = $(".vcenter_vms", context);
|
||||
var networks_container = $(".vcenter_networks", context);
|
||||
|
||||
var vcenter_user = $("#vcenter_user", context).val();
|
||||
var vcenter_password = $("#vcenter_password", context).val();
|
||||
var vcenter_host = $("#vcenter_host", context).val();
|
||||
|
||||
fillVCenterTemplates({
|
||||
container: templates_container,
|
||||
vcenter_user: vcenter_user,
|
||||
vcenter_password: vcenter_password,
|
||||
vcenter_host: vcenter_host
|
||||
});
|
||||
|
||||
fillVCenterNetworks({
|
||||
container: networks_container,
|
||||
vcenter_user: vcenter_user,
|
||||
vcenter_password: vcenter_password,
|
||||
vcenter_host: vcenter_host
|
||||
});
|
||||
},
|
||||
error: function(response) {
|
||||
$(".vcenter_clusters", context).html('')
|
||||
onError({}, OpenNebula.Error(response));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
|
||||
$("#import_vcenter_clusters", context).on("click", function() {
|
||||
$(this).hide();
|
||||
|
||||
var cluster_id = $('#host_cluster_id .resource_list_select', context).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
$.each($(".cluster_name:checked", context), function() {
|
||||
var cluster_context = $(this).closest(".vcenter_cluster");
|
||||
$(".vcenter_host_result:not(.success)", cluster_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
var host_json = {
|
||||
"host": {
|
||||
"name": $(this).data("cluster_name"),
|
||||
"vm_mad": "vcenter",
|
||||
"vnm_mad": "dummy",
|
||||
"im_mad": "vcenter",
|
||||
"cluster_id": cluster_id
|
||||
}
|
||||
};
|
||||
|
||||
OpenNebula.Host.create({
|
||||
timeout: true,
|
||||
data: host_json,
|
||||
success: function(request, response) {
|
||||
OpenNebula.Helper.clear_cache("HOST");
|
||||
|
||||
$(".vcenter_host_result", cluster_context).addClass("success").html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_host_response", cluster_context).html('<p style="font-size:12px" class="running-color">' +
|
||||
Locale.tr("Host created successfully") + ' ID:' + response.HOST.ID +
|
||||
'</p>');
|
||||
|
||||
var template_raw =
|
||||
"VCENTER_USER=\"" + $("#vcenter_user", context).val() + "\"\n" +
|
||||
"VCENTER_PASSWORD=\"" + $("#vcenter_password", context).val() + "\"\n" +
|
||||
"VCENTER_HOST=\"" + $("#vcenter_host", context).val() + "\"\n";
|
||||
|
||||
Sunstone.runAction("Host.update_template", response.HOST.ID, template_raw);
|
||||
addHostElement(request, response);
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
$(".vcenter_host_result", context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_host_response", context).html('<p style="font-size:12px" class="error-color">' +
|
||||
(error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?")) +
|
||||
'</p>');
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$.each($(".template_name:checked", context), function() {
|
||||
var template_context = $(this).closest(".vcenter_template");
|
||||
|
||||
$(".vcenter_template_result:not(.success)", template_context).html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
var template_json = {
|
||||
"vmtemplate": {
|
||||
"template_raw": $(this).data("one_template")
|
||||
}
|
||||
};
|
||||
|
||||
OpenNebula.Template.create({
|
||||
timeout: true,
|
||||
data: template_json,
|
||||
success: function(request, response) {
|
||||
OpenNebula.Helper.clear_cache("VMTEMPLATE");
|
||||
$(".vcenter_template_result", template_context).addClass("success").html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_template_response", template_context).html('<p style="font-size:12px" class="running-color">' +
|
||||
Locale.tr("Template created successfully") + ' ID:' + response.VMTEMPLATE.ID +
|
||||
'</p>');
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
$(".vcenter_template_result", template_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_template_response", template_context).html('<p style="font-size:12px" class="error-color">' +
|
||||
(error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?")) +
|
||||
'</p>');
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$.each($(".vm_name:checked", context), function() {
|
||||
var vm_context = $(this).closest(".vcenter_vm");
|
||||
|
||||
$(".vcenter_vm_result:not(.success)", vm_context).html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
var vm_json = {
|
||||
"vm": {
|
||||
"vm_raw": $(this).data("one_vm")
|
||||
}
|
||||
};
|
||||
|
||||
var host_id_to_deploy = $(this).data("vm_to_host");
|
||||
|
||||
OpenNebula.VM.create({
|
||||
timeout: true,
|
||||
data: vm_json,
|
||||
success: function(request, response) {
|
||||
OpenNebula.Helper.clear_cache("VM");
|
||||
|
||||
var extra_info = {};
|
||||
|
||||
extra_info['host_id'] = host_id_to_deploy;
|
||||
extra_info['ds_id'] = -1;
|
||||
extra_info['enforce'] = false;
|
||||
|
||||
Sunstone.runAction("VM.deploy_action", response.VM.ID, extra_info);
|
||||
|
||||
$(".vcenter_vm_result", vm_context).addClass("success").html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_vm_response", vm_context).html('<p style="font-size:12px" class="running-color">' +
|
||||
Locale.tr("VM imported successfully") + ' ID:' + response.VM.ID +
|
||||
'</p>');
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
$(".vcenter_vm_response", vm_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_vm_response", vm_context).html('<p style="font-size:12px" class="error-color">' +
|
||||
(error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?")) +
|
||||
'</p>');
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$.each($(".network_name:checked", context), function() {
|
||||
var network_context = $(this).closest(".vcenter_network");
|
||||
|
||||
$(".vcenter_network_result:not(.success)", network_context).html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
var network_size = $(".netsize", network_context).val();
|
||||
var network_tmpl = $(this).data("one_network");
|
||||
var netname = $(this).data("network_name");
|
||||
var type = $('.type_select', network_context).val();
|
||||
|
||||
var ar_array = [];
|
||||
ar_array.push("TYPE=" + type);
|
||||
ar_array.push("SIZE=" + network_size);
|
||||
|
||||
switch (type) {
|
||||
case 'ETHER':
|
||||
var mac = $('.eth_mac_net', network_context).val();
|
||||
|
||||
if (mac) {
|
||||
ar_array.push("MAC=" + mac);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'IP4':
|
||||
var mac = $('.four_mac_net', network_context).val();
|
||||
var ip = $('.four_ip_net', network_context).val();
|
||||
|
||||
if (mac) {
|
||||
ar_array.push("MAC=" + mac);
|
||||
}
|
||||
if (ip) {
|
||||
ar_array.push("IP=" + ip);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'IP6':
|
||||
var mac = $('.six_mac_net', network_context).val();
|
||||
var gp = $('.six_global_net', network_context).val();
|
||||
var ula = $('.six_mac_net', network_context).val();
|
||||
|
||||
if (mac) {
|
||||
ar_array.push("MAC=" + mac);
|
||||
}
|
||||
if (gp) {
|
||||
ar_array.push("GLOBAL_PREFIX=" + gp);
|
||||
}
|
||||
if (ula) {
|
||||
ar_array.push("ULA_PREFIX=" + ula);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
network_tmpl += "\nAR=["
|
||||
network_tmpl += ar_array.join(",\n")
|
||||
network_tmpl += "]"
|
||||
|
||||
if ($(".vlaninfo", network_context)) {
|
||||
network_tmpl += "VLAN=\"YES\"\n";
|
||||
network_tmpl += "VLAN_ID=" + $(".vlaninfo", network_context).val() + "\n";
|
||||
}
|
||||
|
||||
var vnet_json = {
|
||||
"vnet": {
|
||||
"vnet_raw": network_tmpl
|
||||
}
|
||||
};
|
||||
|
||||
OpenNebula.Network.create({
|
||||
timeout: true,
|
||||
data: vnet_json,
|
||||
success: function(request, response) {
|
||||
OpenNebula.Helper.clear_cache("VNET");
|
||||
$(".vcenter_network_result", network_context).addClass("success").html(
|
||||
'<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-check fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_network_response", network_context).html('<p style="font-size:12px" class="running-color">' +
|
||||
Locale.tr("Virtual Network created successfully") + ' ID:' + response.VNET.ID +
|
||||
'</p>');
|
||||
},
|
||||
error: function (request, error_json) {
|
||||
$(".vcenter_network_result", network_context).html('<span class="fa-stack fa-2x" style="color: #dfdfdf">' +
|
||||
'<i class="fa fa-cloud fa-stack-2x"></i>' +
|
||||
'<i class="fa fa-warning fa-stack-1x fa-inverse"></i>' +
|
||||
'</span>');
|
||||
|
||||
$(".vcenter_network_response", network_context).html('<p style="font-size:12px" class="error-color">' +
|
||||
(error_json.error.message || Locale.tr("Cannot contact server: is it running and reachable?")) +
|
||||
'</p>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return false
|
||||
});
|
||||
*/
|
||||
|
||||
// Show custom driver input only when custom is selected in selects
|
||||
$('input[name="custom_vmm_mad"],' +
|
||||
'input[name="custom_im_mad"],' +
|
||||
'input[name="custom_vnm_mad"]', context).parent().hide();
|
||||
|
||||
$('select#vmm_mad', context).change(function() {
|
||||
if ($(this).val() == "custom")
|
||||
$('input[name="custom_vmm_mad"]').parent().show();
|
||||
else
|
||||
$('input[name="custom_vmm_mad"]').parent().hide();
|
||||
});
|
||||
|
||||
$('select#im_mad', context).change(function() {
|
||||
if ($(this).val() == "custom")
|
||||
$('input[name="custom_im_mad"]').parent().show();
|
||||
else
|
||||
$('input[name="custom_im_mad"]').parent().hide();
|
||||
});
|
||||
|
||||
$('select#vnm_mad', context).change(function() {
|
||||
if ($(this).val() == "custom")
|
||||
$('input[name="custom_vnm_mad"]').parent().show();
|
||||
else
|
||||
$('input[name="custom_vnm_mad"]').parent().hide();
|
||||
});
|
||||
|
||||
$('#create_host_form').on("keyup keypress", function(e) {
|
||||
var code = e.keyCode || e.which;
|
||||
if (code == 13) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Tips.setup();
|
||||
return false;
|
||||
}
|
||||
|
||||
function _submitWizard(context) {
|
||||
var name = $('#name', this).val();
|
||||
if (!name) {
|
||||
Sunstone.hideFormPanelLoading(context);
|
||||
Notifier.notifyError(Locale.tr("Host name missing!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
var cluster_id = $('#host_cluster_id .resource_list_select', 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,
|
||||
"vm_mad": vmm_mad,
|
||||
"vnm_mad": vnm_mad,
|
||||
"im_mad": im_mad,
|
||||
"cluster_id": cluster_id
|
||||
}
|
||||
};
|
||||
|
||||
//Create the OpenNebula.Host.
|
||||
//If it is successfull we refresh the list.
|
||||
Sunstone.runAction("Host.create", host_json);
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
$("#name", context).focus();
|
||||
|
||||
var cluster_id = $("#host_cluster_id .resource_list_select", context).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
ResourceSelect.insert('#host_cluster_id', context, "Cluster", cluster_id, false);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
define(function(require){
|
||||
return 'createHostForm';
|
||||
})
|
||||
@@ -0,0 +1,139 @@
|
||||
<form data-abide="ajax" id="{{formPanelId}}Wizard" class="custom creation">
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label for="host_type">{{tr "Type"}}</label>
|
||||
<select id="host_type_mad" name="host_type">
|
||||
<option value="kvm">{{tr "KVM"}}</option>
|
||||
<option value="xen">{{tr "XEN"}}</option>
|
||||
<option value="vmware">{{tr "VMware"}}</option>
|
||||
<option value="vcenter">{{tr "vCenter"}}</option>
|
||||
<option value="az">{{tr "Microsoft Azure"}}</option>
|
||||
<option value="ec2">{{tr "Amazon EC2"}}</option>
|
||||
<option value="sl">{{tr "IBM Softlayer"}}</option>
|
||||
<option value="dummy">{{tr "Dummy"}}</option>
|
||||
<option value="custom">{{tr "Custom"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="large-6 columns" id="cluster_select">
|
||||
<label for="host_cluster_id">{{tr "Cluster"}}</label>
|
||||
<div id="host_cluster_id" name="host_cluster_id"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-6 columns" id="name_container">
|
||||
<label for="name">{{tr "Hostname"}}</label>
|
||||
<input type="text" name="name" id="name" />
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<div class="manager clear row" id="vnm_mads">
|
||||
<div class="large-12 columns">
|
||||
<label for="vn">{{tr "Networking"}}</label>
|
||||
<select id="vnm_mad" name="vn">
|
||||
<option value="dummy">{{tr "Default (dummy)"}}</option>
|
||||
<option value="fw">{{tr "Firewall"}}</option>
|
||||
<option value="802.1Q">{{tr "802.1Q"}}</option>
|
||||
<option value="vxlan">{{tr "VXLAN"}}</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>
|
||||
<div class="large-12 columns">
|
||||
<label>{{tr "Custom VNM_MAD"}}</label>
|
||||
<input type="text" name="custom_vnm_mad" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="drivers">
|
||||
<fieldset>
|
||||
<legend>{{tr "Drivers"}}</legend>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<div class="manager clear row" id="vmm_mads">
|
||||
<div class="large-12 columns">
|
||||
<label for="vmm">{{tr "Virtualization"}}</label>
|
||||
<select id="vmm_mad" name="vmm">
|
||||
<option value="kvm">{{tr "KVM"}}</option>
|
||||
<option value="xen">{{tr "XEN"}}</option>
|
||||
<option value="vmware">{{tr "VMware"}}</option>
|
||||
<option value="vcenter">{{tr "vCenter"}}</option>
|
||||
<option value="az">{{tr "Microsoft Azure"}}</option>
|
||||
<option value="ec2">{{tr "Amazon EC2"}}</option>
|
||||
<option value="sl">{{tr "IBM Softlayer"}}</option>
|
||||
<option value="dummy">{{tr "Dummy"}}</option>
|
||||
<option value="custom">{{tr "Custom"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="large-12 columns">
|
||||
<label>{{tr "Custom VMM_MAD"}}</label>
|
||||
<input type="text" name="custom_vmm_mad" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<div class="manager clear row" id="im_mads">
|
||||
<div class="large-12 columns">
|
||||
<label for="im">{{tr "Information"}}</label>
|
||||
<select id="im_mad" name="im">
|
||||
<option value="kvm">{{tr "KVM"}}</option>
|
||||
<option value="xen">{{tr "XEN"}}</option>
|
||||
<option value="vmware">{{tr "VMware"}}</option>
|
||||
<option value="vcenter">{{tr "vCenter"}}</option>
|
||||
<option value="az">{{tr "Microsoft Azure"}}</option>
|
||||
<option value="ec2">{{tr "Amazon EC2"}}</option>
|
||||
<option value="sl">{{tr "IBM Softlayer"}}</option>
|
||||
<option value="dummy">{{tr "Dummy"}}</option>
|
||||
<option value="custom">{{tr "Custom"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="large-12 columns">
|
||||
<label>{{tr "Custom IM_MAD"}}:</label>
|
||||
<input type="text" name="custom_im_mad" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="row vcenter_credentials hidden">
|
||||
<fieldset>
|
||||
<legend>{{tr "vCenter"}}</legend>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label for="vcenter_user">{{tr "User"}}</label>
|
||||
<input type="text" name="vcenter_user" id="vcenter_user" />
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<label for="vcenter_host">{{tr "Hostname"}}</label>
|
||||
<input type="text" name="vcenter_host" id="vcenter_host" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label for="vcenter_password">{{tr "Password"}}</label>
|
||||
<input type="password" name="vcenter_password" id="vcenter_password" />
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<br>
|
||||
<a class="button radius small right" id="get_vcenter_clusters">{{tr "Get vCenter Clusters"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vcenter_clusters"></div>
|
||||
<br>
|
||||
<div class="vcenter_templates"></div>
|
||||
<br>
|
||||
<br>
|
||||
<div class="vcenter_vms"></div>
|
||||
<br>
|
||||
<div class="vcenter_networks"></div>
|
||||
<div class="row import_vcenter_clusters_div hidden">
|
||||
<div class="large-12 columns">
|
||||
<br>
|
||||
<a class="button radius small right success" id="import_vcenter_clusters">{{tr "Import"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
||||
Reference in new issue
Block a user