try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / glance / lib / puppet / type / glance_image.rb
1 Puppet::Type.newtype(:glance_image) do
2   desc <<-EOT
3     This allows manifests to declare an image to be
4     stored in glance.
5
6     glance_image { "Ubuntu 12.04 cloudimg amd64":
7       ensure           => present,
8       name             => "Ubuntu 12.04 cloudimg amd64"
9       is_public        => yes,
10       container_format => ovf,
11       disk_format      => 'qcow2',
12       source           => 'http://uec-images.ubuntu.com/releases/precise/release/ubuntu-12.04-server-cloudimg-amd64-disk1.img'
13     }
14
15     Known problems / limitations:
16       * All images are managed by the glance service. 
17         This means that since users are unable to manage their own images via this type,
18         is_public is really of no use. You can probably hide images this way but that's all.
19       * As glance image names do not have to be unique, you must ensure that your glance 
20         repository does not have any duplicate names prior to using this.
21       * Ensure this is run on the same server as the glance-api service.
22
23   EOT
24
25   ensurable
26
27   newparam(:name, :namevar => true) do
28     desc 'The image name'
29     newvalues(/.*/)
30   end
31
32   newproperty(:id) do
33     desc 'The unique id of the image'
34     validate do |v|
35       raise(Puppet::Error, 'This is a read only property')
36     end
37   end
38
39   newproperty(:location) do
40     desc "The permanent location of the image. Optional"
41     newvalues(/\S+/)
42   end
43
44   newproperty(:is_public) do
45     desc "Whether the image is public or not. Default true"
46     newvalues(/(y|Y)es/, /(n|N)o/)
47     defaultto('Yes')
48     munge do |v|
49       if v =~ /^(y|Y)es$/
50         'True'
51       elsif v =~ /^(n|N)o$/
52         'False'
53       end
54     end
55   end
56
57   newproperty(:container_format) do
58     desc "The format of the container"
59     newvalues(:ami, :ari, :aki, :bare, :ovf)
60   end
61
62   newproperty(:disk_format) do
63     desc "The format of the disk"
64     newvalues(:ami, :ari, :aki, :vhd, :vmd, :raw, :qcow2, :vdi, :iso)
65   end
66
67   newparam(:source) do
68     desc "The source of the image to import from"
69     newvalues(/\S+/)
70   end
71
72   # Require the Glance service to be running
73   autorequire(:service) do
74     ['glance']
75   end
76
77 end
78
79