mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
feature #3748: Add vmd-tab list
This commit is contained in:
parent
c3b794470f
commit
af6de22e83
@ -13,6 +13,7 @@ define(function(require) {
|
||||
require('tabs/templates-tab'),
|
||||
require('tabs/images-tab'),
|
||||
require('tabs/files-tab'),
|
||||
require('tabs/vms-tab'),
|
||||
require('tabs/infra-tab'),
|
||||
require('tabs/clusters-tab'),
|
||||
require('tabs/hosts-tab'),
|
||||
|
@ -5,6 +5,127 @@ define(function(require) {
|
||||
|
||||
var RESOURCE = "VM";
|
||||
|
||||
var STATES = [
|
||||
"INIT",
|
||||
"PENDING",
|
||||
"HOLD",
|
||||
"ACTIVE",
|
||||
"STOPPED",
|
||||
"SUSPENDED",
|
||||
"DONE",
|
||||
"FAILED",
|
||||
"POWEROFF",
|
||||
"UNDEPLOYED"
|
||||
]
|
||||
|
||||
var LCM_STATES = [
|
||||
"LCM_INIT",
|
||||
"PROLOG",
|
||||
"BOOT",
|
||||
"RUNNING",
|
||||
"MIGRATE",
|
||||
"SAVE_STOP",
|
||||
"SAVE_SUSPEND",
|
||||
"SAVE_MIGRATE",
|
||||
"PROLOG_MIGRATE",
|
||||
"PROLOG_RESUME",
|
||||
"EPILOG_STOP",
|
||||
"EPILOG",
|
||||
"SHUTDOWN",
|
||||
"CANCEL",
|
||||
"FAILURE",
|
||||
"CLEANUP_RESUBMIT",
|
||||
"UNKNOWN",
|
||||
"HOTPLUG",
|
||||
"SHUTDOWN_POWEROFF",
|
||||
"BOOT_UNKNOWN",
|
||||
"BOOT_POWEROFF",
|
||||
"BOOT_SUSPENDED",
|
||||
"BOOT_STOPPED",
|
||||
"CLEANUP_DELETE",
|
||||
"HOTPLUG_SNAPSHOT",
|
||||
"HOTPLUG_NIC",
|
||||
"HOTPLUG_SAVEAS",
|
||||
"HOTPLUG_SAVEAS_POWEROFF",
|
||||
"HOTPLUG_SAVEAS_SUSPENDED",
|
||||
"SHUTDOWN_UNDEPLOY",
|
||||
"EPILOG_UNDEPLOY",
|
||||
"PROLOG_UNDEPLOY",
|
||||
"BOOT_UNDEPLOY",
|
||||
"HOTPLUG_PROLOG_POWEROFF",
|
||||
"HOTPLUG_EPILOG_POWEROFF",
|
||||
"BOOT_MIGRATE",
|
||||
"BOOT_FAILURE",
|
||||
"BOOT_MIGRATE_FAILURE",
|
||||
"PROLOG_MIGRATE_FAILURE",
|
||||
"PROLOG_FAILURE",
|
||||
"EPILOG_FAILURE",
|
||||
"EPILOG_STOP_FAILURE",
|
||||
"EPILOG_UNDEPLOY_FAILURE",
|
||||
"PROLOG_MIGRATE_POWEROFF",
|
||||
"PROLOG_MIGRATE_POWEROFF_FAILURE",
|
||||
"PROLOG_MIGRATE_SUSPEND",
|
||||
"PROLOG_MIGRATE_SUSPEND_FAILURE",
|
||||
"BOOT_UNDEPLOY_FAILURE",
|
||||
"BOOT_STOPPED_FAILURE",
|
||||
"PROLOG_RESUME_FAILURE",
|
||||
"PROLOG_UNDEPLOY_FAILURE"
|
||||
]
|
||||
|
||||
var SHORT_LCM_STATES = [
|
||||
"LCM_INIT", // LCM_INIT
|
||||
"PROLOG", // PROLOG
|
||||
"BOOT", // BOOT
|
||||
"RUNNING", // RUNNING
|
||||
"MIGRATE", // MIGRATE
|
||||
"SAVE", // SAVE_STOP
|
||||
"SAVE", // SAVE_SUSPEND
|
||||
"SAVE", // SAVE_MIGRATE
|
||||
"MIGRATE", // PROLOG_MIGRATE
|
||||
"PROLOG", // PROLOG_RESUME
|
||||
"EPILOG", // EPILOG_STOP
|
||||
"EPILOG", // EPILOG
|
||||
"SHUTDOWN", // SHUTDOWN
|
||||
"SHUTDOWN", // CANCEL
|
||||
"FAILURE", // FAILURE
|
||||
"CLEANUP", // CLEANUP_RESUBMIT
|
||||
"UNKNOWN", // UNKNOWN
|
||||
"HOTPLUG", // HOTPLUG
|
||||
"SHUTDOWN", // SHUTDOWN_POWEROFF
|
||||
"BOOT", // BOOT_UNKNOWN
|
||||
"BOOT", // BOOT_POWEROFF
|
||||
"BOOT", // BOOT_SUSPENDED
|
||||
"BOOT", // BOOT_STOPPED
|
||||
"CLEANUP", // CLEANUP_DELETE
|
||||
"SNAPSHOT", // HOTPLUG_SNAPSHOT
|
||||
"HOTPLUG", // HOTPLUG_NIC
|
||||
"HOTPLUG", // HOTPLUG_SAVEAS
|
||||
"HOTPLUG", // HOTPLUG_SAVEAS_POWEROFF
|
||||
"HOTPLUG", // HOTPLUG_SAVEAS_SUSPENDED
|
||||
"SHUTDOWN", // SHUTDOWN_UNDEPLOY
|
||||
"EPILOG", // EPILOG_UNDEPLOY
|
||||
"PROLOG", // PROLOG_UNDEPLOY
|
||||
"BOOT", // BOOT_UNDEPLOY
|
||||
"HOTPLUG", // HOTPLUG_PROLOG_POWEROFF
|
||||
"HOTPLUG", // HOTPLUG_EPILOG_POWEROFF
|
||||
"BOOT", // BOOT_MIGRATE
|
||||
"FAILURE", // BOOT_FAILURE
|
||||
"FAILURE", // BOOT_MIGRATE_FAILURE
|
||||
"FAILURE", // PROLOG_MIGRATE_FAILURE
|
||||
"FAILURE", // PROLOG_FAILURE
|
||||
"FAILURE", // EPILOG_FAILURE
|
||||
"FAILURE", // EPILOG_STOP_FAILURE
|
||||
"FAILURE", // EPILOG_UNDEPLOY_FAILURE
|
||||
"MIGRATE", // PROLOG_MIGRATE_POWEROFF
|
||||
"FAILURE", // PROLOG_MIGRATE_POWEROFF_FAILURE
|
||||
"MIGRATE", // PROLOG_MIGRATE_SUSPEND
|
||||
"FAILURE", // PROLOG_MIGRATE_SUSPEND_FAILURE
|
||||
"FAILURE", // BOOT_UNDEPLOY_FAILURE
|
||||
"FAILURE", // BOOT_STOPPED_FAILURE
|
||||
"FAILURE", // PROLOG_RESUME_FAILURE
|
||||
"FAILURE" // PROLOG_UNDEPLOY_FAILURE
|
||||
]
|
||||
|
||||
var VM = {
|
||||
"resource": RESOURCE,
|
||||
"state": {
|
||||
@ -74,6 +195,15 @@ define(function(require) {
|
||||
"PROLOG_UNDEPLOY_FAILURE" : 50
|
||||
},
|
||||
|
||||
"stateStr": function(stateId) {
|
||||
return STATES[stateId];
|
||||
},
|
||||
"lcmStateStr": function(stateId) {
|
||||
return LCM_STATES[stateId];
|
||||
},
|
||||
"shortLcmStateStr": function(stateId) {
|
||||
return SHORT_LCM_STATES[stateId];
|
||||
},
|
||||
"create": function(params) {
|
||||
OpenNebulaAction.create(params, RESOURCE);
|
||||
},
|
||||
|
46
src/sunstone/public/app/tabs/vms-tab.js
Normal file
46
src/sunstone/public/app/tabs/vms-tab.js
Normal file
@ -0,0 +1,46 @@
|
||||
define(function(require) {
|
||||
var Locale = require('utils/locale');
|
||||
var Buttons = require('./vms-tab/buttons');
|
||||
var Actions = require('./vms-tab/actions');
|
||||
var Table = require('./vms-tab/datatable');
|
||||
|
||||
var TAB_ID = require('./vms-tab/tabId');
|
||||
var DATATABLE_ID = "dataTableVms";
|
||||
|
||||
//var _dialogs = [
|
||||
// require('./vms-tab/dialogs/clone'),
|
||||
// require('./vms-tab/dialogs/instantiate')
|
||||
//];
|
||||
|
||||
//var _panels = [
|
||||
// require('./vms-tab/panels/info'),
|
||||
// require('./vms-tab/panels/template')
|
||||
//];
|
||||
|
||||
//var _formPanels = [
|
||||
// require('./vms-tab/form-panels/create')
|
||||
//]
|
||||
|
||||
var Tab = {
|
||||
tabId: TAB_ID,
|
||||
title: Locale.tr("Virtual Machines"),
|
||||
tabClass: "subTab",
|
||||
parentTab: "vresources-tab",
|
||||
listHeader: '<i class="fa fa-fw fa-th"></i> ' + Locale.tr("Virtual Machines"),
|
||||
infoHeader: '<i class="fa fa-fw fa-th"></i> ' + Locale.tr("VM"),
|
||||
subheader: '<span class="total_vms"/> <small>' + Locale.tr("TOTAL") + '</small> \
|
||||
<span class="active_vms"/> <small>' + Locale.tr("ACTIVE") + '</small> \
|
||||
<span class="off_vms"/> <small>' + Locale.tr("OFF") + '</small> \
|
||||
<span class="pending_vms"/> <small>' + Locale.tr("PENDING") + '</small> \
|
||||
<span class="failed_vms"/> <small>' + Locale.tr("FAILED") + '</small>',
|
||||
resource: 'VM',
|
||||
buttons: Buttons,
|
||||
actions: Actions,
|
||||
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
|
||||
//panels: _panels,
|
||||
//formPanels: _formPanels,
|
||||
//dialogs: _dialogs
|
||||
};
|
||||
|
||||
return Tab;
|
||||
});
|
532
src/sunstone/public/app/tabs/vms-tab/actions.js
Normal file
532
src/sunstone/public/app/tabs/vms-tab/actions.js
Normal file
@ -0,0 +1,532 @@
|
||||
define(function(require) {
|
||||
var Sunstone = require('sunstone');
|
||||
var Notifier = require('utils/notifier');
|
||||
var Locale = require('utils/locale');
|
||||
var OpenNebulaVM = require('opennebula/vm');
|
||||
var CommonActions = require('utils/common-actions');
|
||||
|
||||
var TAB_ID = require('./tabId');
|
||||
//var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId');
|
||||
//var CLONE_DIALOG_ID = require('./dialogs/clone/dialogId');
|
||||
//var INSTANTIATE_DIALOG_ID = require('./dialogs/instantiate/dialogId');
|
||||
var XML_ROOT = "VM";
|
||||
var RESOURCE = "VM";
|
||||
|
||||
var _commonActions = new CommonActions(OpenNebulaVM, RESOURCE, TAB_ID);
|
||||
|
||||
var _actions = {
|
||||
"VM.list": _commonActions.list(),
|
||||
"VM.show": _commonActions.show(),
|
||||
"VM.refresh": _commonActions.refresh(),
|
||||
"VM.delete": _commonActions.delete(),
|
||||
|
||||
/*"VM.create" : {
|
||||
type: "custom",
|
||||
call: function(id, name) {
|
||||
Sunstone.runAction("Template.instantiate", [id], name);
|
||||
Sunstone.runAction("VM.list");
|
||||
},
|
||||
callback: function(request, response) {
|
||||
//Sunstone.resetFormPanel(TAB_ID, CREATE_DIALOG_ID);
|
||||
//Sunstone.hideFormPanel(TAB_ID);
|
||||
Sunstone.getDataTable(TAB_ID).addElement(request, response);
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
"VM.create_dialog" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
//Sunstone.getDialog(CREATE_DIALOG_ID).show();
|
||||
}
|
||||
},
|
||||
"VM.deploy" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpDeployVMDialog();
|
||||
}
|
||||
},
|
||||
|
||||
"VM.deploy_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.deploy,
|
||||
callback: vmShow,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.silent_deploy_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.deploy,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"VM.migrate" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpMigrateVMDialog(false);
|
||||
}
|
||||
},
|
||||
|
||||
"VM.migrate_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.migrate,
|
||||
callback: vmShow,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.migrate_live" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpMigrateVMDialog(true);
|
||||
}
|
||||
},
|
||||
|
||||
"VM.migrate_live_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.livemigrate,
|
||||
callback: vmShow,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.hold" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.hold,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.release" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.release,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.suspend" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.suspend,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.resume" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.resume,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.stop" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.stop,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.reboot_hard" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.reset,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.delete_recreate" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.resubmit,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.reboot" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.reboot,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.poweroff" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.poweroff,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.poweroff_hard" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.poweroff_hard,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.undeploy" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.undeploy,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.undeploy_hard" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.undeploy_hard,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.saveas" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.saveas,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
OpenNebula.Helper.clear_cache("IMAGE");
|
||||
},
|
||||
error:onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.disk_snapshot_cancel" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.disk_snapshot_cancel,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
OpenNebula.Helper.clear_cache("IMAGE");
|
||||
},
|
||||
error:onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.snapshot_create" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.snapshot_create,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error:onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.snapshot_revert" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.snapshot_revert,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error:onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.snapshot_delete" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.snapshot_delete,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error:onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.shutdown" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.shutdown,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.shutdown_hard" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.cancel,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
|
||||
"VM.recover" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.recover,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.resched" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.resched,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.unresched" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.unresched,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.log" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.log,
|
||||
callback: function(req, res) {
|
||||
//after calling VM.log we process the answer
|
||||
//update the tab and pop it up again
|
||||
res = res['vm_log'];
|
||||
var log_lines = res.split("\n");
|
||||
var colored_log = '';
|
||||
for (var i = 0; i < log_lines.length; i++) {
|
||||
var line = log_lines[i];
|
||||
if (line.match(/\[E\]/)) {
|
||||
line = '<span class="vm_log_error">' + line + '</span>';
|
||||
}
|
||||
colored_log += line + "<br>";
|
||||
}
|
||||
|
||||
$('#vm_log_tab').html('<div class="row"><div class="large-11 small-centered columns log-tab">' + colored_log + '</div></div>')
|
||||
},
|
||||
error: function(request, error_json) {
|
||||
$("#vm_log pre").html('');
|
||||
onError(request, error_json);
|
||||
}
|
||||
},
|
||||
|
||||
"VM.startvnc" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpVnc();
|
||||
}
|
||||
},
|
||||
|
||||
"VM.startspice" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
popUpSPICE();
|
||||
}
|
||||
},
|
||||
|
||||
"VM.startvnc_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.startvnc,
|
||||
callback: vncCallback,
|
||||
error: function(req, resp) {
|
||||
onError(req, resp);
|
||||
vnc_lock = false;
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.startspice_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.startvnc,
|
||||
callback: spiceCallback,
|
||||
error: function(req, resp) {
|
||||
onError(req, resp);
|
||||
spice_lock = false;
|
||||
},
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.monitor" : {
|
||||
type: "monitor",
|
||||
call : OpenNebula.VM.monitor,
|
||||
callback: function(req, response) {
|
||||
var vm_graphs = [
|
||||
{
|
||||
monitor_resources : "CPU",
|
||||
labels : "Real CPU",
|
||||
humanize_figures : false,
|
||||
div_graph : $(".vm_cpu_graph")
|
||||
},
|
||||
{
|
||||
monitor_resources : "MEMORY",
|
||||
labels : "Real MEM",
|
||||
humanize_figures : true,
|
||||
div_graph : $(".vm_memory_graph")
|
||||
},
|
||||
{labels : "Network reception",
|
||||
monitor_resources : "NET_RX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
div_graph : $("#vm_net_rx_graph")
|
||||
},
|
||||
{labels : "Network transmission",
|
||||
monitor_resources : "NET_TX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
div_graph : $("#vm_net_tx_graph")
|
||||
},
|
||||
{labels : "Network reception speed",
|
||||
monitor_resources : "NET_RX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#vm_net_rx_speed_graph")
|
||||
},
|
||||
{labels : "Network transmission speed",
|
||||
monitor_resources : "NET_TX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#vm_net_tx_speed_graph")
|
||||
}
|
||||
];
|
||||
|
||||
// The network speed graphs require the derivative of the data,
|
||||
// and this process is done in place. They must be the last
|
||||
// graphs to be processed
|
||||
|
||||
for (var i = 0; i < vm_graphs.length; i++) {
|
||||
plot_graph(
|
||||
response,
|
||||
vm_graphs[i]
|
||||
);
|
||||
}
|
||||
},
|
||||
error: vmMonitorError
|
||||
},
|
||||
|
||||
"VM.chown" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.chown,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction('VM.show', request.request.data[0]);
|
||||
},
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.chgrp" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.chgrp,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.chmod" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.chmod,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.attachdisk" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.attachdisk,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0][0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.detachdisk" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.detachdisk,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0][0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.attachnic" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.attachnic,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.resize" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.resize,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.detachnic" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.detachnic,
|
||||
callback: function(request) {
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
"VM.help" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
hideDialog();
|
||||
$('div#vms_tab div.legend_div').slideToggle();
|
||||
}
|
||||
},
|
||||
|
||||
"VM.rename" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.rename,
|
||||
callback: function(request) {
|
||||
notifyMessage(tr("VirtualMachine renamed correctly"));
|
||||
Sunstone.runAction('VM.show', request.request.data[0]);
|
||||
},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.update_template" : { // Update template
|
||||
type: "single",
|
||||
call: OpenNebula.VM.update,
|
||||
callback: function(request, response) {
|
||||
notifyMessage(tr("VirtualMachine updated correctly"));
|
||||
Sunstone.runAction('VM.show', request.request.data[0]);
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"VM.update_actions" : { // Update template
|
||||
type: "single",
|
||||
call: OpenNebula.VM.update,
|
||||
callback: function(request, response) {
|
||||
notifyMessage(tr("VirtualMachine updated correctly"));
|
||||
Sunstone.runAction("VM.show", request.request.data[0]);
|
||||
},
|
||||
error: onError
|
||||
}*/
|
||||
};
|
||||
|
||||
return _actions;
|
||||
});
|
201
src/sunstone/public/app/tabs/vms-tab/buttons.js
Normal file
201
src/sunstone/public/app/tabs/vms-tab/buttons.js
Normal file
@ -0,0 +1,201 @@
|
||||
define(function(require) {
|
||||
var Locale = require('utils/locale');
|
||||
|
||||
var Buttons = {
|
||||
"VM.refresh" : {
|
||||
type: "action",
|
||||
layout: "refresh",
|
||||
alwaysActive: true
|
||||
},
|
||||
"VM.create_dialog" : {
|
||||
type: "action",
|
||||
layout: "create",
|
||||
alwaysActive: true
|
||||
},
|
||||
"VM.chown" : {
|
||||
type: "confirm_with_select",
|
||||
text: Locale.tr("Change owner"),
|
||||
select: "User",
|
||||
layout: "user_select",
|
||||
tip: Locale.tr("Select the new owner") + ":"
|
||||
},
|
||||
"VM.chgrp" : {
|
||||
type: "confirm_with_select",
|
||||
text: Locale.tr("Change group"),
|
||||
select: "Group",
|
||||
layout: "user_select",
|
||||
tip: Locale.tr("Select the new group") + ":"
|
||||
},
|
||||
"VM.deploy" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Deploy"),
|
||||
tip: Locale.tr("This will deploy the selected VMs on the chosen host"),
|
||||
layout: "vmsplanification_buttons",
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.migrate" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Migrate"),
|
||||
tip: Locale.tr("This will migrate the selected VMs to the chosen host"),
|
||||
layout: "vmsplanification_buttons",
|
||||
custom_classes : "state-dependent"
|
||||
|
||||
},
|
||||
"VM.migrate_live" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Migrate") + ' <span class="label secondary radius">live</span>',
|
||||
tip: Locale.tr("This will live-migrate the selected VMs to the chosen host"),
|
||||
layout: "vmsplanification_buttons",
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.hold" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Hold"),
|
||||
tip: Locale.tr("This will hold selected pending VMs from being deployed"),
|
||||
layout: "vmsplanification_buttons",
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.release" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Release"),
|
||||
layout: "vmsplanification_buttons",
|
||||
tip: Locale.tr("This will release held machines"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.suspend" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Suspend"),
|
||||
layout: "vmspause_buttons",
|
||||
tip: Locale.tr("This will suspend selected machines"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.resume" : {
|
||||
type: "action",
|
||||
text: '<i class="fa fa-play"/>',
|
||||
layout: "vmsplay_buttons",
|
||||
tip: Locale.tr("This will resume selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.stop" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Stop"),
|
||||
layout: "vmsstop_buttons",
|
||||
tip: Locale.tr("This will stop selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.reboot" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Reboot"),
|
||||
layout: "vmsrepeat_buttons",
|
||||
tip: Locale.tr("This will send a reboot action to running VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.reboot_hard" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Reboot") + ' <span class="label secondary radius">hard</span>',
|
||||
layout: "vmsrepeat_buttons",
|
||||
tip: Locale.tr("This will perform a hard reboot on selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.poweroff" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Power Off"),
|
||||
layout: "vmspause_buttons",
|
||||
tip: Locale.tr("This will send a power off signal to running VMs. They can be resumed later."),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.poweroff_hard" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Power Off") + ' <span class="label secondary radius">hard</span>',
|
||||
layout: "vmspause_buttons",
|
||||
tip: Locale.tr("This will send a forced power off signal to running VMs. They can be resumed later."),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.undeploy" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Undeploy"),
|
||||
layout: "vmsstop_buttons",
|
||||
tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore."),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.undeploy_hard" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Undeploy") + ' <span class="label secondary radius">hard</span>',
|
||||
layout: "vmsstop_buttons",
|
||||
tip: Locale.tr("Shuts down the given VM. The VM is saved in the system Datastore."),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.shutdown" : {
|
||||
type: "confirm",
|
||||
text: Locale.tr("Shutdown"),
|
||||
layout: "vmsdelete_buttons",
|
||||
tip: Locale.tr("This will initiate the shutdown process in the selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.shutdown_hard" : {
|
||||
type: "confirm",
|
||||
text: Locale.tr("Shutdown") + ' <span class="label secondary radius">hard</span>',
|
||||
layout: "vmsdelete_buttons",
|
||||
tip: Locale.tr("This will initiate the shutdown-hard (forced) process in the selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
|
||||
"VM.delete" : {
|
||||
type: "confirm",
|
||||
text: Locale.tr("Delete"),
|
||||
layout: "vmsdelete_buttons",
|
||||
tip: Locale.tr("This will delete the selected VMs from the database"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.delete_recreate" : {
|
||||
type: "confirm",
|
||||
text: Locale.tr("Delete") + ' <span class="label secondary radius">recreate</span>',
|
||||
layout: "vmsrepeat_buttons",
|
||||
tip: Locale.tr("This will delete and recreate VMs to PENDING state"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.resched" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Reschedule"),
|
||||
layout: "vmsplanification_buttons",
|
||||
tip: Locale.tr("This will reschedule selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.unresched" : {
|
||||
type: "action",
|
||||
text: Locale.tr("Un-Reschedule"),
|
||||
layout: "vmsplanification_buttons",
|
||||
tip: Locale.tr("This will cancel the rescheduling for the selected VMs"),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.recover" : {
|
||||
type: "confirm_with_select",
|
||||
text: Locale.tr("Recover"),
|
||||
layout: "vmsplanification_buttons",
|
||||
custom_select: '<select class="resource_list_select">\
|
||||
<option value="2">' + Locale.tr("retry") + '</option>\
|
||||
<option value="1">' + Locale.tr("success") + '</option>\
|
||||
<option value="0">' + Locale.tr("failure") + '</option>\
|
||||
</select>' ,
|
||||
tip: Locale.tr("Recovers a stuck VM that is waiting for a driver operation. \
|
||||
The recovery may be done by failing, succeeding or retrying the current operation. \
|
||||
YOU NEED TO MANUALLY CHECK THE VM STATUS ON THE HOST, to decide if the operation \
|
||||
was successful or not, or if it can be retried."),
|
||||
custom_classes : "state-dependent"
|
||||
},
|
||||
"VM.startvnc" : {
|
||||
type: "action",
|
||||
text: '<i class="fa fa-desktop" style="color: rgb(111, 111, 111)"/> ' + Locale.tr("VNC"),
|
||||
custom_classes: "only-right-info vnc-right-info",
|
||||
tip: Locale.tr("VNC")
|
||||
},
|
||||
"VM.startspice" : {
|
||||
type: "action",
|
||||
text: '<i class="fa fa-desktop" style="color: rgb(111, 111, 111)"/> ' + Locale.tr("SPICE"),
|
||||
custom_classes: "only-right-info spice-right-info",
|
||||
tip: Locale.tr("SPICE")
|
||||
}
|
||||
}
|
||||
|
||||
return Buttons;
|
||||
})
|
140
src/sunstone/public/app/tabs/vms-tab/datatable.js
Normal file
140
src/sunstone/public/app/tabs/vms-tab/datatable.js
Normal file
@ -0,0 +1,140 @@
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var TabDataTable = require('utils/tab-datatable');
|
||||
var SunstoneConfig = require('sunstone-config');
|
||||
var Locale = require('utils/locale');
|
||||
var Humanize = require('utils/humanize');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
var OpenNebulaVm = require('opennebula/vm');
|
||||
var VncSpiceUtils = require('utils/vnc-spice-utils');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var RESOURCE = "VM";
|
||||
var XML_ROOT = "VM";
|
||||
var TAB_NAME = require('./tabId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Table(dataTableId, conf) {
|
||||
this.conf = conf || {};
|
||||
this.tabId = TAB_NAME;
|
||||
this.dataTableId = dataTableId;
|
||||
this.resource = RESOURCE;
|
||||
this.xmlRoot = XML_ROOT;
|
||||
|
||||
this.dataTableOptions = {
|
||||
"bAutoWidth": false,
|
||||
"bSortClasses" : false,
|
||||
"bDeferRender": true,
|
||||
"aoColumnDefs": [
|
||||
{"bSortable": false, "aTargets": ["check", 6, 7, 11]},
|
||||
{"sWidth": "35px", "aTargets": [0]},
|
||||
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
|
||||
{"bVisible": false, "aTargets": ['_all']}
|
||||
]
|
||||
}
|
||||
|
||||
this.columns = [
|
||||
Locale.tr("ID") ,
|
||||
Locale.tr("Owner") ,
|
||||
Locale.tr("Group"),
|
||||
Locale.tr("Name"),
|
||||
Locale.tr("Status"),
|
||||
Locale.tr("Used CPU"),
|
||||
Locale.tr("Used Memory"),
|
||||
Locale.tr("Host"),
|
||||
Locale.tr("IPs"),
|
||||
Locale.tr("Start Time"),
|
||||
Locale.tr(""),
|
||||
Locale.tr("Hidden Template")
|
||||
];
|
||||
|
||||
this.selectOptions = {
|
||||
"id_index": 1,
|
||||
"name_index": 4,
|
||||
"select_resource": Locale.tr("Please select a VM from the list"),
|
||||
"you_selected": Locale.tr("You selected the following VM:"),
|
||||
"select_resource_multiple": Locale.tr("Please select one or more VMs from the list"),
|
||||
"you_selected_multiple": Locale.tr("You selected the following VMs:")
|
||||
};
|
||||
|
||||
TabDataTable.call(this);
|
||||
};
|
||||
|
||||
Table.prototype = Object.create(TabDataTable.prototype);
|
||||
Table.prototype.constructor = Table;
|
||||
Table.prototype.elementArray = _elementArray;
|
||||
|
||||
return Table;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _elementArray(element_json) {
|
||||
var element = element_json[XML_ROOT];
|
||||
|
||||
var state = OpenNebulaVm.stateStr(element.STATE);
|
||||
var hostname = "--";
|
||||
|
||||
if (state == "ACTIVE" || state == "SUSPENDED" || state == "POWEROFF") {
|
||||
if (element.HISTORY_RECORDS.HISTORY.constructor == Array) {
|
||||
hostname = element.HISTORY_RECORDS.HISTORY[element.HISTORY_RECORDS.HISTORY.length - 1].HOSTNAME;
|
||||
} else {
|
||||
hostname = element.HISTORY_RECORDS.HISTORY.HOSTNAME;
|
||||
};
|
||||
};
|
||||
|
||||
/* TODO
|
||||
switch (state) {
|
||||
case tr("INIT"):
|
||||
case tr("PENDING"):
|
||||
case tr("HOLD"):
|
||||
pending_vms++;
|
||||
break;
|
||||
case tr("FAILED"):
|
||||
failed_vms++;
|
||||
break;
|
||||
case tr("ACTIVE"):
|
||||
active_vms++;
|
||||
break;
|
||||
case tr("STOPPED"):
|
||||
case tr("SUSPENDED"):
|
||||
case tr("POWEROFF"):
|
||||
off_vms++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}*/
|
||||
|
||||
if (state == "ACTIVE") {
|
||||
state = OpenNebulaVm.shortLcmStateStr(element.LCM_STATE);
|
||||
};
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="' + RESOURCE.toLowerCase() + '_' +
|
||||
element.ID + '" name="selected_items" value="' +
|
||||
element.ID + '"/>',
|
||||
element.ID,
|
||||
element.UNAME,
|
||||
element.GNAME,
|
||||
element.NAME,
|
||||
state,
|
||||
element.CPU,
|
||||
Humanize.size(element.MEMORY),
|
||||
hostname,
|
||||
Humanize.ipsStr(element),
|
||||
Humanize.prettyTime(element.STIME),
|
||||
VncSpiceUtils.vncIcon(element),
|
||||
TemplateUtils.templateToString(element)
|
||||
];
|
||||
}
|
||||
});
|
3
src/sunstone/public/app/tabs/vms-tab/tabId.js
Normal file
3
src/sunstone/public/app/tabs/vms-tab/tabId.js
Normal file
@ -0,0 +1,3 @@
|
||||
define(function(require) {
|
||||
return "vms-tab";
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user