Browse Source

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
changes/42/635242/3
Dan Radez 4 months ago
parent
commit
6f9bb3b201

+ 1
- 1
net_ansible_tempest/tests/scenario/test_basic_ops.py View File

@@ -107,6 +107,6 @@ class TestWithOvs(base.NetAnsibleAdminBaseTest):
107 107
 
108 108
     @decorators.idempotent_id('40b81fe4-1e9c-4f10-a808-c23f85aea5e3')
109 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 111
                             'port_id': self.ovs_port_name}]
112 112
         self._test_update_port(local_link_info)

+ 2
- 2
networking_ansible/ml2/mech_driver.py View File

@@ -316,14 +316,14 @@ class AnsibleMechanismDriver(ml2api.MechanismDriver):
316 316
                   'binding:profile'.format(port_id=port['id'])
317 317
             LOG.debug(msg)
318 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 320
         switch_name = local_link_info[0].get('switch_info')
321 321
         switch_port = local_link_info[0].get('port_id')
322 322
         # fill in the switch name if mac exists but name is not defined
323 323
         # this provides support for introspection when the switch's mac is
324 324
         # also provided in the ML2 conf for ansible-networking
325 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 327
         segmentation_id = network.get('provider:segmentation_id', '')
328 328
         return switch_name, switch_port, segmentation_id
329 329
 

+ 3
- 1
networking_ansible/tests/unit/base.py View File

@@ -50,7 +50,9 @@ class BaseTestCase(base.BaseTestCase):
50 50
 
51 51
         self.ansconfig = config
52 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 56
         self.empty_inventory = {'all': {'hosts': {}}}
55 57
         self.inventory = {
56 58
             'all': {

+ 1
- 1
networking_ansible/tests/unit/test_config.py View File

@@ -26,7 +26,7 @@ class MockedConfigParser(mock.Mock):
26 26
         self.sections = sections
27 27
 
28 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 30
         if self.conffile == 'foo2':
31 31
             section_data = {
32 32
                 'ansible:h1': {'manage_vlans': ['0']},

+ 1
- 1
zuul.d/jobs.yaml View File

@@ -32,7 +32,7 @@
32 32
             ansible:ovs_test:
33 33
               ansible_network_os: openvswitch
34 34
               ansible_host: localhost
35
-              mac: 01:23:45:67:89:AB
35
+              mac: 01:23:45:67:89:ab
36 36
         test-config:
37 37
           $TEMPEST_CONFIG:
38 38
             net_ansible_openvswitch:

Loading…
Cancel
Save