try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / lib / puppet / type / neutron_port.rb
1 Puppet::Type.newtype(:neutron_port) do
2   desc <<-EOT
3     This is currently used to model the creation of neutron ports.
4
5     Ports are used when associating a network and a router interface.
6   EOT
7
8   ensurable
9
10   newparam(:name, :namevar => true) do
11     desc 'Symbolic name for the port'
12     newvalues(/.*/)
13   end
14
15   newproperty(:id) do
16     desc 'The unique id of the port'
17     validate do |v|
18       raise(Puppet::Error, 'This is a read only property')
19     end
20   end
21
22   newproperty(:admin_state_up) do
23     desc 'The administrative status of the router'
24     newvalues(/(t|T)rue/, /(f|F)alse/)
25     munge do |v|
26       v.to_s.capitalize
27     end
28   end
29
30   newproperty(:network_name) do
31     desc <<-EOT
32       The name of the network that this port is assigned to on creation.
33     EOT
34   end
35
36   newproperty(:network_id) do
37     desc <<-EOT
38       The uuid of the network that this port is assigned to on creation.
39     EOT
40     validate do |v|
41       raise(Puppet::Error, 'This is a read only property')
42     end
43   end
44
45   newproperty(:subnet_name) do
46     desc 'A subnet to which the port is assigned on creation.'
47   end
48
49   newproperty(:subnet_id) do
50     desc <<-EOT
51       The uuid of the subnet on which this ports ip exists.
52     EOT
53     validate do |v|
54       raise(Puppet::Error, 'This is a read only property')
55     end
56   end
57
58   newproperty(:ip_address) do
59     desc 'A static ip address given to the port on creation.'
60   end
61
62   newproperty(:status) do
63     desc 'Whether the port is currently operational or not.'
64     validate do |v|
65       raise(Puppet::Error, 'This is a read only property')
66     end
67   end
68
69   newparam(:tenant_name) do
70     desc 'The name of the tenant which will own the port.'
71   end
72
73   newproperty(:tenant_id) do
74     desc 'A uuid identifying the tenant which will own the port.'
75   end
76
77   autorequire(:service) do
78     ['neutron-server']
79   end
80
81   autorequire(:keystone_tenant) do
82     [self[:tenant_name]] if self[:tenant_name]
83   end
84
85   autorequire(:neutron_network) do
86     [self[:name]]
87   end
88
89   validate do
90     if self[:tenant_id] && self[:tenant_name]
91       raise(Puppet::Error, 'Please provide a value for only one of tenant_name and tenant_id.')
92     end
93     if self[:ip_address] && self[:subnet_name]
94       raise(Puppet::Error, 'Please provide a value for only one of ip_address and subnet_name.')
95     end
96   end
97
98 end