Revision f45df6e2

View differences:

src/authm_mad/simple_permissions.rb
16 16
    def get_vm_usage(data)
17 17
        vm_xml=Base64::decode64(data)
18 18
        vm=OpenNebula::VirtualMachine.new(
19
            OpenNebula::XMLUtilsElement.initialize_xml(vm_xml, 'VM'),
19
            OpenNebula::XMLElement.build_xml(vm_xml, 'TEMPLATE'),
20 20
            OpenNebula::Client.new)
21
        vm_hash=vm.to_hash
22 21
        
23 22
        # Should set more sensible defaults or get driver configuration
24
        cpu=vm_hash['TEMPLATE']['CPU']
23
        cpu=vm['CPU']
25 24
        cpu||=1.0
26 25
        cpu=cpu.to_f
27 26
        
28
        memory=vm_hash['TEMPLATE']['MEMORY']
27
        memory=vm['MEMORY']
29 28
        memory||=64
30 29
        memory=memory.to_f
31 30
        
......
53 52
        when 'CREATE'
54 53
            auth_result=true if %w{VM NET IMAGE}.include? object
55 54
            
55
            if @quota_enabled and object=='VM' and auth_result
56
                STDERR.puts 'quota enabled'
57
                @quota.update(uid.to_i)
58
                if !@quota.check(uid.to_i, get_vm_usage(id))
59
                    auth_result="Quota exceeded"
60
                end
61
            end
62
            
56 63
        when 'DELETE'
57 64
            auth_result = (owner == uid)
58 65
            

Also available in: Unified diff