File: cinder_type.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 (39 lines) | stat: -rw-r--r-- 953 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
Puppet::Type.newtype(:cinder_type) do

  desc 'Type for managing cinder types.'

  ensurable

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

  newproperty(:properties) do
    desc "The set of volume type 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(:is_public, :boolean => true) do
    desc 'Whether the type is public or not. Default to `true`'
    newvalues(:true, :false)
    defaultto :true
  end

  newproperty(:access_project_ids,  :array_matching => :all) do
    desc 'Project ids which have access to private cinder type. Should be an array, [project1, project2, ...]'
    def insync?(is)
      return false unless is.is_a? Array
      is.sort == should.sort
    end
  end

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