1 Puppet::Type.newtype(:neutron_subnet) do
5 newparam(:name, :namevar => true) do
6 desc 'Symbolic name for the subnet'
11 desc 'The unique id of the subnet'
13 raise(Puppet::Error, 'This is a read only property')
18 desc 'CIDR representing IP range for this subnet, based on IP version'
21 newproperty(:ip_version) do
22 desc 'The IP version of the CIDR'
26 newproperty(:allocation_pools, :array_matching => :all) do
28 Array of Sub-ranges of cidr available for dynamic allocation to ports.
29 Syntax:["start=IPADDR,end=IPADDR", ...]
33 newproperty(:gateway_ip) do
35 The default gateway provided by DHCP to devices in this subnet. If set to
36 '' then no gateway IP address will be provided via DHCP.
40 newproperty(:enable_dhcp) do
41 desc 'Whether DHCP is enabled for this subnet or not.'
42 newvalues(/(t|T)rue/, /(f|F)alse/)
48 newproperty(:host_routes, :array_matching => :all) do
50 Array of routes that should be used by devices with IPs from this subnet
51 (not including local subnet route).
52 Syntax:["destination=CIDR,nexhop=IP_ADDR", ...]
56 newproperty(:dns_nameservers, :array_matching => :all) do
58 'Array of DNS name servers used by hosts in this subnet.'
62 newproperty(:network_id) do
63 desc 'A uuid identifying the network this subnet is associated with.'
66 newparam(:network_name) do
67 desc 'The name of the network this subnet is associated with.'
70 newparam(:tenant_name) do
71 desc 'The name of the tenant which will own the subnet.'
74 newproperty(:tenant_id) do
75 desc 'A uuid identifying the tenant which will own the subnet.'
78 autorequire(:service) do
82 autorequire(:keystone_tenant) do
83 [self[:tenant_name]] if self[:tenant_name]
86 autorequire(:neutron_network) do
87 [self[:network_name]] if self[:network_name]
91 if self[:ensure] != :present
95 raise(Puppet::Error, 'Please provide a valid CIDR')
96 elsif ! (self[:network_id] || self[:network_name])
97 raise(Puppet::Error, <<-EOT
98 A value for one of network_name or network_id must be provided.
101 elsif self[:network_id] && self[:network_name]
102 raise(Puppet::Error, <<-EOT
103 Please provide a value for only one of network_name and network_id.
106 elsif self[:tenant_id] && self[:tenant_name]
107 raise(Puppet::Error, <<-EOT
108 Please provide a value for only one of tenant_name and tenant_id.