Merge lp:~hopem/charm-helpers/lp1497517 into lp:charm-helpers

Proposed by Edward Hope-Morley
Status: Superseded
Proposed branch: lp:~hopem/charm-helpers/lp1497517
Merge into: lp:charm-helpers
Diff against target: 65 lines (+35/-1)
2 files modified
charmhelpers/contrib/openstack/context.py (+11/-1)
tests/contrib/openstack/test_os_contexts.py (+24/-0)
To merge this branch: bzr merge lp:~hopem/charm-helpers/lp1497517
Reviewer Review Type Date Requested Status
Billy Olsen Needs Fixing
charmers Pending
Review via email: mp+271886@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-22.

To post a comment you must log in.
Revision history for this message
Billy Olsen (billy-olsen) wrote :

Changes seem generally fine to me, but would love to see a unit-test covering this new code.

Also note: there are unrelated py3 test failures.

review: Needs Fixing
lp:~hopem/charm-helpers/lp1497517 updated
454. By Edward Hope-Morley

added unit tests

Revision history for this message
Edward Hope-Morley (hopem) wrote :

Granted!

lp:~hopem/charm-helpers/lp1497517 updated
455. By Edward Hope-Morley

avoid duplicate ports in list

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2015-09-15 17:52:15 +0000
3+++ charmhelpers/contrib/openstack/context.py 2015-09-22 09:48:23 +0000
4@@ -14,6 +14,7 @@
5 # You should have received a copy of the GNU Lesser General Public License
6 # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
7
8+import glob
9 import json
10 import os
11 import re
12@@ -1378,8 +1379,17 @@
13 ports = mappings.values()
14 napi_settings = NeutronAPIContext()()
15 mtu = napi_settings.get('network_device_mtu')
16+ all_ports = []
17+ # If any of ports is a vlan device, its underlying device must have
18+ # mtu applied first.
19+ for port in ports:
20+ for lport in glob.glob("/sys/class/net/%s/lower_*" % port):
21+ lport = os.path.basename(lport)
22+ all_ports.append(lport.split('_')[1])
23+
24+ all_ports.extend(ports)
25 if mtu:
26- ctxt["devs"] = '\\n'.join(ports)
27+ ctxt["devs"] = '\\n'.join(all_ports)
28 ctxt['mtu'] = mtu
29
30 return ctxt
31
32=== modified file 'tests/contrib/openstack/test_os_contexts.py'
33--- tests/contrib/openstack/test_os_contexts.py 2015-09-15 17:52:15 +0000
34+++ tests/contrib/openstack/test_os_contexts.py 2015-09-22 09:48:23 +0000
35@@ -2564,6 +2564,30 @@
36 self.assertEquals(context.DataPortContext()(),
37 {'phybr1': 'eth1010'})
38
39+ @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
40+ {'network_device_mtu': 5000})
41+ @patch.object(context, 'get_nic_hwaddr', lambda inst, port: port)
42+ @patch.object(context.NeutronPortContext, 'resolve_ports',
43+ lambda inst, ports: ports)
44+ def test_phy_nic_mtu_context(self):
45+ self.config.side_effect = fake_config({'data-port':
46+ 'phybr1:eth0'})
47+ ctxt = context.PhyNICMTUContext()()
48+ self.assertEqual(ctxt, {'devs': 'eth0', 'mtu': 5000})
49+
50+ @patch.object(context.glob, 'glob')
51+ @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
52+ {'network_device_mtu': 5000})
53+ @patch.object(context, 'get_nic_hwaddr', lambda inst, port: port)
54+ @patch.object(context.NeutronPortContext, 'resolve_ports',
55+ lambda inst, ports: ports)
56+ def test_phy_nic_mtu_context_vlan(self, mock_glob):
57+ self.config.side_effect = fake_config({'data-port':
58+ 'phybr1:eth0.100'})
59+ mock_glob.return_value = ['/sys/class/net/eth0.100/lower_eth0']
60+ ctxt = context.PhyNICMTUContext()()
61+ self.assertEqual(ctxt, {'devs': 'eth0\\neth0.100', 'mtu': 5000})
62+
63 def test_neutronapicontext_defaults(self):
64 self.relation_ids.return_value = []
65 expected_keys = [

Subscribers

People subscribed via source and target branches