diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb index 11c03966ee..99a0bdf04b 100644 --- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb @@ -37,7 +37,7 @@ module OpenNebulaJSON template = template_to_str(image_hash) end - self.allocate(template,ds_id) + self.allocate(template,ds_id.to_i) end def perform_action(template_json) diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index fba385ec96..2739d9b2b4 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -130,9 +130,22 @@ class SunstoneServer < CloudServer ############################################################################ def upload(template, file_path) image_hash = parse_json(template, 'image') + if OpenNebula.is_error?(image_hash) + return [500, image_hash.to_json] + end + image_hash['PATH'] = file_path - new_template = {:image => image_hash}.to_json + ds_id = parse_json(template, 'ds_id') + if OpenNebula.is_error?(ds_id) + return [500, ds_id.to_json] + end + + new_template = { + :image => image_hash, + :ds_id => ds_id, + }.to_json + image = ImageJSON.new(Image.build_xml, @client) rc = image.create(new_template) diff --git a/src/sunstone/public/js/plugins/dashboard-tab.js b/src/sunstone/public/js/plugins/dashboard-tab.js index 362c51e347..06b931244b 100644 --- a/src/sunstone/public/js/plugins/dashboard-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-tab.js @@ -58,6 +58,10 @@ var dashboard_tab_content = ' + tr("Hosts (total/active)") + '\ \ \ + \ + ' + tr("Clusters") + '\ + \ + \ \ ' + tr("Groups") + '\ \ @@ -78,6 +82,10 @@ var dashboard_tab_content = ' + tr("Virtual Networks (total/public)") + '\ \ \ + \ + ' + tr("Datastores") + '\ + \ + \ \ ' + tr("Images (total/public)") + '\ \ @@ -102,11 +110,13 @@ var dashboard_tab_content =

' + tr("Quickstart") + '

\
\ \ \ \ + \ + \ + \ + \ \ \ \ @@ -85,7 +89,7 @@ var dashboard_tab_content =

'+tr("Quickstart")+'

\
\
\ -\ +\ ' + tr("Host") + '
\ + ' + tr("Cluster") + '
\ ' + tr("VM Instance") + '
\ ' + tr("VM Template") + '
\ - ' + tr("Virtual Network") + '
\ + ' + tr("Virtual Network") + '
\ + ' + tr("Datastore") + '
\ ' + tr("Image") + '
\ ' + tr("User") + '
\ ' + tr("Group") + '
\ @@ -316,5 +326,13 @@ function updateDashboard(what,json_info){ var total_acls=json_info.length; $('#total_acls',db).html(total_acls); break; + case "clusters": + var total_clusters=json_info.length; + $('#total_clusters',db).html(total_clusters); + break; + case "datastores": + var total_datastores=json_info.length; + $('#total_datastores',db).html(total_datastores); + break; } } diff --git a/src/sunstone/public/js/plugins/dashboard-users-tab.js b/src/sunstone/public/js/plugins/dashboard-users-tab.js index 4e602814be..f27ed855fb 100644 --- a/src/sunstone/public/js/plugins/dashboard-users-tab.js +++ b/src/sunstone/public/js/plugins/dashboard-users-tab.js @@ -69,6 +69,10 @@ var dashboard_tab_content =
'+tr("Virtual Networks (total/public)")+'
' + tr("Datastores") + '
'+tr("Images (total/public)")+'
\ - \ + \ '+tr("VM Template")+'
\ '+tr("VM Instance")+'
\ '+tr("Virtual Network")+'
\ @@ -296,5 +300,13 @@ function updateDashboard(what,json_info){ var total_acls=json_info.length; $('#total_acls',db).html(total_acls); break; + case "clusters": + var total_clusters=json_info.length; + $('#total_clusters',db).html(total_clusters); + break; + case "datastores": + var total_datastores=json_info.length; + $('#total_datastores',db).html(total_datastores); + break; } } \ No newline at end of file diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index 603fd6867e..88afb16aab 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -265,7 +265,8 @@ var datastore_buttons = { }, "Datastore.create_dialog" : { type: "create_dialog", - text: tr("+ New") + text: tr("+ New"), + condition: mustBeAdmin, }, "Datastore.update_dialog" : { type: "action", @@ -277,6 +278,7 @@ var datastore_buttons = { text: tr("Select cluster"), select: clusters_sel, tip: tr("Select the destination cluster:"), + condition: mustBeAdmin, }, "Datastore.chown" : { type: "confirm_with_select", @@ -354,22 +356,34 @@ function datastoreInfoListener(){ Sunstone.runAction("Datastore.showinfo",id); return false; }); -} +}; + +function updateDatastoreSelect(){ + datastores_select = makeSelectOptions(dataTable_datastores, + 1, + 4, + [], + [] + ); +}; function updateDatastoreElement(request, element_json){ var id = element_json.DATASTORE.ID; var element = datastoreElementArray(element_json); updateSingleElement(element,dataTable_datastores,'#datastore_'+id) + updateDatastoreSelect(); } function deleteDatastoreElement(request){ deleteElement(dataTable_datastores,'#datastore_'+request.request.data); + updateDatastoreSelect(); } function addDatastoreElement(request,element_json){ var id = element_json.DATASTORE.ID; var element = datastoreElementArray(element_json); addElement(element,dataTable_datastores); + updateDatastoreSelect(); } @@ -381,17 +395,28 @@ function updateDatastoresView(request, list){ }); updateView(list_array,dataTable_datastores); + updateDatastoreSelect(); updateDashboard("datastores",list); } function updateDatastoreInfo(request,ds){ var info = ds.DATASTORE; + var images_str = ""; + if (info.IMAGES.ID && + info.IMAGES.ID.constructor == Array){ + for (var i=0; i\ + '\ \ \ \ @@ -428,6 +453,10 @@ function updateDatastoreInfo(request,ds){ \ \ \ + \ + \ + \ + \ \ \ \ diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index ad8d818883..ca5dd57182 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -63,6 +63,12 @@ var create_image_tmpl = \
'+tr("Human readable description of the image for other users.")+'
\ \ +
\ + \ + \ +
'+tr("Select the datastore for this image")+'
\ +
\ \
\
\ @@ -850,7 +856,11 @@ function setupCreateImageDialog(){ }); if (exit) { return false; } - var ds_id = $('#img_ds_id',this).val(); + var ds_id = $('#img_datastore',this).val(); + if (!ds_id){ + notifyError(tr("Please select a datastore for this image")); + return false; + }; var img_json = {}; @@ -906,7 +916,6 @@ function setupCreateImageDialog(){ img_json[attr_name] = attr_value; }); - ds_id = 1; img_obj = { "image" : img_json, "ds_id" : ds_id}; @@ -932,6 +941,8 @@ function popUpCreateImageDialog(){ $('#file-uploader input',$create_image_dialog).removeAttr("style"); $('#file-uploader input',$create_image_dialog).attr('style','margin:0;width:256px!important'); + $('#img_datastore',$create_image_dialog).html(datastores_sel()); + $create_image_dialog.dialog('open'); } diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index b9b63a21b7..f1865b92dc 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -419,6 +419,7 @@ var vnet_buttons = { text: tr("Select cluster"), select: clusters_sel, tip: tr("Select the destination cluster:"), + condition: mustBeAdmin, }, "Network.chown" : { type: "confirm_with_select", diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 02a060b5d3..4b16656250 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -403,19 +403,26 @@ function waitingNodes(dataTable){ function getUserName(uid){ if (typeof(dataTable_users) != "undefined"){ - return getName(uid,dataTable_users); + return getName(uid,dataTable_users,2); } return uid; } function getGroupName(gid){ if (typeof(dataTable_groups) != "undefined"){ - return getName(gid,dataTable_groups); + return getName(gid,dataTable_groups,2); } return gid; } -function getName(id,dataTable){ +function getImageName(id){ + if (typeof(dataTable_images) != "undefined"){ + return getName(id,dataTable_images,4); + } + return id; +}; + +function getName(id,dataTable,name_col){ var name = id; if (typeof(dataTable) == "undefined") { return name; @@ -424,7 +431,7 @@ function getName(id,dataTable){ $.each(nodes,function(){ if (id == this[1]) { - name = this[2]; + name = this[name_col]; return false; } }); @@ -755,6 +762,10 @@ function clusters_sel() { return clusters_select; } +function datastores_sel() { + return datastores_select; +} + function ownerUse(resource){
'+tr("Datastore information")+' - '+info.NAME+'
'+tr("Base path")+''+info.BASE_PATH+'
'+tr("Images")+''+images_str+'
'+tr("Permissions")+'
     '+tr("Owner")+'