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
=== modified file 'charmhelpers/contrib/openstack/context.py'
--- charmhelpers/contrib/openstack/context.py 2015-09-15 17:52:15 +0000
+++ charmhelpers/contrib/openstack/context.py 2015-09-22 09:48:23 +0000
@@ -14,6 +14,7 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
1616
17import glob
17import json18import json
18import os19import os
19import re20import re
@@ -1378,8 +1379,17 @@
1378 ports = mappings.values()1379 ports = mappings.values()
1379 napi_settings = NeutronAPIContext()()1380 napi_settings = NeutronAPIContext()()
1380 mtu = napi_settings.get('network_device_mtu')1381 mtu = napi_settings.get('network_device_mtu')
1382 all_ports = []
1383 # If any of ports is a vlan device, its underlying device must have
1384 # mtu applied first.
1385 for port in ports:
1386 for lport in glob.glob("/sys/class/net/%s/lower_*" % port):
1387 lport = os.path.basename(lport)
1388 all_ports.append(lport.split('_')[1])
1389
1390 all_ports.extend(ports)
1381 if mtu:1391 if mtu:
1382 ctxt["devs"] = '\\n'.join(ports)1392 ctxt["devs"] = '\\n'.join(all_ports)
1383 ctxt['mtu'] = mtu1393 ctxt['mtu'] = mtu
13841394
1385 return ctxt1395 return ctxt
13861396
=== modified file 'tests/contrib/openstack/test_os_contexts.py'
--- tests/contrib/openstack/test_os_contexts.py 2015-09-15 17:52:15 +0000
+++ tests/contrib/openstack/test_os_contexts.py 2015-09-22 09:48:23 +0000
@@ -2564,6 +2564,30 @@
2564 self.assertEquals(context.DataPortContext()(),2564 self.assertEquals(context.DataPortContext()(),
2565 {'phybr1': 'eth1010'})2565 {'phybr1': 'eth1010'})
25662566
2567 @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
2568 {'network_device_mtu': 5000})
2569 @patch.object(context, 'get_nic_hwaddr', lambda inst, port: port)
2570 @patch.object(context.NeutronPortContext, 'resolve_ports',
2571 lambda inst, ports: ports)
2572 def test_phy_nic_mtu_context(self):
2573 self.config.side_effect = fake_config({'data-port':
2574 'phybr1:eth0'})
2575 ctxt = context.PhyNICMTUContext()()
2576 self.assertEqual(ctxt, {'devs': 'eth0', 'mtu': 5000})
2577
2578 @patch.object(context.glob, 'glob')
2579 @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
2580 {'network_device_mtu': 5000})
2581 @patch.object(context, 'get_nic_hwaddr', lambda inst, port: port)
2582 @patch.object(context.NeutronPortContext, 'resolve_ports',
2583 lambda inst, ports: ports)
2584 def test_phy_nic_mtu_context_vlan(self, mock_glob):
2585 self.config.side_effect = fake_config({'data-port':
2586 'phybr1:eth0.100'})
2587 mock_glob.return_value = ['/sys/class/net/eth0.100/lower_eth0']
2588 ctxt = context.PhyNICMTUContext()()
2589 self.assertEqual(ctxt, {'devs': 'eth0\\neth0.100', 'mtu': 5000})
2590
2567 def test_neutronapicontext_defaults(self):2591 def test_neutronapicontext_defaults(self):
2568 self.relation_ids.return_value = []2592 self.relation_ids.return_value = []
2569 expected_keys = [2593 expected_keys = [

Subscribers

People subscribed via source and target branches