File: cinder_qos.rb

package info (click to toggle)
puppet-module-cinder 27.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,512 kB
  • sloc: ruby: 6,697; python: 33; sh: 10; makefile: 10
file content (47 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download
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
Puppet::Type.newtype(:cinder_qos) do

  desc 'Type for managing cinder QOS.'

  ensurable

  newparam(:name, :namevar => true) do
    newvalues(/\S+/)
  end

  newproperty(:associations, :array_matching => :all) do
    desc 'The cinder Types associations. Should be an array'
    defaultto []
    def insync?(is)
      return false unless is.is_a? Array
      is.sort == should.sort
    end
    validate do |value|
      raise ArgumentError, "Types name doesn't match" unless value.match(/^[-\w]+$/)
    end
  end

  newproperty(:properties) do
    desc "The set of volume qos properties"
    validate do |value|
      if value.is_a?(Hash)
        return true
      else
        raise ArgumentError, "Invalid properties #{value}. Requires a Hash, not a #{value.class}"
      end
    end
  end

  newproperty(:consumer) do
    desc 'The consumer QOS'
    newvalues('front-end', 'back-end', 'both')
    defaultto('both')
  end

  autorequire(:cinder_qos) do
    self[:associations] if self[:associations]
  end

  autorequire(:anchor) do
    ['cinder::service::end']
  end
end