diff --git a/install.sh b/install.sh
index 8ca6422020..d5de5583f0 100755
--- a/install.sh
+++ b/install.sh
@@ -1118,6 +1118,7 @@ SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \
src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb \
src/sunstone/models/OpenNebulaJSON/AclJSON.rb \
src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb \
+ src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb \
src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb"
SUNSTONE_TEMPLATE_FILES="src/sunstone/templates/login.html \
@@ -1137,6 +1138,7 @@ SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\
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/datastores-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 \
diff --git a/src/sunstone/etc/sunstone-plugins.yaml b/src/sunstone/etc/sunstone-plugins.yaml
index d08072929d..ff4d2aaac3 100644
--- a/src/sunstone/etc/sunstone-plugins.yaml
+++ b/src/sunstone/etc/sunstone-plugins.yaml
@@ -23,6 +23,10 @@
:ALL: true
:user:
:group:
+- plugins/datastores-tab.js:
+ :ALL: true
+ :user:
+ :group:
- plugins/templates-tab.js:
:ALL: true
:user:
diff --git a/src/sunstone/models/OpenNebulaJSON.rb b/src/sunstone/models/OpenNebulaJSON.rb
index 60b0ab116c..7055b7a302 100644
--- a/src/sunstone/models/OpenNebulaJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON.rb
@@ -28,6 +28,7 @@ require 'OpenNebulaJSON/UserJSON'
require 'OpenNebulaJSON/VirtualMachineJSON'
require 'OpenNebulaJSON/VirtualNetworkJSON'
require 'OpenNebulaJSON/AclJSON'
+require 'OpenNebulaJSON/DatastoreJSON'
module OpenNebula
class Error
diff --git a/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb b/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb
index 554f901b38..095f30d61a 100644
--- a/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb
@@ -17,23 +17,27 @@
require 'OpenNebulaJSON/JSONUtils'
module OpenNebulaJSON
- class ClusterJSON < OpenNebula::Datastore
+ class DatastoreJSON < OpenNebula::Datastore
include JSONUtils
- def create(template_json, cluster_id=ClusterPool::NONE_CLUSTER_ID)
- datastore_hash = parse_json(template_json, 'datastore')
-
- if OpenNebula.is_error?(datastore_hash)
- return datastore_hash
+ def create(template_json)
+ ds_hash = parse_json(template_json, 'datastore')
+ if OpenNebula.is_error?(ds_hash)
+ return ds_hash
end
- if datastore_hash['datastore_raw']
- template = datastore_hash['image_raw']
+ cluster_id = parse_json(template_json, 'cluster_id')
+ if OpenNebula.is_error?(cluster_id)
+ return cluster_id
+ end
+
+ if ds_hash['datastore_raw']
+ template = ds_hash['datastore_raw']
else
- template = template_to_str(datastore_hash)
+ template = template_to_str(ds_hash)
end
- self.allocate(template,cluster_id)
+ self.allocate(template,cluster_id.to_i)
end
def perform_action(template_json)
@@ -42,9 +46,27 @@ 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 "update" then self.update(action_hash['params'])
+ when "chown" then self.chown(action_hash['params'])
+ when "chmod" then self.chmod_octet(action_hash['params'])
+ else
+ error_msg = "#{action_hash['perform']} action not " <<
+ " available for this resource"
+ OpenNebula::Error.new(error_msg)
+ end
+ end
+
+ def update(params=Hash.new)
+ super(params['template_raw'])
+ end
+
+ def chown(params=Hash.new)
+ super(params['owner_id'].to_i,params['group_id'].to_i)
+ end
+
+ def chmod_octet(params=Hash.new)
+ super(params['octet'])
end
end
end
diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
index 8a5f0a0d35..11c03966ee 100644
--- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb
@@ -26,13 +26,18 @@ module OpenNebulaJSON
return image_hash
end
+ ds_id = parse_json(template_json, 'ds_id')
+ if OpenNebula.is_error?(ds_id)
+ return ds_id
+ end
+
if image_hash['image_raw']
template = image_hash['image_raw']
else
template = template_to_str(image_hash)
end
- self.allocate(template)
+ self.allocate(template,ds_id)
end
def perform_action(template_json)
diff --git a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb
index fe8e67dcfd..791b723645 100644
--- a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb
@@ -26,4 +26,5 @@ module OpenNebulaJSON
class UserPoolJSON < OpenNebula::UserPool; include JSONUtils; end
class AclPoolJSON < OpenNebula::AclPool; include JSONUtils; end
class ClusterPoolJSON < OpenNebula::ClusterPool; include JSONUtils; end
+ class DatastorePoolJSON < OpenNebula::DatastorePool; include JSONUtils; end
end
diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb
index 7a64255bb6..fba385ec96 100644
--- a/src/sunstone/models/SunstoneServer.rb
+++ b/src/sunstone/models/SunstoneServer.rb
@@ -56,6 +56,7 @@ class SunstoneServer < CloudServer
when "vnet" then VirtualNetworkPoolJSON.new(@client, user_flag)
when "user" then UserPoolJSON.new(@client)
when "acl" then AclPoolJSON.new(@client)
+ when "datastore" then DatastorePoolJSON.new(@client)
else
error = Error.new("Error: #{kind} resource not supported")
return [404, error.to_json]
@@ -109,6 +110,7 @@ class SunstoneServer < CloudServer
when "vnet" then VirtualNetworkJSON.new(VirtualNetwork.build_xml, @client)
when "user" then UserJSON.new(User.build_xml, @client)
when "acl" then AclJSON.new(Acl.build_xml, @client)
+ when "datastore" then DatastoreJSON.new(Acl.build_xml, @client)
else
error = Error.new("Error: #{kind} resource not supported")
return [404, error.to_json]
@@ -276,15 +278,16 @@ 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 "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)
- when "vm" then VirtualMachineJSON.new_with_id(id, @client)
- when "vnet" then VirtualNetworkJSON.new_with_id(id, @client)
- when "user" then UserJSON.new_with_id(id, @client)
- when "acl" then AclJSON.new_with_id(id, @client)
+ when "vm" then VirtualMachineJSON.new_with_id(id, @client)
+ when "vnet" then VirtualNetworkJSON.new_with_id(id, @client)
+ when "user" then UserJSON.new_with_id(id, @client)
+ when "acl" then AclJSON.new_with_id(id, @client)
+ when "datastore" then DatastoreJSON.new_with_id(id, @client)
else
error = Error.new("Error: #{kind} resource not supported")
return error
diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js
index 560170b6ea..eb4f149d30 100644
--- a/src/sunstone/public/js/opennebula.js
+++ b/src/sunstone/public/js/opennebula.js
@@ -866,6 +866,9 @@ var OpenNebula = {
"list" : function(params){
OpenNebula.Action.list(params,OpenNebula.Cluster.resource);
},
+ "show" : function(params){
+ OpenNebula.Action.show(params,OpenNebula.Cluster.resource);
+ },
"addhost" : function(params){
var action_obj = { "host_id": params.data.extra_param };
OpenNebula.Action.simple_action(params,OpenNebula.Cluster.resource,
@@ -897,4 +900,43 @@ var OpenNebula = {
"delvnet",action_obj);
},
},
+ "Datastore" : {
+ "resource" : "DATASTORE",
+
+ "create" : function(params){
+ OpenNebula.Action.create(params,OpenNebula.Datastore.resource);
+ },
+ "delete" : function(params){
+ OpenNebula.Action.delete(params,OpenNebula.Datastore.resource);
+ },
+ "list" : function(params){
+ OpenNebula.Action.list(params,OpenNebula.Datastore.resource);
+ },
+ "show" : function(params){
+ OpenNebula.Action.show(params,OpenNebula.Datastore.resource);
+ },
+ "chown" : function(params){
+ OpenNebula.Action.chown(params,OpenNebula.Datastore.resource);
+ },
+ "chgrp" : function(params){
+ OpenNebula.Action.chgrp(params,OpenNebula.Datastore.resource);
+ },
+ "chmod" : function(params){
+ var action_obj = params.data.extra_param;
+ OpenNebula.Action.simple_action(params,
+ OpenNebula.Datastore.resource,
+ "chmod",
+ action_obj);
+ },
+ "update" : function(params){
+ var action_obj = {"template_raw" : params.data.extra_param };
+ OpenNebula.Action.simple_action(params,
+ OpenNebula.Datastore.resource,
+ "update",
+ action_obj);
+ },
+ "fetch_template" : function(params){
+ OpenNebula.Action.show(params,OpenNebula.Datastore.resource,"template");
+ },
+ },
}
diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js
index 9216424a7b..8688c3be92 100644
--- a/src/sunstone/public/js/plugins/acls-tab.js
+++ b/src/sunstone/public/js/plugins/acls-tab.js
@@ -45,8 +45,10 @@ var create_acl_tmpl =
'+tr("This rule applies to")+': \
\
\
- '+tr("Affected resources")+': \
+ '+tr("Affected resources")+': \
'+tr("Hosts")+' \
+ '+tr("Clusters")+' \
+ '+tr("Datastores")+' \
'+tr("Virtual Machines")+' \
'+tr("Virtual Networks")+' \
'+tr("Images")+' \
@@ -247,6 +249,12 @@ function parseAclString(string) {
case "GROUP":
resources_str+=tr("Groups")+", ";
break;
+ case "CLUSTER":
+ resources_str+=tr("Clusters")+", ";
+ break;
+ case "DATASTORE":
+ resources_str+=tr("Datastores")+", ";
+ break;
};
};
//remove ", " from end
diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js
index 3d4a2079ca..0a9a90c52a 100644
--- a/src/sunstone/public/js/plugins/clusters-tab.js
+++ b/src/sunstone/public/js/plugins/clusters-tab.js
@@ -128,7 +128,7 @@ var cluster_actions = {
"Cluster.adddatastore" : {
type: "single",
- call : OpenNebula.Cluster.addhost,
+ call : OpenNebula.Cluster.adddatastore,
callback : function (req) {
Sunstone.runAction("Datastore.show",req.request.data[0][1].ds_id);
//Sunstone.runAction("Cluster.show",req.request.data[0]);
@@ -138,7 +138,7 @@ var cluster_actions = {
"Cluster.deldatastore" : {
type: "single",
- call : OpenNebula.Cluster.addhost,
+ call : OpenNebula.Cluster.deldatastore,
callback : function (req) {
//Sunstone.runAction("Cluster.show",req.request.data[0]);
},
diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js
new file mode 100644
index 0000000000..603fd6867e
--- /dev/null
+++ b/src/sunstone/public/js/plugins/datastores-tab.js
@@ -0,0 +1,657 @@
+/* -------------------------------------------------------------------------- */
+/* 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. */
+/* -------------------------------------------------------------------------- */
+
+/*Datastore tab plugin*/
+
+
+var datastores_tab_content =
+'';
+
+var create_datastore_tmpl =
+'';
+
+var update_datastore_tmpl =
+ '';
+
+var datastores_select="";
+var dataTable_datastores;
+var $create_datastore_dialog;
+
+//Setup actions
+var datastore_actions = {
+
+ "Datastore.create" : {
+ type: "create",
+ call : OpenNebula.Datastore.create,
+ callback : addDatastoreElement,
+ error : onError,
+ notify: true
+ },
+
+ "Datastore.create_dialog" : {
+ type: "custom",
+ call: popUpCreateDatastoreDialog
+ },
+
+ "Datastore.list" : {
+ type: "list",
+ call: OpenNebula.Datastore.list,
+ callback: updateDatastoresView,
+ error: onError
+ },
+
+ "Datastore.show" : {
+ type: "single",
+ call: OpenNebula.Datastore.show,
+ callback: updateDatastoreElement,
+ error: onError
+ },
+
+ "Datastore.showinfo" : {
+ type: "single",
+ call: OpenNebula.Datastore.show,
+ callback: updateDatastoreInfo,
+ error: onError
+ },
+
+ "Datastore.refresh" : {
+ type: "custom",
+ call: function(){
+ waitingNodes(dataTable_datastores);
+ Sunstone.runAction("Datastore.list");
+ },
+ error: onError
+ },
+
+ "Datastore.fetch_template" : {
+ type: "single",
+ call: OpenNebula.Datastore.fetch_template,
+ callback: function (request,response) {
+ $('#datastore_template_update_dialog #datastore_template_update_textarea').val(response.template);
+ },
+ error: onError
+ },
+
+ "Datastore.fetch_permissions" : {
+ type: "single",
+ call: OpenNebula.Datastore.show,
+ callback: function(request,element_json){
+ var dialog = $('#datastore_template_update_dialog form');
+ var ds = element_json.DATASTORE;
+ setPermissionsTable(ds,dialog);
+ },
+ error: onError
+ },
+
+ "Datastore.update_dialog" : {
+ type: "custom",
+ call: popUpDatastoreTemplateUpdateDialog,
+ },
+
+ "Datastore.update" : {
+ type: "single",
+ call: OpenNebula.Datastore.update,
+ callback: function() {
+ notifyMessage(tr("Datastore updated correctly"));
+ },
+ error: onError
+ },
+
+ "Datastore.autorefresh" : {
+ type: "custom",
+ call : function() {
+ OpenNebula.Datastore.list({timeout: true, success: updateDatastoresView,error: onError});
+ }
+ },
+
+ "Datastore.delete" : {
+ type: "multiple",
+ call : OpenNebula.Datastore.delete,
+ callback : deleteDatastoreElement,
+ elements: datastoreElements,
+ error : onError,
+ notify:true
+ },
+
+ "Datastore.chown" : {
+ type: "multiple",
+ call: OpenNebula.Datastore.chown,
+ callback: function (req) {
+ Sunstone.runAction("Datastore.show",req.request.data[0][0]);
+ },
+ elements: datastoreElements,
+ error: onError,
+ notify: true
+ },
+
+ "Datastore.chgrp" : {
+ type: "multiple",
+ call: OpenNebula.Datastore.chgrp,
+ callback: function (req) {
+ Sunstone.runAction("Datastore.show",req.request.data[0][0]);
+ },
+ elements: datastoreElements,
+ error: onError,
+ notify: true
+ },
+
+ "Datastore.chmod" : {
+ type: "single",
+ call: OpenNebula.Datastore.chmod,
+// callback
+ error: onError,
+ notify: true
+ },
+
+ "Datastore.addtocluster" : {
+ type: "multiple",
+ call: function(params){
+ var cluster = params.data.extra_param;
+ var ds = params.data.id;
+ Sunstone.runAction("Cluster.adddatastore",cluster,ds);
+ },
+ elements: datastoreElements,
+ notify:true,
+ },
+
+};
+
+var datastore_buttons = {
+ "Datastore.refresh" : {
+ type: "image",
+ text: tr("Refresh list"),
+ img: "images/Refresh-icon.png"
+ },
+ "Datastore.create_dialog" : {
+ type: "create_dialog",
+ text: tr("+ New")
+ },
+ "Datastore.update_dialog" : {
+ type: "action",
+ text: tr("Update properties"),
+ alwaysActive: true
+ },
+ "Datastore.addtocluster" : {
+ type: "confirm_with_select",
+ text: tr("Select cluster"),
+ select: clusters_sel,
+ tip: tr("Select the destination cluster:"),
+ },
+ "Datastore.chown" : {
+ type: "confirm_with_select",
+ text: tr("Change owner"),
+ select: users_sel,
+ tip: tr("Select the new owner")+":",
+ condition: mustBeAdmin
+ },
+ "Datastore.chgrp" : {
+ type: "confirm_with_select",
+ text: tr("Change group"),
+ select: groups_sel,
+ tip: tr("Select the new group")+":",
+ condition: mustBeAdmin
+ },
+ "Datastore.delete" : {
+ type: "confirm",
+ text: tr("Delete")
+ }
+}
+
+var datastore_info_panel = {
+ "datastore_info_tab" : {
+ title: tr("Datastore information"),
+ content: ""
+ },
+ "datastore_template_tab" : {
+ title: tr("Datastore template"),
+ content: ""
+ },
+}
+
+var datastores_tab = {
+ title: tr("Datastores"),
+ content: datastores_tab_content,
+ buttons: datastore_buttons
+}
+
+Sunstone.addActions(datastore_actions);
+Sunstone.addMainTab('datastores_tab',datastores_tab);
+Sunstone.addInfoPanel('datastore_info_panel',datastore_info_panel);
+
+
+function datastoreElements() {
+ return getSelectedNodes(dataTable_datastores);
+}
+
+function vmShow(req) {
+ Sunstone.runAction("Datastore.show",req.request.data[0]);
+}
+
+function datastoreElementArray(element_json){
+ var element = element_json.DATASTORE;
+
+ return [
+ ' ',
+ element.ID,
+ element.UNAME,
+ element.GNAME,
+ element.NAME,
+ element.CLUSTER
+ ];
+}
+
+function datastoreInfoListener(){
+
+ $('#tbodydatastores tr',dataTable_datastores).live("click", function(e){
+ if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
+
+ var aData = dataTable_datastores.fnGetData(this);
+ var id = $(aData[0]).val();
+ if (!id) return true;
+
+ popDialogLoading();
+ Sunstone.runAction("Datastore.showinfo",id);
+ return false;
+ });
+}
+
+function updateDatastoreElement(request, element_json){
+ var id = element_json.DATASTORE.ID;
+ var element = datastoreElementArray(element_json);
+ updateSingleElement(element,dataTable_datastores,'#datastore_'+id)
+}
+
+function deleteDatastoreElement(request){
+ deleteElement(dataTable_datastores,'#datastore_'+request.request.data);
+}
+
+function addDatastoreElement(request,element_json){
+ var id = element_json.DATASTORE.ID;
+ var element = datastoreElementArray(element_json);
+ addElement(element,dataTable_datastores);
+}
+
+
+function updateDatastoresView(request, list){
+ var list_array = [];
+
+ $.each(list,function(){
+ list_array.push( datastoreElementArray(this));
+ });
+
+ updateView(list_array,dataTable_datastores);
+ updateDashboard("datastores",list);
+}
+
+
+function updateDatastoreInfo(request,ds){
+ var info = ds.DATASTORE;
+
+ var info_tab = {
+ title : tr("Datastore information"),
+ content:
+ '\
+ \
+ '+tr("Datastore information")+' - '+info.NAME+' \
+ \
+ \
+ \
+ '+tr("ID")+' \
+ '+info.ID+' \
+ \
+ \
+ '+tr("Name")+' \
+ '+info.NAME+' \
+ \
+ \
+ '+tr("Owner")+' \
+ '+info.UNAME+' \
+ \
+ \
+ '+tr("Group")+' \
+ '+info.GNAME+' \
+ \
+ \
+ '+tr("Cluster")+' \
+ '+info.CLUSTER+' \
+ \
+ \
+ '+tr("DS Mad")+' \
+ '+info.DS_MAD+' \
+ \
+ \
+ '+tr("TM Mad")+' \
+ '+ info.TM_MAD +' \
+ \
+ \
+ '+tr("Base path")+' \
+ '+info.BASE_PATH+' \
+ \
+ '+tr("Permissions")+' \
+ \
+ '+tr("Owner")+' \
+ '+ownerPermStr(info)+' \
+ \
+ \
+ '+tr("Group")+' \
+ '+groupPermStr(info)+' \
+ \
+ \
+ '+tr("Other")+' \
+ '+otherPermStr(info)+' \
+ \
+ \
+
'
+ }
+
+ var template_tab = {
+ title: tr("Datastore Template"),
+ content:
+ '\
+ '+tr("Datastore template")+' '+
+ prettyPrintJSON(info.TEMPLATE)+
+ '
'
+ }
+
+ Sunstone.updateInfoPanelTab("datastore_info_panel","datastore_info_tab",info_tab);
+ Sunstone.updateInfoPanelTab("datastore_info_panel","datastore_template_tab",template_tab);
+ Sunstone.popUpInfoPanel("datastore_info_panel");
+}
+
+// Sets up the create-template dialog and all the processing associated to it,
+// which is a lot.
+function setupCreateDatastoreDialog(){
+
+ dialogs_context.append('
');
+ //Insert HTML in place
+ $create_datastore_dialog = $('#create_datastore_dialog')
+ var dialog = $create_datastore_dialog;
+ dialog.html(create_datastore_tmpl);
+
+ //Prepare jquery dialog
+ dialog.dialog({
+ autoOpen: false,
+ modal: true,
+ width: 400
+ });
+
+ $('button',dialog).button();
+ setupTips(dialog);
+
+ $('#create_datastore_form',dialog).submit(function(){
+ var name = $('#name',this).val();
+ var cluster_id = $('#cluster_id',this).val();
+ var ds_mad = $('#ds_mad',this).val();
+ var tm_mad = $('#tm_mad',this).val();
+
+ if (!name){
+ notifyError("Please provide a name");
+ return false;
+ };
+
+ var ds_obj = {
+ "datastore" : {
+ "name" : name,
+ "ds_mad" : ds_mad,
+ "tm_mad" : tm_mad
+ },
+ "cluster_id" : cluster_id
+ };
+
+ Sunstone.runAction("Datastore.create",ds_obj);
+
+ $create_datastore_dialog.dialog('close');
+ return false;
+ });
+}
+
+function popUpCreateDatastoreDialog(){
+ $('select#cluster_id',$create_datastore_dialog).html(clusters_sel());
+ $create_datastore_dialog.dialog('open');
+}
+
+function setupDatastoreTemplateUpdateDialog(){
+ //Append to DOM
+ dialogs_context.append('
');
+ var dialog = $('#datastore_template_update_dialog',dialogs_context);
+
+ //Put HTML in place
+ dialog.html(update_datastore_tmpl);
+
+ var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
+
+ //Convert into jQuery
+ dialog.dialog({
+ autoOpen:false,
+ width:500,
+ modal:true,
+ height:height,
+ resizable:true,
+ });
+
+ $('button',dialog).button();
+
+ $('#datastore_template_update_select',dialog).change(function(){
+ var id = $(this).val();
+ $('.permissions_table input',dialog).removeAttr('checked');
+ $('.permissions_table',dialog).removeAttr('update');
+ if (id && id.length){
+ var dialog = $('#datastore_template_update_dialog');
+ $('#template_template_update_textarea',dialog).val(tr("Loading")+"...");
+ Sunstone.runAction("Datastore.fetch_template",id);
+ Sunstone.runAction("Datastore.fetch_permissions",id);
+ } else {
+ $('#datastore_template_update_textarea',dialog).val("");
+ };
+ });
+
+ $('.permissions_table input',dialog).change(function(){
+ $(this).parents('table').attr('update','update');
+ });
+
+ $('form',dialog).submit(function(){
+ var dialog = $(this);
+ var new_template = $('#datastore_template_update_textarea',dialog).val();
+ var id = $('#datastore_template_update_select',dialog).val();
+ if (!id || !id.length) {
+ $(this).parents('#datastore_template_update_dialog').dialog('close');
+ return false;
+ };
+
+ var permissions = $('.permissions_table',dialog);
+ if (permissions.attr('update')){
+ var perms = {
+ octet : buildOctet(permissions)
+ };
+ Sunstone.runAction("Datastore.chmod",id,perms);
+ };
+
+ Sunstone.runAction("Datastore.update",id,new_template);
+ $(this).parents('#datastore_template_update_dialog').dialog('close');
+ return false;
+ });
+};
+
+function popUpDatastoreTemplateUpdateDialog(){
+ var select = makeSelectOptions(dataTable_datastores,
+ 1,//id_col
+ 4,//name_col
+ [],
+ []
+ );
+ var sel_elems = getSelectedNodes(dataTable_datastores);
+
+
+ var dialog = $('#datastore_template_update_dialog');
+ $('#datastore_template_update_select',dialog).html(select);
+ $('#datastore_template_update_textarea',dialog).val("");
+ $('.permissions_table input',dialog).removeAttr('checked');
+ $('.permissions_table',dialog).removeAttr('update');
+
+ if (sel_elems.length >= 1){ //several items in the list are selected
+ //grep them
+ var new_select= sel_elems.length > 1? 'Please select ' : "";
+ $('option',''+select+' ').each(function(){
+ var val = $(this).val();
+ if ($.inArray(val,sel_elems) >= 0){
+ new_select+=''+$(this).text()+' ';
+ };
+ });
+ $('#datastore_template_update_select',dialog).html(new_select);
+ if (sel_elems.length == 1) {
+ $('#datastore_template_update_select option',dialog).attr('selected','selected');
+ $('#datastore_template_update_select',dialog).trigger("change");
+ };
+ };
+
+ dialog.dialog('open');
+ return false;
+};
+
+//Prepares autorefresh
+function setDatastoreAutorefresh(){
+ setInterval(function(){
+ var checked = $('input.check_item:checked',dataTable_datastores);
+ var filter = $("#datatable_datastores_filter input",
+ dataTable_datastores.parents('#datatable_datastores_wrapper')).attr('value');
+ if (!checked.length && !filter.length){
+ Sunstone.runAction("Datastore.autorefresh");
+ };
+ },INTERVAL+someTime());
+}
+
+
+$(document).ready(function(){
+
+ dataTable_datastores = $("#datatable_datastores",main_tabs_context).dataTable({
+ "bJQueryUI": true,
+ "bSortClasses": false,
+ "sPaginationType": "full_numbers",
+ "bAutoWidth":false,
+ "aoColumnDefs": [
+ { "bSortable": false, "aTargets": ["check"] },
+ { "sWidth": "60px", "aTargets": [0] },
+ { "sWidth": "35px", "aTargets": [1] },
+ { "sWidth": "100px", "aTargets": [2,3,5] }
+ ],
+ "oLanguage": (datatable_lang != "") ?
+ {
+ sUrl: "locale/"+lang+"/"+datatable_lang
+ } : ""
+ });
+
+ dataTable_datastores.fnClearTable();
+ addElement([
+ spinner,
+ '','','','',''],dataTable_datastores);
+ Sunstone.runAction("Datastore.list");
+
+ setupCreateDatastoreDialog();
+ setupDatastoreTemplateUpdateDialog();
+ setDatastoreAutorefresh();
+
+ initCheckAllBoxes(dataTable_datastores);
+ tableCheckboxesListener(dataTable_datastores);
+ datastoreInfoListener();
+})
\ No newline at end of file
diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js
index 2d87e1585f..084434343c 100644
--- a/src/sunstone/public/js/plugins/hosts-tab.js
+++ b/src/sunstone/public/js/plugins/hosts-tab.js
@@ -321,11 +321,6 @@ 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);
@@ -607,7 +602,7 @@ function setupCreateHostDialog(){
//Open creation dialogs
function popUpCreateHostDialog(){
- $('#host_cluster_id',$create_host_dialog).html(clusters_select);
+ $('#host_cluster_id',$create_host_dialog).html(clusters_sel());
$create_host_dialog.dialog('open');
return false;
}
@@ -632,10 +627,6 @@ function hostMonitorError(req,error_json){
$('#host_monitoring_tab '+id).html(''+message+'
');
}
-function hosts_sel() {
- return hosts_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
diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js
index 02e441da56..ad8d818883 100644
--- a/src/sunstone/public/js/plugins/images-tab.js
+++ b/src/sunstone/public/js/plugins/images-tab.js
@@ -28,6 +28,7 @@ var images_tab_content =
'+tr("Owner")+' \
'+tr("Group")+' \
'+tr("Name")+' \
+ '+tr("Datastore")+' \
'+tr("Size")+' \
'+tr("Type")+' \
'+tr("Registration time")+' \
@@ -316,7 +317,7 @@ var image_actions = {
type: "single",
call: OpenNebula.Image.update,
callback: function() {
- notifyMessage(tr("Template updated correctly"));
+ notifyMessage(tr("Image updated correctly"));
},
error: onError
},
@@ -378,7 +379,7 @@ var image_actions = {
type: "multiple",
call: OpenNebula.Image.chown,
callback: function (req) {
- Sunstone.runAction("Image.show",req.request.data[0]);
+ Sunstone.runAction("Image.show",req.request.data[0][0]);
},
elements: imageElements,
error: onError,
@@ -389,7 +390,7 @@ var image_actions = {
type: "multiple",
call: OpenNebula.Image.chgrp,
callback: function (req) {
- Sunstone.runAction("Image.show",req.request.data[0]);
+ Sunstone.runAction("Image.show",req.request.data[0][0]);
},
elements: imageElements,
error: onError,
@@ -522,6 +523,7 @@ function imageElementArray(image_json){
image.UNAME,
image.GNAME,
image.NAME,
+ image.DATASTORE,
image.SIZE,
''+type.html()+' ',
pretty_time(image.REGTIME),
@@ -599,6 +601,10 @@ function updateImageInfo(request,img){
'+tr("Name")+' \
'+img_info.NAME+' \
\
+ \
+ '+tr("Datastore")+' \
+ '+img_info.DATASTORE+' \
+ \
\
'+tr("Owner")+' \
'+img_info.UNAME+' \
@@ -643,7 +649,7 @@ function updateImageInfo(request,img){
'+tr("Running #VMS")+' \
'+img_info.RUNNING_VMS+' \
\
- Permissions \
+ '+tr("Permissions")+' \
\
'+tr("Owner")+' \
'+ownerPermStr(img_info)+' \
@@ -843,6 +849,9 @@ function setupCreateImageDialog(){
}
});
if (exit) { return false; }
+
+ var ds_id = $('#img_ds_id',this).val();
+
var img_json = {};
var name = $('#img_name',this).val();
@@ -897,8 +906,9 @@ function setupCreateImageDialog(){
img_json[attr_name] = attr_value;
});
-
- img_obj = { "image" : img_json };
+ ds_id = 1;
+ img_obj = { "image" : img_json,
+ "ds_id" : ds_id};
if (upload){
uploader._onInputChange(file_input);
@@ -1094,10 +1104,10 @@ $(document).ready(function(){
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
- { "sWidth": "60px", "aTargets": [0,2,3,8,9] },
- { "sWidth": "35px", "aTargets": [1,5,10] },
- { "sWidth": "100px", "aTargets": [6] },
- { "sWidth": "150px", "aTargets": [7] }
+ { "sWidth": "60px", "aTargets": [0,2,3,9,10] },
+ { "sWidth": "35px", "aTargets": [1,6,11] },
+ { "sWidth": "100px", "aTargets": [5,7] },
+ { "sWidth": "150px", "aTargets": [8] }
],
"oLanguage": (datatable_lang != "") ?
{
@@ -1108,7 +1118,7 @@ $(document).ready(function(){
dataTable_images.fnClearTable();
addElement([
spinner,
- '','','','','','','','','',''],dataTable_images);
+ '','','','','','','','','','',''],dataTable_images);
Sunstone.runAction("Image.list");
setupCreateImageDialog();
diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js
index 5375aaf892..f4f1f8a28e 100644
--- a/src/sunstone/public/js/plugins/templates-tab.js
+++ b/src/sunstone/public/js/plugins/templates-tab.js
@@ -599,21 +599,21 @@ var update_template_tmpl =
'+tr("Admin")+' \
\
'+tr("Owner")+' \
- \
- \
- \
+ \
+ \
+ \
\
\
'+tr("Group")+' \
- \
- \
- \
+ \
+ \
+ \
\
\
'+tr("Other")+' \
- \
- \
- \
+ \
+ \
+ \
\
\
\
@@ -624,7 +624,7 @@ var update_template_tmpl =
\
\
\
- Update\
+ '+tr("Update")+'\
\
\
\
@@ -956,7 +956,7 @@ function updateTemplateInfo(request,template){
'+tr("Register time")+' \
'+pretty_time(template_info.REGTIME)+' \
\
- Permissions \
+ '+tr("Permissions")+' \
\
'+tr("Owner")+' \
'+ownerPermStr(template_info)+' \
@@ -2088,7 +2088,6 @@ function setupTemplateTemplateUpdateDialog(){
Sunstone.runAction("Template.update",id,new_template);
$(this).parents('#template_template_update_dialog').dialog('close');
- dialog.dialog('close');
return false;
});
};
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index cfb477c9c7..ae2364a0e6 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -1302,7 +1302,6 @@ $(document).ready(function(){
setupSaveasDialog();
setVMAutorefresh();
setupVNC();
- setupTips
initCheckAllBoxes(dataTable_vMachines);
tableCheckboxesListener(dataTable_vMachines);
diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js
index 3cc3aff2df..b9b63a21b7 100644
--- a/src/sunstone/public/js/plugins/vnets-tab.js
+++ b/src/sunstone/public/js/plugins/vnets-tab.js
@@ -587,7 +587,7 @@ function updateVNetworkInfo(request,vn){
'+tr("VLAN ID")+' \
'+ (typeof(vn_info.VLAN_ID) == "object" ? "--": vn_info.VLAN_ID) +' \
\
- Permissions \
+ '+tr("Permissions")+' \
\
'+tr("Owner")+' \
'+ownerPermStr(vn_info)+' \
diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js
index 24a4cf81ae..02a060b5d3 100644
--- a/src/sunstone/public/js/sunstone-util.js
+++ b/src/sunstone/public/js/sunstone-util.js
@@ -751,6 +751,12 @@ function hosts_sel(){
return hosts_select;
}
+function clusters_sel() {
+ return clusters_select;
+}
+
+
+
function ownerUse(resource){
return parseInt(resource.PERMISSIONS.OWNER_U);
};