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