Project

General

Profile

fog.patch

fog Patch - Anonymous, 03/08/2013 01:32 PM

View differences:

fog-1.9.0/lib/fog/ovirt/compute.rb 2013-03-08 18:07:36.542000080 -0500
16 16
      collection :interfaces
17 17
      model      :volume
18 18
      collection :volumes
19
      model      :quota
20
      collection :quotas
19 21

  
20 22
      request_path 'fog/ovirt/requests/compute'
21 23

  
......
42 44
      request :list_template_volumes
43 45
      request :add_volume
44 46
      request :destroy_volume
47
      request :list_quotas
48
      request :get_quota
45 49

  
46 50
      module Shared
47 51
        # converts an OVIRT object into an hash for fog to consume.
fog-1.9.0/lib/fog/ovirt/models/compute/quota.rb 2013-03-08 03:26:52.040002152 -0500
1
module Fog
2
  module Compute
3
    class Ovirt
4

  
5
      class Quota < Fog::Model
6

  
7
        identity :id
8

  
9
        attribute :name
10
        attribute :description
11

  
12
        def to_s
13
          name
14
        end
15

  
16
      end
17

  
18
    end
19
  end
20
end
21

  
fog-1.9.0/lib/fog/ovirt/models/compute/quotas.rb 2013-03-08 03:40:57.589999878 -0500
1
require 'fog/core/collection'
2
require 'fog/ovirt/models/compute/quota'
3

  
4
module Fog
5
  module Compute
6
    class Ovirt
7

  
8
      class Quotas < Fog::Collection
9

  
10
        model Fog::Compute::Ovirt::Quota
11

  
12
	def all(filters = {})
13
          load service.list_quotas(filters)
14
        end
15

  
16
        def get(id)
17
          new service.get_quota(id)
18
        end
19

  
20
      end
21
    end
22
  end
23
end
24

  
fog-1.9.0/lib/fog/ovirt/models/compute/server.rb 2013-03-08 02:25:00.999998447 -0500
27 27
        attribute :interfaces
28 28
        attribute :volumes
29 29
        attribute :raw
30

  
30
        attribute :quota
31
 
31 32
        def ready?
32 33
          !(status =~ /down/i)
33 34
        end
fog-1.9.0/lib/fog/ovirt/models/compute/volume.rb 2013-03-08 18:04:16.406000061 -0500
15 15
        attribute :format
16 16
        attribute :sparse
17 17
        attribute :size_gb
18
        attribute :quota
18 19

  
19 20
        def size_gb
20 21
          attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]
fog-1.9.0/lib/fog/ovirt/requests/compute/get_quota.rb 2013-03-08 01:24:51.570004916 -0500
1
module Fog
2
  module Compute
3
    class Ovirt
4
      class Real
5
        def get_quota(id)
6
          ovirt_attrs client.quota(id)
7
        end
8

  
9
      end
10
      class Mock
11
        def get_quota(id)
12
          xml = read_xml('quota.xml')
13
          ovirt_attrs OVIRT::Quota::new(self, Nokogiri::XML(xml).root)
14
        end
15
      end
16
    end
17
  end
18
end
19

  
fog-1.9.0/lib/fog/ovirt/requests/compute/list_quotas.rb 2013-03-08 01:25:18.186000764 -0500
1
module Fog
2
  module Compute
3
    class Ovirt
4
      class Real
5
        def list_quotas(filters = {})
6
          client.quotas(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
7
        end
8

  
9
      end
10
      class Mock
11
        def list_quotas(filters = {})
12
          xml = read_xml 'quotas.xml'
13
          Nokogiri::XML(xml).xpath('/quotas/quota').collect do |q|
14
            ovirt_attrs OVIRT::Quotas::new(self, q)
15
          end
16
        end
17
      end
18
    end
19
  end
20
end
21