You are right, the code I sent will not work, in the repo you can find the correct commit.
http://dev.opennebula.org/projects/opennebula/repository/revisions/master/entry/src/authm_mad/remotes/quota/quota.rb#L292 On 22 December 2011 20:03, Hutson Betts <[email protected]> wrote: > Daniel, > > This is a late reply, but I wanted to point out that the patch you > provided is slightly wrong. I believe it should be: > > --- a/src/authm_mad/remotes/quota/quota.rb > +++ b/src/authm_mad/remotes/quota/quota.rb > @@ -241,10 +241,10 @@ class Quota > resources.each{ |res| > pool = get_pool(res, user_id) > base_xpath = "/#{res}_POOL/#{resource}" > Quota.const_get("#{res}_USAGE".to_sym).each { |key, > params| > + usage[key] ||= 0 > pool.each_xpath("#{base_xpath}/#{params[:xpath]}") { > |elem| > if elem > - usage[key] ||= 0 > if params[:count] > usage[key] += 1 > else > > With the other patch, the key variable was never defined, since it was > defined in the next line. Therefore, the following error would occur: > > Thu Dec 22 12:55:12 2011 [AuM][I]: Command execution > fail: /var/lib/one/remotes/auth/quota/authorize 1 VM:PFRFTVBMQVRFPjxDUFU > +PCFbQ0RBVEFbMV1dPjwvQ1BVPjxESV$ > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I > 22 /usr/lib/one/ruby/quota.rb:244:in `get_usage': undefined local > variable or method `key' for #<Quota:0x7faee1fc02a0> (NameError) > > Thu Dec 22 12:55:12 2011 [AuM][I]: /usr/lib/one/ruby/quota.rb:244:in > `get_usage': undefined local variable or method `key' for > #<Quota:0x7faee1fc02a0> (Name$ > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /usr/lib/one/ruby/quota.rb:241:in `each' > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /usr/lib/one/ruby/quota.rb:241:in `each' > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /usr/lib/one/ruby/quota.rb:241:in `get_usage' > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /usr/lib/one/ruby/quota.rb:241:in `get_usage' > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /usr/lib/one/ruby/quota.rb:189:in `check_quotas' > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /usr/lib/one/ruby/quota.rb:189:in `check_quotas' > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /usr/lib/one/ruby/quota.rb:184:in `authorize' > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /usr/lib/one/ruby/quota.rb:184:in `authorize' > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /var/lib/one/remotes/auth/quota/authorize:53 > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /var/lib/one/remotes/auth/quota/authorize:53 > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /var/lib/one/remotes/auth/quota/authorize:52:in `each' > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /var/lib/one/remotes/auth/quota/authorize:52:in `each' > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 > from /var/lib/one/remotes/auth/quota/authorize:52 > > Thu Dec 22 12:55:12 2011 [AuM][I]: > from /var/lib/one/remotes/auth/quota/authorize:52 > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: LOG I 22 ExitCode: > 1 > > Thu Dec 22 12:55:12 2011 [AuM][I]: ExitCode: 1 > Thu Dec 22 12:55:12 2011 [AuM][D]: Message received: AUTHORIZE FAILURE > 22 - > > Thu Dec 22 12:55:12 2011 [AuM][E]: Auth Error: > Thu Dec 22 12:55:12 2011 [ReM][E]: [VirtualMachineAllocate] User [1] not > authorized to perform action on virtual machine. > > However, after using the change I made, I was able to get it working. > > oneadmin@opennebula-server:~$ occi-compute --username [USER] --password > [PASSWORD] --url https://localhost/occi --debug create test.vm > /var/lib/gems/1.8/gems/curb-0.7.16/lib/curb_core.so: warning: already > initialized constant CURL_SSLVERSION_DEFAULT > <COMPUTE href='[ADDRESS]/compute/21'> > <ID>21</ID> > <CPU>1</CPU> > <MEMORY>1024</MEMORY> > <NAME>one-21</NAME> > <INSTANCE_TYPE>small</INSTANCE_TYPE> > <STATE>PENDING</STATE> > <DISK id='0'> > <STORAGE href='[ADDRESS]/storage/1' name='Machine A'/> > <TYPE>DISK</TYPE> > <TARGET>hda</TARGET> > </DISK> > <NIC> > <NETWORK href='[ADDRESS]/network/10' name='test-2'/> > <IP>192.168.0.1</IP> > <MAC>02:00:c0:a8:00:01</MAC> > </NIC> > </COMPUTE> > > oneadmin@opennebula-server:~$ onevm list all > ID USER GROUP NAME STAT CPU MEM HOSTNAME > TIME > 21 [USER] users one-21 runn 94 1024M 10.1.0.101 > 00 00:02:33 > > > -- > Hutson Betts > Computer Science and Engineering > Texas A&M University > > > On Fri, 2011-12-16 at 17:51 +0100, Daniel Molina wrote: > > Dear Hutson, > > > > I suppose that you are using OpenNebula 3.0. That bug was fixed in the > > master branch for the next release. This bug appears when the VM pool > > is empty or no CPU is defined in the VMS. You can fix it applying the > > following patch: > > > > diff --git a/src/authm_mad/remotes/quota/quota.rb > > b/src/authm_mad/remotes/quota/quota.rb > > index 1f13234..26336bb 100644 > > --- a/src/authm_mad/remotes/quota/quota.rb > > +++ b/src/authm_mad/remotes/quota/quota.rb > > @@ -241,10 +241,10 @@ class Quota > > resources.each{ |res| > > pool = get_pool(res, user_id) > > base_xpath = "/#{res}_POOL/#{resource}" > > + usage[key] ||= 0 > > Quota.const_get("#{res}_USAGE".to_sym).each { |key, > params| > > pool.each_xpath("#{base_xpath}/#{params[:xpath]}") > { |elem| > > if elem > > - usage[key] ||= 0 > > if params[:count] > > usage[key] += 1 > > else > > > > > > Kind regards. > > > > On 15 December 2011 18:45, Hutson Betts <[email protected]> wrote: > > > I'm currently facing a similar issue when attempting to instantiate a > VM > > > using occi-compute. The error: > > > > > > oneadmin@opennebula-server:~$ occi-compute --username [USER] > --password > > > [PASSWORD] --url https://localhost/occi --debug create test.vm > > > /var/lib/gems/1.8/gems/curb-0.7.16/lib/curb_core.so: warning: already > > > initialized constant CURL_SSLVERSION_DEFAULT > > > [VirtualMachineAllocate] User [1] not authorized to perform action on > > > virtual machine. > > > > > > oneadmin@opennebula-server:~$ onevm list all > > > ID USER GROUP NAME STAT CPU MEM HOSTNAME > > > TIME > > > > > > oneadmin@opennebula-server:~$ onevnet list all > > > one ID USER GROUP NAME TYPE BRIDGE PUB LEASES > > > 6 [USER] users firewall-extern R br2 No 0 > > > > > > oneadmin@opennebula-server:~$ oneimage list all > > > ID USER GROUP NAME SIZE TYPE REGTIME PUB > > > PER STAT RVMS > > > 1 [USER] users Machine A 1015M OS 12/11 17:50:01 No > > > No rdy 0 > > > 2 [USER] users Machine B 976M OS 12/11 17:51:27 No > > > No rdy 0 > > > 3 [USER] users Machine C 993M OS 12/11 18:00:40 No > > > No rdy 0 > > > > > > Output From oned.log: > > > > > > Thu Dec 15 11:43:25 2011 [ACL][D]: Request #1 VM/* CREATE > > > Thu Dec 15 11:43:25 2011 [ACL][D]: > Rule @1 VM+NET+IMAGE+TEMPLATE/* > > > CREATE+INFO_POOL_MINE > > > Thu Dec 15 11:43:25 2011 [ACL][D]: Permission granted > > > Thu Dec 15 11:43:26 2011 [ReM][D]: VirtualMachinePoolInfo method > invoked > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 12 ExitCode: > > > 0 > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: ExitCode: 0 > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: AUTHENTICATE > > > SUCCESS 12 - > > > > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 Command > > > execution fail: /var/lib/one/remotes/auth/quota/authorize 1 > > > VM:PFRFTVBMQVRFPjxDUFU+PCF$ > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: Command execution > > > fail: /var/lib/one/remotes/auth/quota/authorize 1 > VM:PFRFTVBMQVRFPjxDUFU > > > +PCFbQ0RBVEFbMV1dPjwvQ1BVPjxESV$ > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I > > > 11 /usr/lib/one/ruby/quota.rb:199:in `Float': can't convert nil into > > > Float (TypeError) > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: /usr/lib/one/ruby/quota.rb:199:in > > > `Float': can't convert nil into Float (TypeError) > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /usr/lib/one/ruby/quota.rb:199:in `send' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /usr/lib/one/ruby/quota.rb:199:in `send' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /usr/lib/one/ruby/quota.rb:199:in `check_quotas' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /usr/lib/one/ruby/quota.rb:199:in `check_quotas' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /usr/lib/one/ruby/quota.rb:194:in `each' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /usr/lib/one/ruby/quota.rb:194:in `each' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /usr/lib/one/ruby/quota.rb:194:in `check_quotas' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /usr/lib/one/ruby/quota.rb:194:in `check_quotas' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /usr/lib/one/ruby/quota.rb:184:in `authorize' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /usr/lib/one/ruby/quota.rb:184:in `authorize' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /var/lib/one/remotes/auth/quota/authorize:53 > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /var/lib/one/remotes/auth/quota/authorize:53 > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /var/lib/one/remotes/auth/quota/authorize:52:in `each' > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /var/lib/one/remotes/auth/quota/authorize:52:in `each' > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 > > > from /var/lib/one/remotes/auth/quota/authorize:52 > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: > > > from /var/lib/one/remotes/auth/quota/authorize:52 > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: LOG I 11 ExitCode: > > > 1 > > > > > > Thu Dec 15 11:43:26 2011 [AuM][I]: ExitCode: 1 > > > Thu Dec 15 11:43:26 2011 [AuM][D]: Message received: AUTHORIZE FAILURE > > > 11 - > > > > > > Thu Dec 15 11:43:26 2011 [AuM][E]: Auth Error: > > > Thu Dec 15 11:43:26 2011 [ReM][E]: [VirtualMachineAllocate] User [1] > not > > > authorized to perform action on virtual machine. > > > > > > -- > > > Hutson Betts > > > Computer Science and Engineering > > > Texas A&M University > > > > > > > > > On Thu, 2011-12-15 at 14:26 +1000, Graeme Gillies wrote: > > >> Hi, > > >> > > >> I've done some more investigating and I've got a handle on what the > problem is. > > >> > > >> My VM templates don't define a CPU attribute (as I'm just letting it > > >> use the default values) and therefore the code errors out trying to > > >> get a CPU value from my vm template which don't have one. > > >> > > >> This sounds like a bug to me, I'm assuming I should file it at > > >> dev.opennebula.org? > > >> > > >> Regards, > > >> > > >> Graeme > > >> > > >> On Mon, Dec 5, 2011 at 3:36 PM, Graeme Gillies > > >> <[email protected]> wrote: > > >> > Hi, > > >> > > > >> > I have enabled the quota module on my opennebula 3 installation and > > >> > now whenever I try and create a vm image, either from a template or > > >> > file from disk, I get the quota module denying me. I have checked > the > > >> > quota limits for the user are ok. Running the command from the > > >> > oned.log with ruby debug gives the following error message > > >> > > > >> > /var/lib/one/remotes/auth/quota/authorize:38: warning: ambiguous > first > > >> > argument; put parentheses or even spaces > > >> > /var/lib/one/remotes/auth/quota/authorize:57: warning: ambiguous > first > > >> > argument; put parentheses or even spaces > > >> > Exception `LoadError' at > /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1113 > > >> > - no such file to load -- rubygems/defaults/operating_system > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:50 - no such > file > > >> > to load -- Win32API > > >> > Exception `NoMethodError' at /usr/lib/ruby/1.8/rational.rb:78 - > > >> > undefined method `gcd' for Rational(1, 2):Rational > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such > > >> > file to load -- nokogiri > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such > > >> > file to load -- xmlparser > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such > > >> > file to load -- xmlparser > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such > > >> > file to load -- sequel > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/model/base.rb:817: > > >> > warning: `*' interpreted as argument prefix > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/model/base.rb:631: > > >> > warning: instance variable @dataset not initialized > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/model/base.rb:631: > > >> > warning: instance variable @dataset not initialized > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such > > >> > file to load -- sqlite3 > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such > > >> > file to load -- sqlite3/1.8/sqlite3_native > > >> > Exception `LoadError' at > > >> > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such > > >> > file to load -- sqlite3/1.8/sqlite3_native > > >> > Exception `SQLite3::SQLException' at > > >> > > /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.3/lib/sqlite3/database.rb:91 - > > >> > index quotas_uid_index already exists > > >> > Exception `Sequel::DatabaseError' at > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/database/misc.rb:254 > > >> > - SQLite3::SQLException: index quotas_uid_index already exists > > >> > Exception `SQLite3::SQLException' at > > >> > > /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.3/lib/sqlite3/database.rb:91 - > > >> > index usage_uid_index already exists > > >> > Exception `Sequel::DatabaseError' at > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/database/misc.rb:254 > > >> > - SQLite3::SQLException: index usage_uid_index already exists > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/dataset/actions.rb:130: > > >> > warning: instance variable @row_proc not initialized > > >> > > /usr/lib/ruby/gems/1.8/gems/sequel-3.29.0/lib/sequel/dataset/actions.rb:130: > > >> > warning: instance variable @row_proc not initialized > > >> > Exception `TypeError' at /usr/lib/one/ruby/quota.rb:199 - can't > > >> > convert nil into Float > > >> > /usr/lib/one/ruby/quota.rb:199:in `Float': can't convert nil into > > >> > Float (TypeError) > > >> > from /usr/lib/one/ruby/quota.rb:199:in `send' > > >> > from /usr/lib/one/ruby/quota.rb:199:in `check_quotas' > > >> > from /usr/lib/one/ruby/quota.rb:194:in `each' > > >> > from /usr/lib/one/ruby/quota.rb:194:in `check_quotas' > > >> > from /usr/lib/one/ruby/quota.rb:184:in `authorize' > > >> > from /var/lib/one/remotes/auth/quota/authorize:53 > > >> > from /var/lib/one/remotes/auth/quota/authorize:52:in `each' > > >> > from /var/lib/one/remotes/auth/quota/authorize:52 > > >> > > > >> > output for onequota show 1 > > >> > > > >> > uid cpu memory num_vms storage > > >> > 1 0/3 5120/10240 4/10 0/20480 > > >> > > > >> > Any help would be much appreciated. > > >> > > > >> > Regards, > > >> > > > >> > Graeme > > >> _______________________________________________ > > >> Users mailing list > > >> [email protected] > > >> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org > > > > > > _______________________________________________ > > > Users mailing list > > > [email protected] > > > http://lists.opennebula.org/listinfo.cgi/users-opennebula.org > > > > > > > > > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.opennebula.org/listinfo.cgi/users-opennebula.org > > -- Daniel Molina Project Engineer OpenNebula - The Open Source Toolkit for Data Center Virtualization www.OpenNebula.org | [email protected] | @OpenNebula
_______________________________________________ Users mailing list [email protected] http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
