Browse Source

Merge "Fix Mellanox ConnectX-4 serializer with bonding"

tags/fuel8_cx5
Jenkins 2 years ago
parent
commit
fc918d5ce2
1 changed files with 63 additions and 45 deletions
  1. 63
    45
      deployment_scripts/mellanox_settings.py

+ 63
- 45
deployment_scripts/mellanox_settings.py View File

@@ -90,11 +90,22 @@ class MellanoxSettings(object):
90 90
         mlnx = cls.get_mlnx_section()
91 91
         for network_type, ifc_dict in mlnx_interfaces.iteritems():
92 92
             if 'driver' in ifc_dict and network_type in ['private','management','storage']:
93
-              drivers.append(ifc_dict['driver'])
94
-              interfaces.append(ifc_dict['interface'])
93
+              
94
+              # The bond interfaces extend the original list,
95
+              # otherwise, the interface is appended to the list.
96
+              if(type(ifc_dict['driver']) is list):
97
+                  drivers.extend(ifc_dict['driver'])
98
+              else:
99
+                  drivers.append(ifc_dict['driver'])
100
+
101
+              if(type(ifc_dict['interface']) is list):
102
+                  interfaces.extend(ifc_dict['interface'])
103
+              else:
104
+                  interfaces.append(ifc_dict['interface'])
95 105
 
96 106
         drivers_set = list(set(drivers))
97 107
         interfaces_set = list(set(interfaces))
108
+
98 109
         if (len(drivers_set) > 1):
99 110
              logging.error("Multiple ConnectX adapters was found in this environment.")
100 111
              raise MellanoxSettingsException(
@@ -288,6 +299,10 @@ class MellanoxSettings(object):
288 299
     def is_iser_enabled(cls):
289 300
         return cls.get_mlnx_section()['iser']
290 301
 
302
+    @classmethod
303
+    def is_sriov_enabled(cls):
304
+        return cls.get_mlnx_section()['sriov']
305
+
291 306
     @classmethod
292 307
     def is_vxlan_offloading_enabled(cls):
293 308
         return cls.get_mlnx_section()['vxlan_offloading']
@@ -434,49 +449,52 @@ class MellanoxSettings(object):
434 449
 
435 450
             # Map networks to interfaces
436 451
             for transformation in transformations:
437
-                if transformation['action'] == 'add-port' or \
438
-                    transformation['action'] == 'add-bond':
439
-                    if transformation['bridge'] == 'br-fw-admin':
440
-                        network_type = 'admin'
441
-                    elif transformation['bridge'] == 'br-ex':
442
-                        network_type = 'public'
443
-                    elif transformation['bridge'] == 'br-aux' or \
444
-                        transformation['bridge'] == 'br-mesh':
445
-                        network_type = 'private'
446
-                    elif transformation['bridge'] == 'br-mgmt':
447
-                        network_type = 'management'
448
-                    elif transformation['bridge'] == 'br-storage':
449
-                        network_type = 'storage'
450
-                    elif transformation['bridge'] == 'br-baremetal':
451
-                        network_type = 'baremetal'
452
-
453
-                    network_interface = {}
454
-                    network_interface['bridge'] = transformation['bridge']
455
-
456
-                    # Split to iface name and VLAN
457
-                    iface_split = transformation['name'].split('.')
458
-                    if len(iface_split)==1:
459
-                        iface_split.append(str(1))
460
-                    interface, vlan = iface_split
461
-                    network_interface['interface'] = interface
462
-                    network_interface['vlan'] = vlan
463
-
464
-                    # If bond
465
-                    if 'bonds' in cls.data and interface in cls.data['bonds']:
466
-                        network_interface['driver'] = \
467
-                            cls.data['bonds'][interface]['driver']
468
-                        if network_type == 'private':
469
-
470
-                            # Assign SR-IOV to the first port only
471
-                            network_interface['interface'] = \
472
-                                cls.data['bonds'][interface]['interfaces'][0]
473
-                        else:
474
-                            network_interface['interface'] = \
475
-                                cls.data['bonds'][interface]['interfaces']
476
-                    else: # Not a bond
477
-                        network_interface['driver'] = \
478
-                            interfaces[interface]['vendor_specific']['driver']
479
-                    dict_of_interfaces[network_type] = network_interface
452
+                if 'bridge' in transformation.keys() and \
453
+                    (transformation['action'] == 'add-port' or \
454
+                    transformation['action'] == 'add-bond'):
455
+                     if transformation['bridge'] == 'br-fw-admin':
456
+                         network_type = 'admin'
457
+                     elif transformation['bridge'] == 'br-ex':
458
+                         network_type = 'public'
459
+                     elif transformation['bridge'] == 'br-aux' or \
460
+                         transformation['bridge'] == 'br-mesh':
461
+                         network_type = 'private'
462
+                     elif transformation['bridge'] == 'br-mgmt':
463
+                         network_type = 'management'
464
+                     elif transformation['bridge'] == 'br-storage':
465
+                         network_type = 'storage'
466
+                     elif transformation['bridge'] == 'br-baremetal':
467
+                         network_type = 'baremetal'
468
+
469
+                     network_interface = {}
470
+                     network_interface['bridge'] = transformation['bridge']
471
+
472
+                     # Split to iface name and VLAN
473
+                     iface_split = transformation['name'].split('.')
474
+                     if len(iface_split)==1:
475
+                         iface_split.append(str(1))
476
+                     interface, vlan = iface_split
477
+                     network_interface['interface'] = interface
478
+                     network_interface['vlan'] = vlan
479
+
480
+                     # If bond
481
+                     if 'bonds' in cls.data and interface in cls.data['bonds']:
482
+                         network_interface['driver'] = \
483
+                             cls.data['bonds'][interface]['driver']
484
+                         if ( network_type == 'private' and cls.is_sriov_enabled() ) or \
485
+                             ( network_type == 'storage' and cls.is_iser_enabled() ):
486
+                             
487
+                             # Assign SR-IOV/ISER to the first port only.
488
+                             # This is a temporary workaround until supporing bond over VFs.
489
+                             # We sort the array of interfaces in order to get the first
490
+                             # interface on all nodes.
491
+                             if_list = cls.data['bonds'][interface]['interfaces']
492
+                             if_list.sort()
493
+                             network_interface['interface'] = if_list[0]
494
+                     else: # Not a bond
495
+                         network_interface['driver'] = \
496
+                             interfaces[interface]['vendor_specific']['driver']
497
+                     dict_of_interfaces[network_type] = network_interface
480 498
 
481 499
             # Set private network in case private and storage on the same port
482 500
             if 'private' not in dict_of_interfaces.keys() and \

Loading…
Cancel
Save