File: get_limits.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (94 lines) | stat: -rw-r--r-- 3,042 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module Fog
  module OpenStack
    class Compute
      # http://developer.openstack.org/api-ref-compute-v2.1.html#showlimits

      class Real
        def get_limits(options = {})
          request(
            :expects => 200,
            :method  => 'GET',
            :path    => '/limits',
            :query   => options
          )
        end
      end

      class Mock
        def get_limits(_options = {})
          rate_limits = [
            {'regex' => '.*',
             'limit' => [
               {'next-available' => '2012-11-22T16:13:44Z',
                'unit'           => 'MINUTE',
                'verb'           => 'POST',
                'remaining'      => 9,
                'value'          => 10},
               {'next-available' => '2012-11-23T00:46:14Z',
                'unit'           => 'MINUTE',
                'verb'           => 'PUT',
                'remaining'      => 10,
                'value'          => 10},
               {'next-available' => '2012-11-22T16:14:30Z',
                'unit'           => 'MINUTE',
                'verb'           => 'DELETE',
                'remaining'      => 99,
                'value'          => 100}
             ],
             'uri'   => '*'},
            {'regex' => '^/servers',
             'limit' => [
               {'next-available' => '2012-11-23T00:46:14Z',
                'unit'           => 'DAY',
                'verb'           => 'POST',
                'remaining'      => 50,
                'value'          => 50}
             ],
             'uri'   => '*/servers'},
            {'regex' => '.*changes-since.*',
             'limit' => [
               {'next-available' => '2012-11-23T00:46:14Z',
                'unit'           => 'MINUTE',
                'verb'           => 'GET',
                'remaining'      => 3,
                'value'          => 3}
             ],
             'uri'   => '*changes-since*'}
          ]

          absolute_limits = {
            # Max
            'maxServerMeta'           => 128,
            'maxTotalInstances'       => 10,
            'maxPersonality'          => 5,
            'maxImageMeta'            => 128,
            'maxPersonalitySize'      => 10240,
            'maxSecurityGroupRules'   => 20,
            'maxTotalKeypairs'        => 100,
            'maxSecurityGroups'       => 10,
            'maxTotalCores'           => 20,
            'maxTotalFloatingIps'     => 10,
            'maxTotalRAMSize'         => 51200,

            # Used
            'totalCoresUsed'          => -1,
            'totalRAMUsed'            => -2048,
            'totalInstancesUsed'      => -1,
            'totalSecurityGroupsUsed' => 0,
            'totalFloatingIpsUsed'    => 0
          }

          Excon::Response.new(
            :status => 200,
            :body   => {
              'limits' => {
                'rate'     => rate_limits,
                'absolute' => absolute_limits
              }
            }
          )
        end
      end
    end
  end
end