neutron_network: Allow customizing MTU
Closes-Bug: #1590039 Change-Id: I203014f15f00b6f8f0306e7bc75f45247df4f7b7
This commit is contained in:
parent
581f6a3149
commit
2a8ca843d0
@ -44,7 +44,8 @@ Puppet::Type.type(:neutron_network).provide(
|
||||
:shared => network[:shared],
|
||||
:tenant_id => network[:project_id],
|
||||
:project_id => network[:project_id],
|
||||
:availability_zone_hint => parse_availability_zone_hint(network[:availability_zone_hints])
|
||||
:availability_zone_hint => parse_availability_zone_hint(network[:availability_zone_hints]),
|
||||
:mtu => network[:mtu],
|
||||
)
|
||||
end
|
||||
self.do_not_manage = false
|
||||
@ -114,6 +115,10 @@ Puppet::Type.type(:neutron_network).provide(
|
||||
end
|
||||
end
|
||||
|
||||
if @resource[:mtu]
|
||||
opts << "--mtu=#{@resource[:mtu]}"
|
||||
end
|
||||
|
||||
network = self.class.request('network', 'create', opts)
|
||||
@property_hash = {
|
||||
:ensure => :present,
|
||||
@ -127,7 +132,8 @@ Puppet::Type.type(:neutron_network).provide(
|
||||
:shared => network[:shared],
|
||||
:tenant_id => network[:project_id],
|
||||
:project_id => network[:project_id],
|
||||
:availability_zone_hint => self.class.parse_availability_zone_hint(network[:availability_zone_hints])
|
||||
:availability_zone_hint => self.class.parse_availability_zone_hint(network[:availability_zone_hints]),
|
||||
:mtu => network[:mtu],
|
||||
}
|
||||
end
|
||||
|
||||
@ -159,6 +165,10 @@ Puppet::Type.type(:neutron_network).provide(
|
||||
end
|
||||
end
|
||||
|
||||
if @property_flush[:mtu]
|
||||
opts << "--mtu=#{@property_flush[:mtu]}"
|
||||
end
|
||||
|
||||
self.class.request('network', 'set', opts)
|
||||
@property_flush.clear
|
||||
end
|
||||
@ -177,6 +187,7 @@ Puppet::Type.type(:neutron_network).provide(
|
||||
:admin_state_up,
|
||||
:shared,
|
||||
:router_external,
|
||||
:mtu
|
||||
].each do |attr|
|
||||
define_method(attr.to_s + "=") do |value|
|
||||
if self.class.do_not_manage
|
||||
|
@ -81,6 +81,14 @@ Puppet::Type.newtype(:neutron_network) do
|
||||
desc 'The availability zone hint to provide the scheduler'
|
||||
end
|
||||
|
||||
newproperty(:mtu) do
|
||||
desc 'Set network mtu'
|
||||
newvalues(/\d+/)
|
||||
munge do |v|
|
||||
Integer(v)
|
||||
end
|
||||
end
|
||||
|
||||
# Require the neutron-server service to be running
|
||||
autorequire(:anchor) do
|
||||
['neutron::service::end']
|
||||
|
5
releasenotes/notes/network-mtu-c02dc3947a513f73.yaml
Normal file
5
releasenotes/notes/network-mtu-c02dc3947a513f73.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The ``neutron_network`` resource type now supports the new ``mtu`` property
|
||||
to set network MTU.
|
@ -13,6 +13,10 @@ describe 'basic neutron' do
|
||||
include openstack_integration::mysql
|
||||
include openstack_integration::keystone
|
||||
include openstack_integration::neutron
|
||||
|
||||
neutron_network { 'mtutest':
|
||||
mtu => 1000,
|
||||
}
|
||||
EOS
|
||||
|
||||
|
||||
|
@ -48,13 +48,15 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="False"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.admin_state_up).to eq('True')
|
||||
expect(provider.tenant_id).to eq('60f9544eb94c42a6b7e8e98c2be981b1')
|
||||
expect(provider.router_external).to eq('False')
|
||||
expect(provider.shared).to eq('False')
|
||||
expect(provider.mtu).to eq('1500')
|
||||
end
|
||||
end
|
||||
|
||||
@ -76,7 +78,8 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="False"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.admin_state_up).to eq('False')
|
||||
@ -101,7 +104,8 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="False"
|
||||
shared="True"')
|
||||
shared="True"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.shared).to eq('True')
|
||||
@ -126,7 +130,8 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="False"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
end
|
||||
@ -157,7 +162,8 @@ provider_network_type="vlan"
|
||||
provider_physical_network="datacentre"
|
||||
provider_segmentation_id="10"
|
||||
router_external="False"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.provider_network_type).to eq('vlan')
|
||||
@ -184,12 +190,38 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="True"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.router_external).to eq('True')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with mtu' do
|
||||
let :net_attrs do
|
||||
{
|
||||
:name => net_name,
|
||||
:mtu => 9000,
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates network' do
|
||||
provider_class.expects(:openstack)
|
||||
.with('network', 'create', '--format', 'shell',
|
||||
['net1', '--mtu=9000'])
|
||||
.returns('admin_state_up="True"
|
||||
availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="True"
|
||||
shared="False"
|
||||
mtu="9000"')
|
||||
provider.create
|
||||
expect(provider.exists?).to be_truthy
|
||||
expect(provider.mtu).to eq('9000')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
@ -243,6 +275,15 @@ shared="False"')
|
||||
provider.flush
|
||||
end
|
||||
end
|
||||
|
||||
context '.mtu' do
|
||||
it 'updates mtu' do
|
||||
provider_class.expects(:openstack)
|
||||
.with('network', 'set', ['net1', '--mtu=1490'])
|
||||
provider.mtu = 1490
|
||||
provider.flush
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#instances' do
|
||||
@ -261,7 +302,8 @@ availability_zone_hints="[]"
|
||||
id="076520cc-b783-4cf5-a4a9-4cb5a5e93a9b"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="False"
|
||||
shared="False"')
|
||||
shared="False"
|
||||
mtu="1500"')
|
||||
provider_class.expects(:openstack)
|
||||
.with('network', 'show', '--format', 'shell',
|
||||
'34e8f42b-89db-4a5b-92db-76ca7073414d')
|
||||
@ -270,7 +312,8 @@ availability_zone_hints="[]"
|
||||
id="34e8f42b-89db-4a5b-92db-76ca7073414d"
|
||||
project_id="60f9544eb94c42a6b7e8e98c2be981b1"
|
||||
router_external="True"
|
||||
shared="True"')
|
||||
shared="True"
|
||||
mtu="9000"')
|
||||
|
||||
instances = provider_class.instances
|
||||
expect(instances.length).to eq(2)
|
||||
@ -281,6 +324,7 @@ shared="True"')
|
||||
expect(instances[0].router_external).to eq('False')
|
||||
expect(instances[0].tenant_id).to eq('60f9544eb94c42a6b7e8e98c2be981b1')
|
||||
expect(instances[0].shared).to eq('False')
|
||||
expect(instances[0].mtu).to eq('1500')
|
||||
|
||||
expect(instances[1].id).to eq('34e8f42b-89db-4a5b-92db-76ca7073414d')
|
||||
expect(instances[1].name).to eq('net2')
|
||||
@ -288,6 +332,7 @@ shared="True"')
|
||||
expect(instances[1].tenant_id).to eq('60f9544eb94c42a6b7e8e98c2be981b1')
|
||||
expect(instances[1].router_external).to eq('True')
|
||||
expect(instances[1].shared).to eq('True')
|
||||
expect(instances[1].mtu).to eq('9000')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user