]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/neutron/lib/puppet/type/neutron_network.rb
try again, with puppetforge modules, correctly included now
[dsa-puppet.git] / 3rdparty / modules / neutron / lib / puppet / type / neutron_network.rb
1 Puppet::Type.newtype(:neutron_network) do
2
3   ensurable
4
5   newparam(:name, :namevar => true) do
6     desc 'Symbolic name for the network'
7     newvalues(/.*/)
8   end
9
10   newproperty(:id) do
11     desc 'The unique id of the network'
12     validate do |v|
13       raise(Puppet::Error, 'This is a read only property')
14     end
15   end
16
17   newproperty(:admin_state_up) do
18     desc 'The administrative status of the network'
19     newvalues(/(t|T)rue/, /(f|F)alse/)
20     munge do |v|
21       v.to_s.capitalize
22     end
23   end
24
25   newproperty(:shared) do
26     desc 'Whether this network should be shared across all tenants or not'
27     newvalues(/(t|T)rue/, /(f|F)alse/)
28     munge do |v|
29       v.to_s.capitalize
30     end
31   end
32
33   newparam(:tenant_name) do
34     desc 'The name of the tenant which will own the network.'
35   end
36
37   newproperty(:tenant_id) do
38     desc 'A uuid identifying the tenant which will own the network.'
39   end
40
41   newproperty(:provider_network_type) do
42     desc 'The physical mechanism by which the virtual network is realized.'
43     newvalues(:flat, :vlan, :local, :gre, :l3_ext, :vxlan)
44   end
45
46   newproperty(:provider_physical_network) do
47     desc <<-EOT
48       The name of the physical network over which the virtual network
49       is realized for flat and VLAN networks.
50     EOT
51     newvalues(/\S+/)
52   end
53
54   newproperty(:provider_segmentation_id) do
55     desc 'Identifies an isolated segment on the physical network.'
56     munge do |v|
57       Integer(v)
58     end
59   end
60
61   newproperty(:router_external) do
62     desc 'Whether this router will route traffic to an external network'
63     newvalues(/(t|T)rue/, /(f|F)alse/)
64     munge do |v|
65       v.to_s.capitalize
66     end
67   end
68
69   # Require the neutron-server service to be running
70   autorequire(:service) do
71     ['neutron-server']
72   end
73
74   autorequire(:keystone_tenant) do
75     [self[:tenant_name]] if self[:tenant_name]
76   end
77
78   validate do
79     if self[:ensure] != :present
80       return
81     end
82     if self[:tenant_id] && self[:tenant_name]
83       raise(Puppet::Error, <<-EOT
84 Please provide a value for only one of tenant_name and tenant_id.
85 EOT
86             )
87     end
88   end
89
90 end