Merge lp:~james-page/charm-helpers/ovs-datapath-type into lp:charm-helpers

Proposed by James Page on 2016-04-05
Status: Merged
Merged at revision: 561
Proposed branch: lp:~james-page/charm-helpers/ovs-datapath-type
Merge into: lp:charm-helpers
Diff against target: 40 lines (+15/-2)
2 files modified
charmhelpers/contrib/network/ovs/__init__.py (+6/-2)
tests/contrib/network/test_ovs.py (+9/-0)
To merge this branch: bzr merge lp:~james-page/charm-helpers/ovs-datapath-type
Reviewer Review Type Date Requested Status
David Ames 2016-04-05 Approve on 2016-04-05
Review via email: mp+290999@code.launchpad.net
To post a comment you must log in.
David Ames (thedac) wrote :

Looks good. Merging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/network/ovs/__init__.py'
2--- charmhelpers/contrib/network/ovs/__init__.py 2015-01-22 06:06:03 +0000
3+++ charmhelpers/contrib/network/ovs/__init__.py 2016-04-05 14:44:48 +0000
4@@ -25,10 +25,14 @@
5 )
6
7
8-def add_bridge(name):
9+def add_bridge(name, datapath_type=None):
10 ''' Add the named bridge to openvswitch '''
11 log('Creating bridge {}'.format(name))
12- subprocess.check_call(["ovs-vsctl", "--", "--may-exist", "add-br", name])
13+ cmd = ["ovs-vsctl", "--", "--may-exist", "add-br", name]
14+ if datapath_type is not None:
15+ cmd += ['--', 'set', 'bridge', name,
16+ 'datapath_type={}'.format(datapath_type)]
17+ subprocess.check_call(cmd)
18
19
20 def del_bridge(name):
21
22=== modified file 'tests/contrib/network/test_ovs.py'
23--- tests/contrib/network/test_ovs.py 2014-07-15 14:45:50 +0000
24+++ tests/contrib/network/test_ovs.py 2016-04-05 14:44:48 +0000
25@@ -119,6 +119,15 @@
26
27 @patch.object(ovs, 'log')
28 @patch('subprocess.check_call')
29+ def test_add_bridge_datapath_type(self, check_call, log):
30+ ovs.add_bridge('test', datapath_type='netdev')
31+ check_call.assert_called_with(["ovs-vsctl", "--", "--may-exist",
32+ "add-br", 'test', "--", "set",
33+ "bridge", "test", "datapath_type=netdev"])
34+ self.assertTrue(log.call_count == 1)
35+
36+ @patch.object(ovs, 'log')
37+ @patch('subprocess.check_call')
38 def test_del_bridge(self, check_call, log):
39 ovs.del_bridge('test')
40 check_call.assert_called_with(["ovs-vsctl", "--", "--if-exists",

Subscribers

People subscribed via source and target branches