3 require 'puppet/provider/neutron_subnet/neutron'
5 provider_class = Puppet::Type.type(:neutron_subnet).provider(:neutron)
7 describe provider_class do
17 :cidr => '10.0.0.0/24',
19 :gateway_ip => '10.0.0.1',
20 :enable_dhcp => 'False',
21 :network_name => 'net1',
23 :allocation_pools => 'start=7.0.0.1,end=7.0.0.10',
24 :dns_nameservers => '8.8.8.8',
25 :host_routes => 'destination=12.0.0.0/24,nexthop=10.0.0.1',
29 describe 'when updating a subnet' do
31 Puppet::Type::Neutron_subnet.new(subnet_attrs)
35 provider_class.new(resource)
38 it 'should call subnet-update to change gateway_ip' do
39 provider.expects(:auth_neutron).with('subnet-update',
40 '--gateway-ip=10.0.0.2',
42 provider.gateway_ip=('10.0.0.2')
45 it 'should call subnet-update to remove gateway_ip with empty string' do
46 provider.expects(:auth_neutron).with('subnet-update',
49 provider.gateway_ip=('')
52 it 'should call subnet-update to change enable_dhcp' do
53 provider.expects(:auth_neutron).with('subnet-update',
56 provider.enable_dhcp=('True')
59 it 'should call subnet-update to change dns_nameservers' do
60 provider.expects(:auth_neutron).with('subnet-update',
65 provider.dns_nameservers=(['9.9.9.9'])
68 it 'should call subnet-update to change host_routes' do
69 provider.expects(:auth_neutron).with('subnet-update',
74 'destination=12.0.0.0/24,nexthop=10.0.0.2'])
75 provider.host_routes=(['destination=12.0.0.0/24,nexthop=10.0.0.2'])
78 it 'should not update if dns_nameservers are empty' do
79 provider.dns_nameservers=('')
82 it 'should not update if host_routes are empty' do
83 provider.host_routes=('')
87 describe 'when updating a subnet (reverse)' do
88 let :subnet_attrs_mod do
89 subnet_attrs.merge!({:enable_dhcp => 'True'})
92 Puppet::Type::Neutron_subnet.new(subnet_attrs_mod)
96 provider_class.new(resource)
100 it 'should call subnet-update to change enable_dhcp' do
101 provider.expects(:auth_neutron).with('subnet-update',
104 provider.enable_dhcp=('False')