summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2019-02-06 13:29:11 -0500
committerDan Radez <dradez@redhat.com>2019-02-07 09:50:39 -0500
commit6f9bb3b20138bcd45da75ba9fd7a465f37266260 (patch)
tree20c665c629026b7b23288ff18a9eae597e41297c
parent7a452237f3cfcc536699b9f8fbb3dd581a7ac9f0 (diff)
Ensure all switch_mac refs are upper()
MAC map was not being used properly because the condition was not forcing the mac to upper as expected. This moves the upper() func to the call to get the initial value instead of running it later when needed. Change-Id: Ic546bba5bf82842a6a4eb31fccc8f1b63a036fa3
Notes
Notes (review): Code-Review+2: Jakub Libosvar <libosvar@redhat.com> Workflow+1: Jakub Libosvar <libosvar@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 07 Feb 2019 17:19:07 +0000 Reviewed-on: https://review.openstack.org/635242 Project: openstack/networking-ansible Branch: refs/heads/master
-rw-r--r--net_ansible_tempest/tests/scenario/test_basic_ops.py2
-rw-r--r--networking_ansible/ml2/mech_driver.py4
-rw-r--r--networking_ansible/tests/unit/base.py4
-rw-r--r--networking_ansible/tests/unit/test_config.py2
-rw-r--r--zuul.d/jobs.yaml2
5 files changed, 8 insertions, 6 deletions
diff --git a/net_ansible_tempest/tests/scenario/test_basic_ops.py b/net_ansible_tempest/tests/scenario/test_basic_ops.py
index 3d1e908..8ddca96 100644
--- a/net_ansible_tempest/tests/scenario/test_basic_ops.py
+++ b/net_ansible_tempest/tests/scenario/test_basic_ops.py
@@ -107,6 +107,6 @@ class TestWithOvs(base.NetAnsibleAdminBaseTest):
107 107
108 @decorators.idempotent_id('40b81fe4-1e9c-4f10-a808-c23f85aea5e3') 108 @decorators.idempotent_id('40b81fe4-1e9c-4f10-a808-c23f85aea5e3')
109 def test_update_port_no_info(self): 109 def test_update_port_no_info(self):
110 local_link_info = [{'switch_id': '01:23:45:67:89:AB', 110 local_link_info = [{'switch_id': '01:23:45:67:89:ab',
111 'port_id': self.ovs_port_name}] 111 'port_id': self.ovs_port_name}]
112 self._test_update_port(local_link_info) 112 self._test_update_port(local_link_info)
diff --git a/networking_ansible/ml2/mech_driver.py b/networking_ansible/ml2/mech_driver.py
index 97d65fd..39e8b4b 100644
--- a/networking_ansible/ml2/mech_driver.py
+++ b/networking_ansible/ml2/mech_driver.py
@@ -316,14 +316,14 @@ class AnsibleMechanismDriver(ml2api.MechanismDriver):
316 'binding:profile'.format(port_id=port['id']) 316 'binding:profile'.format(port_id=port['id'])
317 LOG.debug(msg) 317 LOG.debug(msg)
318 raise exceptions.LocalLinkInfoMissingException(msg) 318 raise exceptions.LocalLinkInfoMissingException(msg)
319 switch_mac = local_link_info[0].get('switch_id') 319 switch_mac = local_link_info[0].get('switch_id', '').upper()
320 switch_name = local_link_info[0].get('switch_info') 320 switch_name = local_link_info[0].get('switch_info')
321 switch_port = local_link_info[0].get('port_id') 321 switch_port = local_link_info[0].get('port_id')
322 # fill in the switch name if mac exists but name is not defined 322 # fill in the switch name if mac exists but name is not defined
323 # this provides support for introspection when the switch's mac is 323 # this provides support for introspection when the switch's mac is
324 # also provided in the ML2 conf for ansible-networking 324 # also provided in the ML2 conf for ansible-networking
325 if not switch_name and switch_mac in self.mac_map: 325 if not switch_name and switch_mac in self.mac_map:
326 switch_name = self.mac_map[switch_mac.upper()] 326 switch_name = self.mac_map[switch_mac]
327 segmentation_id = network.get('provider:segmentation_id', '') 327 segmentation_id = network.get('provider:segmentation_id', '')
328 return switch_name, switch_port, segmentation_id 328 return switch_name, switch_port, segmentation_id
329 329
diff --git a/networking_ansible/tests/unit/base.py b/networking_ansible/tests/unit/base.py
index c74b343..785e57f 100644
--- a/networking_ansible/tests/unit/base.py
+++ b/networking_ansible/tests/unit/base.py
@@ -50,7 +50,9 @@ class BaseTestCase(base.BaseTestCase):
50 50
51 self.ansconfig = config 51 self.ansconfig = config
52 self.testhost = 'testhost' 52 self.testhost = 'testhost'
53 self.testmac = '01:23:45:67:89:AB' 53 # using lowercase to ensure case sensitivity is handled correctly
54 # the code applys upper() to everything
55 self.testmac = '01:23:45:67:89:ab'
54 self.empty_inventory = {'all': {'hosts': {}}} 56 self.empty_inventory = {'all': {'hosts': {}}}
55 self.inventory = { 57 self.inventory = {
56 'all': { 58 'all': {
diff --git a/networking_ansible/tests/unit/test_config.py b/networking_ansible/tests/unit/test_config.py
index 2616fc0..c54b93d 100644
--- a/networking_ansible/tests/unit/test_config.py
+++ b/networking_ansible/tests/unit/test_config.py
@@ -26,7 +26,7 @@ class MockedConfigParser(mock.Mock):
26 self.sections = sections 26 self.sections = sections
27 27
28 def parse(self): 28 def parse(self):
29 section_data = {'ansible:testhost': {'mac': ['01:23:45:67:89:AB']}} 29 section_data = {'ansible:testhost': {'mac': ['01:23:45:67:89:ab']}}
30 if self.conffile == 'foo2': 30 if self.conffile == 'foo2':
31 section_data = { 31 section_data = {
32 'ansible:h1': {'manage_vlans': ['0']}, 32 'ansible:h1': {'manage_vlans': ['0']},
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index fa450a4..5323299 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -32,7 +32,7 @@
32 ansible:ovs_test: 32 ansible:ovs_test:
33 ansible_network_os: openvswitch 33 ansible_network_os: openvswitch
34 ansible_host: localhost 34 ansible_host: localhost
35 mac: 01:23:45:67:89:AB 35 mac: 01:23:45:67:89:ab
36 test-config: 36 test-config:
37 $TEMPEST_CONFIG: 37 $TEMPEST_CONFIG:
38 net_ansible_openvswitch: 38 net_ansible_openvswitch: