From a331ac31fa157f65589b91ff52efcc7b7c553246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 12 Jan 2012 12:31:20 +0100 Subject: [PATCH 01/12] Revert "Feature #862: Remove USER:ADMIN right to VDC Admins", since commit:f1478e68 oneuser delete requires ADMIN rights This reverts commit 0c2750de4832d5966a2e0fbd16c994a9ddd31311. --- src/ozones/Server/lib/OZones/VDC.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ozones/Server/lib/OZones/VDC.rb b/src/ozones/Server/lib/OZones/VDC.rb index 3650ff63eb..0ce45e38fe 100644 --- a/src/ozones/Server/lib/OZones/VDC.rb +++ b/src/ozones/Server/lib/OZones/VDC.rb @@ -233,7 +233,8 @@ module OZones # Grant permissions to the vdc admin rule_str << "##{@vdc.VDCADMIN_ID} USER/* CREATE" - rule_str << "##{@vdc.VDCADMIN_ID} USER/@#{@vdc.GROUP_ID} USE+MANAGE" + rule_str << "##{@vdc.VDCADMIN_ID} USER/@#{@vdc.GROUP_ID} " \ + "USE+MANAGE+ADMIN" ############################################################### #When more rules are added the class constant HOST_ACL_FIRST_ID From 91b49a7fd57d1a28f8f0a8bba56d00d37754b25d Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Thu, 12 Jan 2012 17:16:25 +0100 Subject: [PATCH 02/12] Define public method in OCA --- src/cloud/occi/lib/ImageOCCI.rb | 10 ++-------- src/cloud/occi/lib/VirtualNetworkOCCI.rb | 2 +- src/cloud/occi/lib/occi-server.rb | 6 +----- src/oca/ruby/OpenNebula/Image.rb | 8 ++++++++ src/oca/ruby/OpenNebula/Template.rb | 8 ++++++++ src/oca/ruby/OpenNebula/VirtualNetwork.rb | 8 ++++++++ 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/cloud/occi/lib/ImageOCCI.rb b/src/cloud/occi/lib/ImageOCCI.rb index 1a9a9c6bb7..b49e7b91d2 100755 --- a/src/cloud/occi/lib/ImageOCCI.rb +++ b/src/cloud/occi/lib/ImageOCCI.rb @@ -24,7 +24,7 @@ class ImageOCCI < Image <%= self.id.to_s %> <%= self.name %> <% if self['TYPE'] != nil %> - <%= self['TYPE'] %> + <%= self.type_str %> <% end %> <% if self['TEMPLATE/DESCRIPTION'] != nil %> <%= self['TEMPLATE/DESCRIPTION'] %> @@ -33,7 +33,7 @@ class ImageOCCI < Image <% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %> <%= self['FSTYPE'] %> <% end %> - <%= pub %> + <%= self.public? ? "YES" : "NO" %> <%= self['PERSISTENT'] == "0" ? "NO" : "YES"%> } @@ -82,12 +82,6 @@ class ImageOCCI < Image # Creates the OCCI representation of an Image def to_occi(base_url) - if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" - pub = "YES" - else - pub = "NO" - end - begin occi_im = ERB.new(OCCI_IMAGE) occi_im_text = occi_im.result(binding) diff --git a/src/cloud/occi/lib/VirtualNetworkOCCI.rb b/src/cloud/occi/lib/VirtualNetworkOCCI.rb index 6a5e3fe63b..677af015af 100755 --- a/src/cloud/occi/lib/VirtualNetworkOCCI.rb +++ b/src/cloud/occi/lib/VirtualNetworkOCCI.rb @@ -34,7 +34,7 @@ class VirtualNetworkOCCI < VirtualNetwork <%= network_size %> <% end %> <%= self['TOTAL_LEASES'] %> - <%= pub %> + <%= self.public? ? "YES" : "NO" %> } diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 3c184f73be..dbf1fda8bc 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -255,11 +255,7 @@ end ################################################### get '/compute/:id' do - if params[:id] == "types" - result,rc = @occi_server.get_computes_types - else - result,rc = @occi_server.get_compute(request, params) - end + result,rc = @occi_server.get_compute(request, params) treat_response(result,rc) end diff --git a/src/oca/ruby/OpenNebula/Image.rb b/src/oca/ruby/OpenNebula/Image.rb index fbd5082edb..619df8d005 100644 --- a/src/oca/ruby/OpenNebula/Image.rb +++ b/src/oca/ruby/OpenNebula/Image.rb @@ -219,6 +219,14 @@ module OpenNebula self['GID'].to_i end + def public? + if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" + true + else + false + end + end + private def set_enabled(enabled) diff --git a/src/oca/ruby/OpenNebula/Template.rb b/src/oca/ruby/OpenNebula/Template.rb index 825e1b3c21..03fbef994b 100644 --- a/src/oca/ruby/OpenNebula/Template.rb +++ b/src/oca/ruby/OpenNebula/Template.rb @@ -154,6 +154,14 @@ module OpenNebula self['UID'].to_i end + def public? + if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" + true + else + false + end + end + private def set_publish(published) diff --git a/src/oca/ruby/OpenNebula/VirtualNetwork.rb b/src/oca/ruby/OpenNebula/VirtualNetwork.rb index 1dc568e0ce..70bd2b325f 100644 --- a/src/oca/ruby/OpenNebula/VirtualNetwork.rb +++ b/src/oca/ruby/OpenNebula/VirtualNetwork.rb @@ -210,6 +210,14 @@ module OpenNebula SHORT_VN_TYPES[type_str] end + def public? + if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" + true + else + false + end + end + private def set_publish(published) group_u = published ? 1 : 0 From 95722c75ff32703f5add50bcd2c9b6ad4403e006 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 12 Jan 2012 17:28:46 +0100 Subject: [PATCH 03/12] Bug: Fixes update for resources --- src/cli/one_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index c61828e527..3bfda3e948 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -385,6 +385,13 @@ EOT tmp = Tempfile.new(id.to_s) path = tmp.path + rc = resource.info + + if OpenNebula.is_error?(rc) + puts rc.message + exit -1 + end + tmp << resource.template_str tmp.flush From 7e1653044f05a11c5091861381c745ef4fa38a24 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 13:31:45 +0100 Subject: [PATCH 04/12] Sunstone: require confirmation when deleting --- src/sunstone/public/js/plugins/acls-tab.js | 2 +- src/sunstone/public/js/plugins/groups-tab.js | 2 +- src/sunstone/public/js/plugins/hosts-tab.js | 2 +- src/sunstone/public/js/plugins/images-tab.js | 2 +- src/sunstone/public/js/plugins/templates-tab.js | 2 +- src/sunstone/public/js/plugins/users-tab.js | 2 +- src/sunstone/public/js/plugins/vnets-tab.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js index b2d43d8e14..9216424a7b 100644 --- a/src/sunstone/public/js/plugins/acls-tab.js +++ b/src/sunstone/public/js/plugins/acls-tab.js @@ -146,7 +146,7 @@ var acl_buttons = { text: tr("+ New") }, "Acl.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } } diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 4dd340989d..981ed8f3c7 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -134,7 +134,7 @@ var group_buttons = { // }, "Group.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } }; diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 2dabdd259d..8575bc28d0 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -273,7 +273,7 @@ var host_buttons = { text: tr("Disable") }, "Host.delete" : { - type: "action", + type: "confirm", text: tr("Delete host") } }; diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 97a60cdffe..241c32e319 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -456,7 +456,7 @@ var image_buttons = { } }, "Image.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } } diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index a097134703..029147b424 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -815,7 +815,7 @@ var template_buttons = { } }, "Template.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } } diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index a8d6a73166..fbd1e2a8fa 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -282,7 +282,7 @@ var user_buttons = { // condition: True // }, "User.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } } diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 16c692c211..fedd19fa6d 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -401,7 +401,7 @@ var vnet_buttons = { }, "Network.delete" : { - type: "action", + type: "confirm", text: tr("Delete") } } From b329de02da87cc6dacdb2fa43b09b3db0c53c284 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 16:31:14 +0100 Subject: [PATCH 05/12] SelfService: Improve file upload so it doesn't eat up RAM. --- src/cloud/occi/lib/occi-server.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index e1e1df568d..cfadd287a2 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -50,6 +50,7 @@ require 'sinatra' require 'yaml' require 'erb' require 'tempfile' +require 'fileutils' require 'json' require 'OCCIServer' @@ -349,9 +350,8 @@ end post '/ui/upload' do file = Tempfile.new('uploaded_image') + FileUtils.cp(request.env['rack.input'].path,file.path) request.params['file'] = file.path #so we can re-use occi post_storage() - file.write(request.env['rack.input'].read) - #file.close # this would allow that file is garbage-collected result,rc = @occi_server.post_storage(request) treat_response(result,rc) end From 1485b71826f1d547b99623470c1babe5a0f50c5d Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 16:31:58 +0100 Subject: [PATCH 06/12] Restore refresh time inverval (cherry picked from commit 33763c38c938e5af60455f2995470ca9d7fa53a3) --- src/sunstone/public/js/sunstone-util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 97d0ba493e..b09f67013d 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -16,7 +16,7 @@ /* Some useful functions for Sunstone default plugins */ -var INTERVAL=300000; //milisecs +var INTERVAL=60000; //milisecs function someTime(){ return Math.floor(Math.random()*30000); From 4e6071ee98d367c90adf347b91fb783cb027b13e Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 16:39:28 +0100 Subject: [PATCH 07/12] SelfSerice: Do not open info panels on empty list click. (cherry picked from commit 60b8e15ee9a28eabcdfaf00d4cb23d34e4a7a339) --- src/cloud/occi/lib/ui/public/js/plugins/compute.js | 5 ++++- src/cloud/occi/lib/ui/public/js/plugins/network.js | 7 +++++-- src/cloud/occi/lib/ui/public/js/plugins/storage.js | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index b321b8cbe7..fb64497c31 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -427,9 +427,12 @@ function vMachineInfoListener(){ $('#tbodyvmachines tr',dataTable_vMachines).live("click", function(e){ if ($(e.target).is('input') || $(e.target).is('a img')) {return true;} - popDialogLoading(); + var aData = dataTable_vMachines.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("VM.showinfo",id); return false; }); diff --git a/src/cloud/occi/lib/ui/public/js/plugins/network.js b/src/cloud/occi/lib/ui/public/js/plugins/network.js index 52c82ae58a..436b040939 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/network.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/network.js @@ -237,10 +237,13 @@ function vNetworkElementArray(vn_json){ function vNetworkInfoListener(){ $('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){ - if ($(e.target).is('input')) {return true;} - popDialogLoading(); + if ($(e.target).is('input')) {return true;}; + var aData = dataTable_vNetworks.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Network.showinfo",id); return false; }); diff --git a/src/cloud/occi/lib/ui/public/js/plugins/storage.js b/src/cloud/occi/lib/ui/public/js/plugins/storage.js index 06d719a44f..d6fbfe10d9 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/storage.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/storage.js @@ -308,9 +308,11 @@ function imageInfoListener(){ if (target.is('input') || target.is('select') || target.is('option')) return true; - popDialogLoading(); var aData = dataTable_images.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Image.showinfo",id); return false; }); From b8bb3b74c2a9d0af85e9180416bbc0e7d2928309 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 16:43:56 +0100 Subject: [PATCH 08/12] Sunstone: do not open info tabs when clicking on empty tables (cherry picked from commit 0b0d0d1166d1e7398ec9c19222c1c6a6781a8d91) --- src/sunstone/public/js/plugins/hosts-tab.js | 5 ++++- src/sunstone/public/js/plugins/images-tab.js | 4 +++- src/sunstone/public/js/plugins/templates-tab.js | 5 ++++- src/sunstone/public/js/plugins/vms-tab.js | 5 ++++- src/sunstone/public/js/plugins/vnets-tab.js | 5 ++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 8575bc28d0..77db99cb93 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -369,9 +369,12 @@ 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;} - popDialogLoading(); + var aData = dataTable_hosts.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Host.showinfo",id); return false; }); diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 241c32e319..62ab9f159c 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -528,9 +528,11 @@ function imageInfoListener(){ if (target.is('input') || target.is('select') || target.is('option')) return true; - popDialogLoading(); var aData = dataTable_images.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Image.showinfo",id); return false; }); diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 029147b424..f838bd1495 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -865,9 +865,12 @@ function templateElementArray(template_json){ function templateInfoListener(){ $('#tbodytemplates tr',dataTable_templates).live("click",function(e){ if ($(e.target).is('input')) {return true;} - popDialogLoading(); + var aData = dataTable_templates.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Template.showinfo",id); return false; }); diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index ccd2698a9c..43c71961be 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -651,9 +651,12 @@ function vMachineInfoListener(){ $('#tbodyvmachines tr',dataTable_vMachines).live("click", function(e){ if ($(e.target).is('input') || $(e.target).is('a img')) {return true;} - popDialogLoading(); + var aData = dataTable_vMachines.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("VM.showinfo",id); return false; }); diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index fedd19fa6d..66856161ce 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -457,9 +457,12 @@ function vNetworkInfoListener(){ $('#tbodyvnetworks tr',dataTable_vNetworks).live("click", function(e){ if ($(e.target).is('input')) {return true;} - popDialogLoading(); + var aData = dataTable_vNetworks.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Network.showinfo",id); return false; }); From 52cd5673cb21edc8eace9dc06eebe2314ffcc1e7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 12 Jan 2012 16:45:56 +0100 Subject: [PATCH 09/12] oZones: do not open info tab when clicking on empty tables (cherry picked from commit 7010b29b8f3ce73c791d5a6965fca70f5aed0ce9) --- src/ozones/Server/public/js/plugins/vdcs-tab.js | 7 +++++-- src/ozones/Server/public/js/plugins/zones-tab.js | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ozones/Server/public/js/plugins/vdcs-tab.js b/src/ozones/Server/public/js/plugins/vdcs-tab.js index 88685d81f7..902744f212 100644 --- a/src/ozones/Server/public/js/plugins/vdcs-tab.js +++ b/src/ozones/Server/public/js/plugins/vdcs-tab.js @@ -234,11 +234,14 @@ function vdcElementArray(vdc_json){ } function vdcInfoListener() { - $("#tbodyvdcs tr").live("click", function(e){ + $("#tbodyvdcs tr").live("click", function(e){ if ($(e.target).is('input')) {return true;} - popDialogLoading(); + var aData = dataTable_vdcs.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("VDC.showinfo",id); return false; }); diff --git a/src/ozones/Server/public/js/plugins/zones-tab.js b/src/ozones/Server/public/js/plugins/zones-tab.js index c1c8e76213..d8ea22a55a 100644 --- a/src/ozones/Server/public/js/plugins/zones-tab.js +++ b/src/ozones/Server/public/js/plugins/zones-tab.js @@ -244,9 +244,12 @@ function zoneElementArray(zone_json){ function zoneInfoListener(){ $("#tbodyzones tr").live("click", function(e){ if ($(e.target).is('input')) {return true;} - popDialogLoading(); + var aData = dataTable_zones.fnGetData(this); var id = $(aData[0]).val(); + if (!id) return true; + + popDialogLoading(); Sunstone.runAction("Zone.showinfo",id); return false; }); From b49e56a259a3ff011d7d826a5aa900f63c0beb95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 12 Jan 2012 17:44:08 +0100 Subject: [PATCH 10/12] Feature #862: Fix quotas, the Template contents are retrieved from the core --- src/authm_mad/remotes/quota/authorize | 8 +++++++- src/authm_mad/remotes/quota/quota.rb | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/authm_mad/remotes/quota/authorize b/src/authm_mad/remotes/quota/authorize index 19e7c15909..ae5916b4c0 100755 --- a/src/authm_mad/remotes/quota/authorize +++ b/src/authm_mad/remotes/quota/authorize @@ -50,7 +50,13 @@ quota = Quota.new #OpenNebula.log_debug("quotas: #{quota.get(1)}") ARGV.each {|request| - rc = quota.authorize(user_id, request) + obj, template_or_id, op, owner, acl_eval = request.split(':') + + if ( obj == "TEMPLATE" && op == "USE" && ARGV.size == 1 ) + rc = false + else + rc = quota.authorize(user_id, request) + end if rc OpenNebula.error_message rc diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index f230f16000..c86854526e 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -219,10 +219,20 @@ class Quota # Check if this op needs to check the quota return false unless with_quota?(obj, op) - # If the object is a template the info should be retrived from the - # VM pool. - obj = "VM" if obj == "TEMPLATE" - template = Base64::decode64(template_or_id) + template = "" + + if ( obj == "TEMPLATE" ) + obj = "VM" + + vm_template = OpenNebula::Template.new_with_id(template_or_id, @client) + vm_template.info + + vm_template.each("TEMPLATE") { |xml_elem| + template = xml_elem.to_xml + } + else + template = Base64::decode64(template_or_id) + end check_quotas(user_id.to_i, obj, template) end @@ -267,7 +277,7 @@ class Quota def with_quota?(obj, op) return (obj == "VM" && op == "CREATE") || (obj == "IMAGE" && op == "CREATE") || - (obj == "TEMPLATE" && op == "INSTANTIATE") + (obj == "TEMPLATE" && op == "USE") end ########################################################################### From c6ec7b4cd66deb0fa0ab1e72cf9368edab38cf54 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 12 Jan 2012 18:27:37 +0100 Subject: [PATCH 11/12] Remove unneeded logging in VMware driver --- src/vmm_mad/remotes/vmware/vmware_driver.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vmm_mad/remotes/vmware/vmware_driver.rb b/src/vmm_mad/remotes/vmware/vmware_driver.rb index a0c8b539bf..570b7b0b81 100644 --- a/src/vmm_mad/remotes/vmware/vmware_driver.rb +++ b/src/vmm_mad/remotes/vmware/vmware_driver.rb @@ -252,14 +252,14 @@ class VMwareDriver end #Performs a action usgin libvirt - def do_action(cmd) + def do_action(cmd, log=true) rc = LocalCommand.run(esx_cmd(cmd)) if rc.code == 0 return [true, rc.stdout] else err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}" - OpenNebula.log_error(err) + OpenNebula.log_error(err) if log return [false, rc.code] end end @@ -299,7 +299,7 @@ class VMwareDriver end def domain_defined?(one_id) - rc, info = do_action("virsh -c #{@uri} dominfo one-#{one_id}") + rc, info = do_action("virsh -c #{@uri} dominfo one-#{one_id}", false) return rc end From 524eff7897040239969c4711458ef0f7952789a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 12 Jan 2012 18:29:46 +0100 Subject: [PATCH 12/12] Add reboot action to states documentation --- share/doc/states/states-complete.dot | 3 +++ share/doc/states/states-simple.dot | 3 +++ 2 files changed, 6 insertions(+) diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 9937c7a306..07d9baeb61 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -81,6 +81,9 @@ digraph OpenNebula { unknown -> boot [label="restart"]; boot -> boot [label="restart"]; +# reboot + running -> running [label="reboot"]; + # resubmit "ANY \\ {suspended,done}" -> pending [label="resubmit"]; diff --git a/share/doc/states/states-simple.dot b/share/doc/states/states-simple.dot index 21d37fb8b9..00b74e7d6b 100644 --- a/share/doc/states/states-simple.dot +++ b/share/doc/states/states-simple.dot @@ -75,6 +75,9 @@ digraph OpenNebula { unknown -> boot [label="restart"]; boot -> boot [label="restart"]; +# reboot + running -> running [label="reboot"]; + # resubmit "ANY \\ {suspended,done}" -> pending [label="resubmit"];