summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-27 11:05:00 +0000
committerGerrit Code Review <review@openstack.org>2017-03-27 11:05:00 +0000
commitec5d01b6ad9c37c68f16f935ec1095c5de9d224a (patch)
tree40812dffc04e006e421ff8cc8a2718781cafc6d2
parent7dc2405d31d2daf3a70b8cc905ef159d3a97cb8d (diff)
parentc83d8a06fecdddea622996b5ba102fa136457c95 (diff)
Merge "Handle vlan_id in dpdk/vxlan mode"
-rw-r--r--deployment/puppet/osnailyfacter/lib/puppet/parser/functions/remove_ovs_usage.rb48
-rw-r--r--deployment/puppet/osnailyfacter/spec/functions/remove_ovs_usage_spec.rb19
2 files changed, 39 insertions, 28 deletions
diff --git a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/remove_ovs_usage.rb b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/remove_ovs_usage.rb
index febfae7..e2ec9ec 100644
--- a/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/remove_ovs_usage.rb
+++ b/deployment/puppet/osnailyfacter/lib/puppet/parser/functions/remove_ovs_usage.rb
@@ -1,42 +1,29 @@
1require 'yaml' 1require 'yaml'
2 2
3Puppet::Parser::Functions::newfunction( :remove_ovs_usage, 3Puppet::Parser::Functions::newfunction( :remove_ovs_usage,
4 :type => :rvalue, :doc => <<-EOS 4 :type => :rvalue, :arity => 1, :doc => <<-EOS
5 This function get network_scheme and returns mangled 5 This function get network_scheme and returns mangled
6 network scheme without ovs-based elements. 6 network scheme without ovs-based elements.
7 EOS 7 EOS
8 ) do |argv| 8 ) do |argv|
9 9
10 def bridge_name_max_len 10 raise(
11 15 11 Puppet::ParseError,
12 end 12 "remove_ovs_usage(): Wrong network_scheme. Should be non-empty Hash."
13 ) unless argv[0].is_a?(Hash)
13 14
14 if argv.size != 1 15 raise(
15 raise( 16 Puppet::ParseError,
16 Puppet::ParseError, 17 "remove_ovs_usage(): You network_scheme hash has wrong format.\nThis parser can work with v1.1 format, please convert you config."
17 "remove_ovs_usage(): Wrong number of arguments. Should be two." 18 ) if argv[0]['version'].to_s.to_f < 1.1
18 )
19 end
20 if !argv[0].is_a?(Hash)
21 raise(
22 Puppet::ParseError,
23 "remove_ovs_usage(): Wrong network_scheme. Should be non-empty Hash."
24 )
25 end
26 if argv[0]['version'].to_s.to_f < 1.1
27 raise(
28 Puppet::ParseError,
29 "remove_ovs_usage(): You network_scheme hash has wrong format.\nThis parser can work with v1.1 format, please convert you config."
30 )
31 end
32 19
33 network_scheme = argv[0] 20 transformations = argv[0]['transformations']
34 rv = { 21 rv = {
35 'use_ovs' => false 22 'use_ovs' => false
36 } 23 }
37 overrides = [] 24 overrides = []
38 25
39 network_scheme['transformations'].each do |tr| 26 transformations.each do |tr|
40 # get all dependent ovs providers 27 # get all dependent ovs providers
41 if tr['provider'] =~ /ovs/ 28 if tr['provider'] =~ /ovs/
42 if tr['action'] == 'add-patch' 29 if tr['action'] == 'add-patch'
@@ -46,16 +33,25 @@ Puppet::Parser::Functions::newfunction( :remove_ovs_usage,
46 'provider' => 'lnx' 33 'provider' => 'lnx'
47 } 34 }
48 else 35 else
49 overrides << { 36 override_lnx = {
50 'action' => 'override', 37 'action' => 'override',
51 'override' => tr['name'], 38 'override' => tr['name'],
52 'provider' => 'lnx' 39 'provider' => 'lnx'
53 } 40 }
41
42 # handle vxlan mode
43 if tr['provider'] == 'dpdkovs'
44 bridge = transformations.select { |t| tr['bridge'] == t['name'] }
45 bridge_vlan_id = bridge[0]['vendor_specific']['vlan_id']
46 override_lnx.merge!({'name' => "#{tr['name']}.#{bridge_vlan_id}"}) if bridge_vlan_id
47 end
48
49 overrides << override_lnx
54 end 50 end
55 end 51 end
56 end 52 end
57 53
58 if ! overrides.empty? 54 unless overrides.empty?
59 rv['network_scheme'] = { 55 rv['network_scheme'] = {
60 'transformations' => overrides 56 'transformations' => overrides
61 } 57 }
diff --git a/deployment/puppet/osnailyfacter/spec/functions/remove_ovs_usage_spec.rb b/deployment/puppet/osnailyfacter/spec/functions/remove_ovs_usage_spec.rb
index 5030362..9bdaaad 100644
--- a/deployment/puppet/osnailyfacter/spec/functions/remove_ovs_usage_spec.rb
+++ b/deployment/puppet/osnailyfacter/spec/functions/remove_ovs_usage_spec.rb
@@ -29,6 +29,15 @@ describe 'remove_ovs_usage' do
29 'bridge' => 'bridge-0', 29 'bridge' => 'bridge-0',
30 'action' => 'add-port', 30 'action' => 'add-port',
31 'name' => 'ethx', 31 'name' => 'ethx',
32 },
33 {
34 'provider' => 'ovs',
35 'action' => 'add-br',
36 'name' => 'bridge-0',
37 'vendor_specific' => {
38 'datapath_type' => 'netdev',
39 'vlan_id' => 909,
40 },
32 } 41 }
33 ], 42 ],
34 } 43 }
@@ -48,6 +57,12 @@ describe 'remove_ovs_usage' do
48 'action' => 'override', 57 'action' => 'override',
49 'override' => 'ethx', 58 'override' => 'ethx',
50 'provider' => 'lnx', 59 'provider' => 'lnx',
60 'name' => 'ethx.909',
61 },
62 {
63 'action' => 'override',
64 'override' => 'bridge-0',
65 'provider' => 'lnx',
51 } 66 }
52 ] 67 ]
53 } 68 }
@@ -91,8 +106,8 @@ describe 'remove_ovs_usage' do
91 end 106 end
92 107
93 it 'should expect 1 argument' do 108 it 'should expect 1 argument' do
94 is_expected.to run.with_params().and_raise_error(Puppet::ParseError) 109 is_expected.to run.with_params().and_raise_error(ArgumentError)
95 is_expected.to run.with_params(1, 2).and_raise_error(Puppet::ParseError) 110 is_expected.to run.with_params(1, 2).and_raise_error(ArgumentError)
96 end 111 end
97 112
98 it 'should expect a hash as given argument' do 113 it 'should expect a hash as given argument' do