mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Feature #1112: Add Clusters to Sunstone
This commit is contained in:
parent
75a19e8bb7
commit
ff1dd894ba
@ -1116,6 +1116,7 @@ SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/AclJSON.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb"
|
||||
|
||||
SUNSTONE_TEMPLATE_FILES="src/sunstone/templates/login.html \
|
||||
@ -1134,6 +1135,7 @@ SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\
|
||||
src/sunstone/public/js/plugins/dashboard-tab.js \
|
||||
src/sunstone/public/js/plugins/dashboard-users-tab.js \
|
||||
src/sunstone/public/js/plugins/hosts-tab.js \
|
||||
src/sunstone/public/js/plugins/clusters-tab.js \
|
||||
src/sunstone/public/js/plugins/groups-tab.js \
|
||||
src/sunstone/public/js/plugins/images-tab.js \
|
||||
src/sunstone/public/js/plugins/templates-tab.js \
|
||||
|
@ -14,6 +14,11 @@
|
||||
:user:
|
||||
:group:
|
||||
oneadmin: true
|
||||
- plugins/clusters-tab.js:
|
||||
:ALL: false
|
||||
:user:
|
||||
:group:
|
||||
oneadmin: true
|
||||
- plugins/vms-tab.js:
|
||||
:ALL: true
|
||||
:user:
|
||||
|
@ -19,6 +19,7 @@ include OpenNebula
|
||||
|
||||
require 'OpenNebulaJSON/GroupJSON'
|
||||
require 'OpenNebulaJSON/HostJSON'
|
||||
require 'OpenNebulaJSON/ClusterJSON'
|
||||
require 'OpenNebulaJSON/ImageJSON'
|
||||
require 'OpenNebulaJSON/TemplateJSON'
|
||||
require 'OpenNebulaJSON/JSONUtils'
|
||||
|
@ -22,12 +22,10 @@ module OpenNebulaJSON
|
||||
|
||||
def create(template_json)
|
||||
cluster_hash = parse_json(template_json, 'cluster')
|
||||
|
||||
if OpenNebula.is_error?(cluster_hash)
|
||||
return cluster_hash
|
||||
end
|
||||
|
||||
|
||||
self.allocate(cluster_hash['name'])
|
||||
end
|
||||
|
||||
@ -37,9 +35,43 @@ module OpenNebulaJSON
|
||||
return action_hash
|
||||
end
|
||||
|
||||
error_msg = "#{action_hash['perform']} action not " <<
|
||||
" available for this resource"
|
||||
OpenNebula::Error.new(error_msg)
|
||||
rc = case action_hash['perform']
|
||||
when "addhost" then self.addhost(action_hash['params'])
|
||||
when "delhost" then self.delhost(action_hash['params'])
|
||||
when "adddatastore" then self.adddatastore(action_hash['params'])
|
||||
when "deldatastore" then self.deldatastore(action_hash['params'])
|
||||
when "addvnet" then self.addvnet(action_hash['params'])
|
||||
when "delvnet" then self.delvnet(action_hash['params'])
|
||||
|
||||
else
|
||||
error_msg = "#{action_hash['perform']} action not " <<
|
||||
" available for this resource"
|
||||
OpenNebula::Error.new(error_msg)
|
||||
end
|
||||
end
|
||||
|
||||
def addhost(params=Hash.new)
|
||||
super(params['host_id'].to_i)
|
||||
end
|
||||
|
||||
def delhost(params=Hash.new)
|
||||
super(params['host_id'].to_i)
|
||||
end
|
||||
|
||||
def adddatastore(params=Hash.new)
|
||||
super(params['ds_id'].to_i)
|
||||
end
|
||||
|
||||
def deldatastore(params=Hash.new)
|
||||
super(params['ds_id'].to_i)
|
||||
end
|
||||
|
||||
def addvnet(params=Hash.new)
|
||||
super(params['vnet_id'].to_i)
|
||||
end
|
||||
|
||||
def delvnet(params=Hash.new)
|
||||
super(params['vnet_id'].to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ module OpenNebulaJSON
|
||||
host_hash['im_mad'],
|
||||
host_hash['vm_mad'],
|
||||
host_hash['vnm_mad'],
|
||||
host_hash['tm_mad'])
|
||||
host_hash['cluster_id'].to_i)
|
||||
end
|
||||
|
||||
def delete
|
||||
|
@ -25,4 +25,5 @@ module OpenNebulaJSON
|
||||
class GroupPoolJSON < OpenNebula::GroupPool; include JSONUtils; end
|
||||
class UserPoolJSON < OpenNebula::UserPool; include JSONUtils; end
|
||||
class AclPoolJSON < OpenNebula::AclPool; include JSONUtils; end
|
||||
class ClusterPoolJSON < OpenNebula::ClusterPool; include JSONUtils; end
|
||||
end
|
||||
|
@ -48,6 +48,7 @@ class SunstoneServer < CloudServer
|
||||
|
||||
pool = case kind
|
||||
when "group" then GroupPoolJSON.new(@client)
|
||||
when "cluster" then ClusterPoolJSON.new(@client)
|
||||
when "host" then HostPoolJSON.new(@client)
|
||||
when "image" then ImagePoolJSON.new(@client, user_flag)
|
||||
when "vmtemplate" then TemplatePoolJSON.new(@client, user_flag)
|
||||
@ -100,6 +101,7 @@ class SunstoneServer < CloudServer
|
||||
def create_resource(kind, template)
|
||||
resource = case kind
|
||||
when "group" then GroupJSON.new(Group.build_xml, @client)
|
||||
when "cluster" then ClusterJSON.new(Group.build_xml, @client)
|
||||
when "host" then HostJSON.new(Host.build_xml, @client)
|
||||
when "image" then ImageJSON.new(Image.build_xml, @client)
|
||||
when "vmtemplate" then TemplateJSON.new(Template.build_xml, @client)
|
||||
@ -275,6 +277,7 @@ class SunstoneServer < CloudServer
|
||||
def retrieve_resource(kind, id)
|
||||
resource = case kind
|
||||
when "group" then GroupJSON.new_with_id(id, @client)
|
||||
when "cluster" then ClusterJSON.new_with_id(id, @client)
|
||||
when "host" then HostJSON.new_with_id(id, @client)
|
||||
when "image" then ImageJSON.new_with_id(id, @client)
|
||||
when "vmtemplate" then TemplateJSON.new_with_id(id, @client)
|
||||
|
@ -852,5 +852,49 @@ var OpenNebula = {
|
||||
"list" : function(params){
|
||||
OpenNebula.Action.list(params,OpenNebula.Acl.resource);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Cluster" : {
|
||||
"resource" : "CLUSTER",
|
||||
|
||||
"create" : function(params){
|
||||
OpenNebula.Action.create(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
"delete" : function(params){
|
||||
OpenNebula.Action.delete(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
"list" : function(params){
|
||||
OpenNebula.Action.list(params,OpenNebula.Cluster.resource);
|
||||
},
|
||||
"addhost" : function(params){
|
||||
var action_obj = { "host_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"addhost",action_obj);
|
||||
},
|
||||
"delhost" : function(params){
|
||||
var action_obj = { "host_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"delhost",action_obj);
|
||||
},
|
||||
"adddatastore" : function(params){
|
||||
var action_obj = { "ds_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"adddatastore",action_obj);
|
||||
},
|
||||
"deldatastore" : function(params){
|
||||
var action_obj = { "ds_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"deldatastore",action_obj);
|
||||
},
|
||||
"addvnet" : function(params){
|
||||
var action_obj = { "vnet_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"addvnet",action_obj);
|
||||
},
|
||||
"delvnet" : function(params){
|
||||
var action_obj = { "vnet_id": params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
|
||||
"delvnet",action_obj);
|
||||
},
|
||||
},
|
||||
}
|
||||
|
511
src/sunstone/public/js/plugins/clusters-tab.js
Normal file
511
src/sunstone/public/js/plugins/clusters-tab.js
Normal file
@ -0,0 +1,511 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*Cluster tab plugin*/
|
||||
|
||||
|
||||
var clusters_tab_content =
|
||||
'<form id="form_cluters" action="javascript:alert(\'js errors?!\')">\
|
||||
<div class="action_blocks">\
|
||||
</div>\
|
||||
<table id="datatable_clusters" class="display">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">' + tr("All") + '</input></th>\
|
||||
<th>' + tr("id") + '</th>\
|
||||
<th>' + tr("Name") + '</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyclusters">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</form>';
|
||||
|
||||
var create_cluster_tmpl =
|
||||
'<div class="create_form"><form id="create_cluster_form" action="">\
|
||||
<fieldset>\
|
||||
<label for="name">' + tr("Name") + ':</label><input type="text" name="name" id="name" />\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<div><button class="button" type="submit" id="create_cluster_submit" value="OpenNebula.Cluster.create">' + tr("Create") + '</button>\
|
||||
<button class="button" type="reset" value="reset">' + tr("Reset") + '</button></div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form></div>';
|
||||
|
||||
var clusters_select="";
|
||||
var dataTable_clusters;
|
||||
var $create_cluster_dialog;
|
||||
|
||||
//Setup actions
|
||||
var cluster_actions = {
|
||||
|
||||
"Cluster.create" : {
|
||||
type: "create",
|
||||
call : OpenNebula.Cluster.create,
|
||||
callback : addClusterElement,
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Cluster.create_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpCreateClusterDialog
|
||||
},
|
||||
|
||||
"Cluster.list" : {
|
||||
type: "list",
|
||||
call: OpenNebula.Cluster.list,
|
||||
callback: updateClustersView,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Cluster.show" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Cluster.show,
|
||||
callback: updateClusterElement,
|
||||
error: onError
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
"Cluster.showinfo" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Cluster.show,
|
||||
callback: updateClusterInfo,
|
||||
error: onError
|
||||
},
|
||||
*/
|
||||
|
||||
"Cluster.refresh" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
waitingNodes(dataTable_clusters);
|
||||
Sunstone.runAction("Cluster.list");
|
||||
},
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Cluster.autorefresh" : {
|
||||
type: "custom",
|
||||
call : function() {
|
||||
OpenNebula.Cluster.list({timeout: true, success: updateClustersView,error: onError});
|
||||
}
|
||||
},
|
||||
|
||||
"Cluster.addhost" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.addhost,
|
||||
callback : function (req) {
|
||||
Sunstone.runAction("Host.show",req.request.data[0][1].host_id);
|
||||
},
|
||||
error : onError,
|
||||
},
|
||||
|
||||
"Cluster.delhost" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.delhost,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction("Cluster.show",req.request.data[0]);
|
||||
},
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Cluster.adddatastore" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.addhost,
|
||||
callback : function (req) {
|
||||
Sunstone.runAction("Datastore.show",req.request.data[0][1].ds_id);
|
||||
//Sunstone.runAction("Cluster.show",req.request.data[0]);
|
||||
},
|
||||
error : onError,
|
||||
},
|
||||
|
||||
"Cluster.deldatastore" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.addhost,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction("Cluster.show",req.request.data[0]);
|
||||
},
|
||||
error : onError,
|
||||
},
|
||||
|
||||
"Cluster.addvnet" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.addvnet,
|
||||
callback : function (req) {
|
||||
Sunstone.runAction("Network.show",req.request.data[0][1].vnet_id);
|
||||
},
|
||||
error : onError,
|
||||
},
|
||||
|
||||
"Cluster.delvnet" : {
|
||||
type: "single",
|
||||
call : OpenNebula.Cluster.delvnet,
|
||||
callback : function (req) {
|
||||
//Sunstone.runAction("Cluster.show",req.request.data[0]);
|
||||
},
|
||||
error : onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Cluster.delete" : {
|
||||
type: "multiple",
|
||||
call : OpenNebula.Cluster.delete,
|
||||
callback : deleteClusterElement,
|
||||
elements: clusterElements,
|
||||
error : onError,
|
||||
notify:true
|
||||
},
|
||||
};
|
||||
|
||||
var cluster_buttons = {
|
||||
"Cluster.refresh" : {
|
||||
type: "image",
|
||||
text: tr("Refresh list"),
|
||||
img: "images/Refresh-icon.png"
|
||||
},
|
||||
"Cluster.create_dialog" : {
|
||||
type: "create_dialog",
|
||||
text: tr("+ New")
|
||||
},
|
||||
"Cluster.delete" : {
|
||||
type: "confirm",
|
||||
text: tr("Delete")
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
var host_info_panel = {
|
||||
"host_info_tab" : {
|
||||
title: tr("Host information"),
|
||||
content:""
|
||||
},
|
||||
|
||||
"host_template_tab" : {
|
||||
title: tr("Host template"),
|
||||
content: ""
|
||||
},
|
||||
"host_monitoring_tab": {
|
||||
title: tr("Monitoring information"),
|
||||
content: ""
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
var clusters_tab = {
|
||||
title: tr("Clusters"),
|
||||
content: clusters_tab_content,
|
||||
buttons: cluster_buttons
|
||||
}
|
||||
|
||||
Sunstone.addActions(cluster_actions);
|
||||
Sunstone.addMainTab('clusters_tab',clusters_tab);
|
||||
//Sunstone.addInfoPanel("host_info_panel",host_info_panel);
|
||||
|
||||
|
||||
function clusterElements(){
|
||||
return getSelectedNodes(dataTable_clusters);
|
||||
}
|
||||
|
||||
function clusterElementArray(element_json){
|
||||
|
||||
var element = element_json.CLUSTER;
|
||||
|
||||
return [
|
||||
'<input class="check_item" type="checkbox" id="cluster_'+element.ID+'" name="selected_items" value="'+element.ID+'"/>',
|
||||
element.ID,
|
||||
element.NAME,
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
//Listen to clicks on the tds of the tables and shows the info dialogs.
|
||||
function hostInfoListener(){
|
||||
$('#tbodyhosts tr',dataTable_hosts).live("click",function(e){
|
||||
//do nothing if we are clicking a checkbox!
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
|
||||
var aData = dataTable_hosts.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
if (!id) return true;
|
||||
|
||||
popDialogLoading();
|
||||
Sunstone.runAction("Host.showinfo",id);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
//updates the host select by refreshing the options in it
|
||||
function updateClusterSelect(){
|
||||
clusters_select = '<option value="-1">Default (none)</option>';
|
||||
clusters_select += makeSelectOptions(dataTable_clusters,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[],//status_cols
|
||||
[],//bad_st
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
//callback for an action affecting a host element
|
||||
function updateClusterElement(request, element_json){
|
||||
var id = element_json.CLUSTER.ID;
|
||||
var element = clusterElementArray(element_json);
|
||||
updateSingleElement(element,dataTable_clusters,'#cluster_'+id);
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//callback for actions deleting a host element
|
||||
function deleteClusterElement(req){
|
||||
deleteElement(dataTable_clusters,'#cluster_'+req.request.data);
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//call back for actions creating a host element
|
||||
function addClusterElement(request,element_json){
|
||||
var id = element_json.CLUSTER.ID;
|
||||
var element = clusterElementArray(element_json);
|
||||
addElement(element,dataTable_clusters);
|
||||
updateClusterSelect();
|
||||
}
|
||||
|
||||
//callback to update the list of hosts.
|
||||
function updateClustersView (request,list){
|
||||
var list_array = [];
|
||||
|
||||
$.each(list,function(){
|
||||
//Grab table data from the host_list
|
||||
list_array.push(clusterElementArray(this));
|
||||
});
|
||||
|
||||
updateView(list_array,dataTable_clusters);
|
||||
updateClusterSelect();
|
||||
//dependency with the dashboard plugin
|
||||
updateDashboard("clusters",list);
|
||||
}
|
||||
|
||||
/*
|
||||
//Updates the host info panel tab's content and pops it up
|
||||
function updateHostInfo(request,host){
|
||||
var host_info = host.HOST;
|
||||
|
||||
//Information tab
|
||||
var info_tab = {
|
||||
title : tr("Host information"),
|
||||
content :
|
||||
'<table id="info_host_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">' + tr("Host information") + ' - '+host_info.NAME+'</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("id") + '</td>\
|
||||
<td class="value_td">'+host_info.ID+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Name") + '</td>\
|
||||
<td class="value_td">'+host_info.NAME+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Cluster") + '</td>\
|
||||
<td class="value_td">'+host_info.CLUSTER+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("State") + '</td>\
|
||||
<td class="value_td">'+tr(OpenNebula.Helper.resource_state("host",host_info.STATE))+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("IM MAD") + '</td>\
|
||||
<td class="value_td">'+host_info.IM_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("VM MAD") + '</td>\
|
||||
<td class="value_td">'+host_info.VM_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("VN MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.VN_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("TM MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.TM_MAD+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<table id="host_shares_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">' + tr("Host shares") + '</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Max Mem") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_MEM)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used Mem (real)") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.USED_MEM)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used Mem (allocated)") + '</td>\
|
||||
<td class="value_td">'+humanize_size(host_info.HOST_SHARE.MAX_USAGE)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used CPU (real)") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.USED_CPU+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Used CPU (allocated)") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.CPU_USAGE+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Running VMs") + '</td>\
|
||||
<td class="value_td">'+host_info.HOST_SHARE.RUNNING_VMS+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>'
|
||||
}
|
||||
|
||||
//Template tab
|
||||
var template_tab = {
|
||||
title : tr("Host template"),
|
||||
content :
|
||||
'<table id="host_template_table" class="info_table" style="width:80%">\
|
||||
<thead><tr><th colspan="2">' + tr("Host template") + '</th></tr></thead>'+
|
||||
prettyPrintJSON(host_info.TEMPLATE)+
|
||||
'</table>'
|
||||
}
|
||||
|
||||
var monitor_tab = {
|
||||
title: tr("Monitoring information"),
|
||||
content : generateMonitoringDivs(host_graphs,"host_monitor_")
|
||||
}
|
||||
|
||||
//Sunstone.updateInfoPanelTab(info_panel_name,tab_name, new tab object);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_info_tab",info_tab);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_template_tab",template_tab);
|
||||
Sunstone.updateInfoPanelTab("host_info_panel","host_monitoring_tab",monitor_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("host_info_panel");
|
||||
//pop up panel while we retrieve the graphs
|
||||
for (var i=0; i<host_graphs.length; i++){
|
||||
Sunstone.runAction("Host.monitor",host_info.ID,host_graphs[i]);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//Prepares the host creation dialog
|
||||
function setupCreateClusterDialog(){
|
||||
dialogs_context.append('<div title=\"'+tr("Create cluster")+'\" id="create_cluster_dialog"></div>');
|
||||
$create_cluster_dialog = $('div#create_cluster_dialog');
|
||||
var dialog = $create_cluster_dialog;
|
||||
|
||||
dialog.html(create_cluster_tmpl);
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
width: 500
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
//Handle the form submission
|
||||
$('#create_cluster_form',dialog).submit(function(){
|
||||
if (!($('#name',this).val().length)){
|
||||
notifyError(tr("Cluster name missing!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
var cluster_json = {
|
||||
"cluster": {
|
||||
"name": $('#name',this).val(),
|
||||
}
|
||||
};
|
||||
|
||||
//Create the OpenNebula.Host.
|
||||
//If it's successfull we refresh the list.
|
||||
Sunstone.runAction("Cluster.create",cluster_json);
|
||||
$create_cluster_dialog.dialog('close');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//Open creation dialogs
|
||||
function popUpCreateClusterDialog(){
|
||||
$create_cluster_dialog.dialog('open');
|
||||
return false;
|
||||
}
|
||||
|
||||
//Prepares the autorefresh for hosts
|
||||
function setClusterAutorefresh() {
|
||||
setInterval(function(){
|
||||
var checked = $('input.check_item:checked',dataTable_clusters);
|
||||
var filter = $("#datatable_clusters_filter input",dataTable_clusters.parents('#datatable_clusters_wrapper')).attr('value');
|
||||
if (!checked.length && !filter.length){
|
||||
Sunstone.runAction("Cluster.autorefresh");
|
||||
}
|
||||
},INTERVAL+someTime());
|
||||
}
|
||||
|
||||
|
||||
function clusters_sel() {
|
||||
return clusters_select;
|
||||
}
|
||||
|
||||
//This is executed after the sunstone.js ready() is run.
|
||||
//Here we can basicly init the host datatable, preload it
|
||||
//and add specific listeners
|
||||
$(document).ready(function(){
|
||||
|
||||
//prepare host datatable
|
||||
dataTable_clusters = $("#datatable_clusters",main_tabs_context).dataTable({
|
||||
"bJQueryUI": true,
|
||||
"bSortClasses": false,
|
||||
"bAutoWidth":false,
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
//preload it
|
||||
dataTable_clusters.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','',''],dataTable_clusters);
|
||||
Sunstone.runAction("Cluster.list");
|
||||
|
||||
setupCreateClusterDialog();
|
||||
|
||||
setClusterAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_clusters);
|
||||
tableCheckboxesListener(dataTable_clusters);
|
||||
// clusterInfoListener();
|
||||
});
|
@ -43,6 +43,7 @@ var hosts_tab_content =
|
||||
<th class="check"><input type="checkbox" class="check_all" value="">' + tr("All") + '</input></th>\
|
||||
<th>' + tr("id") + '</th>\
|
||||
<th>' + tr("Name") + '</th>\
|
||||
<th>' + tr("Cluster") + '</th>\
|
||||
<th>' + tr("Running VMs") + '</th>\
|
||||
<th>' + tr("CPU Use") + '</th>\
|
||||
<th>' + tr("Memory use") + '</th>\
|
||||
@ -93,19 +94,15 @@ var create_host_tmpl =
|
||||
<option value="vmware">VMware</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="tm_mads">\
|
||||
<label>' + tr("Transfer Manager") + ':</label>\
|
||||
<select id="tm_mad" name="tm">\
|
||||
<option value="tm_shared">' + tr("Shared") + '</option>\
|
||||
<option value="tm_ssh">' + tr("SSH") + '</option>\
|
||||
<option value="tm_vmware">' + tr("VMware") + '</option>\
|
||||
<option value="tm_dummy">' + tr("Dummy") + '</option>\
|
||||
<div class="manager clear" id="cluster_select">\
|
||||
<label>' + tr("Cluster") + ':</label>\
|
||||
<select id="host_cluster_id" name="host_cluster_id">\
|
||||
</select>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<div><button class="button" id="create_host_submit" value="OpenNebula.Host.create">' + tr("Create") + '</button>\
|
||||
<div><button class="button" type="submit" id="create_host_submit" value="OpenNebula.Host.create">' + tr("Create") + '</button>\
|
||||
<button class="button" type="reset" value="reset">' + tr("Reset") + '</button></div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
@ -250,7 +247,20 @@ var host_actions = {
|
||||
notifyMessage(tr("Template updated correctly"));
|
||||
},
|
||||
error: onError
|
||||
}
|
||||
},
|
||||
|
||||
"Host.addtocluster" : {
|
||||
type: "multiple",
|
||||
call: function(params){
|
||||
var cluster = params.data.extra_param;
|
||||
var host = params.data.id;
|
||||
Sunstone.runAction("Cluster.addhost",cluster,host);
|
||||
},
|
||||
callback: null,
|
||||
elements: hostElements,
|
||||
notify:true,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
var host_buttons = {
|
||||
@ -268,6 +278,12 @@ var host_buttons = {
|
||||
text: tr("Update a template"),
|
||||
alwaysActive: true
|
||||
},
|
||||
"Host.addtocluster" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Select cluster"),
|
||||
select: clusters_sel,
|
||||
tip: tr("Select the destination cluster:"),
|
||||
},
|
||||
"Host.enable" : {
|
||||
type: "action",
|
||||
text: tr("Enable")
|
||||
@ -305,6 +321,11 @@ var hosts_tab = {
|
||||
buttons: host_buttons
|
||||
}
|
||||
|
||||
//Hack since this plugin is loaded earlier
|
||||
function clusters_sel() {
|
||||
return clusters_select;
|
||||
}
|
||||
|
||||
Sunstone.addActions(host_actions);
|
||||
Sunstone.addMainTab('hosts_tab',hosts_tab);
|
||||
Sunstone.addInfoPanel("host_info_panel",host_info_panel);
|
||||
@ -362,6 +383,7 @@ function hostElementArray(host_json){
|
||||
'<input class="check_item" type="checkbox" id="host_'+host.ID+'" name="selected_items" value="'+host.ID+'"/>',
|
||||
host.ID,
|
||||
host.NAME,
|
||||
host.CLUSTER,
|
||||
host.HOST_SHARE.RUNNING_VMS, //rvm
|
||||
pb_cpu,
|
||||
pb_mem,
|
||||
@ -389,7 +411,7 @@ function updateHostSelect(){
|
||||
hosts_select = makeSelectOptions(dataTable_hosts,
|
||||
1,//id_col
|
||||
2,//name_col
|
||||
[6,6],//status_cols
|
||||
[7,7],//status_cols
|
||||
["ERROR","OFF"]//bad_st
|
||||
);
|
||||
}
|
||||
@ -448,6 +470,14 @@ function updateHostInfo(request,host){
|
||||
<td class="key_td">' + tr("id") + '</td>\
|
||||
<td class="value_td">'+host_info.ID+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Name") + '</td>\
|
||||
<td class="value_td">'+host_info.NAME+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("Cluster") + '</td>\
|
||||
<td class="value_td">'+host_info.CLUSTER+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">' + tr("State") + '</td>\
|
||||
<td class="value_td">'+tr(OpenNebula.Helper.resource_state("host",host_info.STATE))+'</td>\
|
||||
@ -553,15 +583,19 @@ function setupCreateHostDialog(){
|
||||
notifyError(tr("Host name missing!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
var cluster_id = $('#host_cluster_id',this).val();
|
||||
if (!cluster_id) cluster_id = "-1";
|
||||
|
||||
var host_json = {
|
||||
"host": {
|
||||
"name": $('#name',this).val(),
|
||||
"tm_mad": $('#tm_mad :selected',this).val(),
|
||||
"vm_mad": $('#vmm_mad :selected',this).val(),
|
||||
"vnm_mad": $('#vnm_mad :selected',this).val(),
|
||||
"im_mad": $('#im_mad :selected',this).val()
|
||||
"vm_mad": $('#vmm_mad',this).val(),
|
||||
"vnm_mad": $('#vnm_mad',this).val(),
|
||||
"im_mad": $('#im_mad',this).val(),
|
||||
"cluster_id": cluster_id
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Create the OpenNebula.Host.
|
||||
//If it's successfull we refresh the list.
|
||||
@ -573,6 +607,7 @@ function setupCreateHostDialog(){
|
||||
|
||||
//Open creation dialogs
|
||||
function popUpCreateHostDialog(){
|
||||
$('#host_cluster_id',$create_host_dialog).html(clusters_select);
|
||||
$create_host_dialog.dialog('open');
|
||||
return false;
|
||||
}
|
||||
@ -614,22 +649,22 @@ $(document).ready(function(){
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0,3] },
|
||||
{ "sWidth": "60px", "aTargets": [0,4] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
{ "sWidth": "100px", "aTargets": [6] },
|
||||
{ "sWidth": "200px", "aTargets": [4,5] }
|
||||
{ "sWidth": "100px", "aTargets": [7,3] },
|
||||
{ "sWidth": "200px", "aTargets": [5,6] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
sUrl: "locale/"+lang+"/"+datatable_lang
|
||||
} : ""
|
||||
});
|
||||
|
||||
//preload it
|
||||
dataTable_hosts.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','','','',''],dataTable_hosts);
|
||||
'','','','','','',''],dataTable_hosts);
|
||||
Sunstone.runAction("Host.list");
|
||||
|
||||
setupCreateHostDialog();
|
||||
|
@ -28,6 +28,7 @@ var vnets_tab_content =
|
||||
<th>'+tr("Owner")+'</th>\
|
||||
<th>'+tr("Group")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
<th>'+tr("Cluster")+'</th>\
|
||||
<th>'+tr("Type")+'</th>\
|
||||
<th>'+tr("Bridge")+'</th>\
|
||||
<th>'+tr("Total Leases")+'</th>\
|
||||
@ -49,6 +50,7 @@ var create_vn_tmpl =
|
||||
<fieldset>\
|
||||
<label for="name">'+tr("Name")+':</label>\
|
||||
<input type="text" name="name" id="name" /><br />\
|
||||
<br />\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<label for="network_mode">'+tr("Network mode")+':</label>\
|
||||
@ -380,6 +382,18 @@ var vnet_actions = {
|
||||
error: onError
|
||||
},
|
||||
|
||||
"Network.addtocluster" : {
|
||||
type: "multiple",
|
||||
call: function(params){
|
||||
var cluster = params.data.extra_param;
|
||||
var vnet = params.data.id;
|
||||
Sunstone.runAction("Cluster.addvnet",cluster,vnet);
|
||||
},
|
||||
callback: null,
|
||||
elements: vnElements,
|
||||
notify:true,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -400,7 +414,12 @@ var vnet_buttons = {
|
||||
text: tr("Update properties"),
|
||||
alwaysActive: true
|
||||
},
|
||||
|
||||
"Network.addtocluster" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Select cluster"),
|
||||
select: clusters_sel,
|
||||
tip: tr("Select the destination cluster:"),
|
||||
},
|
||||
"Network.chown" : {
|
||||
type: "confirm_with_select",
|
||||
text: tr("Change owner"),
|
||||
@ -463,6 +482,7 @@ function vNetworkElementArray(vn_json){
|
||||
network.UNAME,
|
||||
network.GNAME,
|
||||
network.NAME,
|
||||
network.CLUSTER,
|
||||
parseInt(network.TYPE) ? "FIXED" : "RANGED",
|
||||
network.BRIDGE,
|
||||
network.TOTAL_LEASES ];
|
||||
@ -539,6 +559,10 @@ function updateVNetworkInfo(request,vn){
|
||||
<td class="key_td">'+tr("Name")+'</td>\
|
||||
<td class="value_td">'+vn_info.NAME+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Cluster")+'</td>\
|
||||
<td class="value_td">'+vn_info.CLUSTER+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Owner")+'</td>\
|
||||
<td class="value_td">'+vn_info.UNAME+'</td>\
|
||||
@ -849,6 +873,7 @@ function setupCreateVNetDialog() {
|
||||
var phydev = $('#phydev',this).val();
|
||||
var vlan = $('#vlan',this).val();
|
||||
var vlan_id = $('#vlan_id',this).val();
|
||||
|
||||
switch (network_mode) {
|
||||
case "default":
|
||||
if (!bridge && !phydev){
|
||||
@ -948,7 +973,9 @@ function setupCreateVNetDialog() {
|
||||
|
||||
//Create the VNetwork.
|
||||
|
||||
network_json = {"vnet" : network_json};
|
||||
network_json = {
|
||||
"vnet" : network_json,
|
||||
};
|
||||
|
||||
Sunstone.runAction("Network.create",network_json);
|
||||
$create_vn_dialog.dialog('close');
|
||||
@ -1145,9 +1172,9 @@ $(document).ready(function(){
|
||||
"sPaginationType": "full_numbers",
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0,5,6,7] },
|
||||
{ "sWidth": "60px", "aTargets": [0,6,7,8] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
{ "sWidth": "100px", "aTargets": [2,3] }
|
||||
{ "sWidth": "100px", "aTargets": [2,3,5] }
|
||||
],
|
||||
"oLanguage": (datatable_lang != "") ?
|
||||
{
|
||||
@ -1158,7 +1185,7 @@ $(document).ready(function(){
|
||||
dataTable_vNetworks.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','','','','',''],dataTable_vNetworks);
|
||||
'','','','','','','',''],dataTable_vNetworks);
|
||||
Sunstone.runAction("Network.list");
|
||||
|
||||
setupCreateVNetDialog();
|
||||
|
Loading…
x
Reference in New Issue
Block a user