Browse Source

Update bond properties depending on DPDK status

Bond should have 'ovs' type if DPDK is enabled on it,
and 'linux' type in case of disabled DPDK.

Closes-Bug: #1566312

Change-Id: I555a603fc53deaf38d801b55631ef496ccff004b
tags/10.0.0b1
Julia Aranovich 3 years ago
parent
commit
79cb81f542

+ 1
- 1
static/translations/core.json View File

@@ -453,7 +453,7 @@
453 453
                         "physical_network": "Physical Network Name",
454 454
                         "dpdk": "DPDK",
455 455
                         "dpdk_description": "The Data Plane Development Kit (DPDK) provides high-performance packet processing libraries and user space drivers.",
456
-                        "dpdk_in_ovs_bond": "DPDK can not be disabled in OVS bond",
456
+                        "locked_dpdk_bond": "DPDK can not be enabled because not all slave interfaces support it",
457 457
                         "different_availability": "<Different Availability>",
458 458
                         "availability_tooltip": "Some network interfaces do not support this feature, therefore, these properties will not change after saving."
459 459
                     },

+ 40
- 15
static/views/cluster_page_tabs/nodes_tab_screens/edit_node_interfaces_screen.js View File

@@ -356,9 +356,7 @@ var EditNodeInterfacesScreen = React.createClass({
356 356
       var bondMode = _.flatten(
357 357
         _.pluck(this.props.bondingConfig.properties[bondType].mode, 'values')
358 358
       )[0];
359
-      bondName = this.props.interfaces.generateBondName(
360
-        bondType === 'linux' ? 'bond' : 'ovs-bond'
361
-      );
359
+      bondName = this.props.interfaces.generateBondName('bond');
362 360
 
363 361
       bond = new models.Interface({
364 362
         type: 'bond',
@@ -657,10 +655,9 @@ var EditNodeInterfacesScreen = React.createClass({
657 655
                   errors={this.state.interfacesErrors[ifcName]}
658 656
                   validate={this.validate}
659 657
                   removeInterfaceFromBond={this.removeInterfaceFromBond}
660
-                  bondingProperties={
661
-                    this.props.bondingConfig.properties[availableBondingTypes[ifcName][0]]
662
-                  }
658
+                  bondingProperties={this.props.bondingConfig.properties}
663 659
                   availableBondingTypes={availableBondingTypes[ifcName]}
660
+                  getAvailableBondingTypes={this.getAvailableBondingTypes}
664 661
                   interfaceSpeeds={interfaceSpeeds[index]}
665 662
                   interfaceNames={interfaceNames[index]}
666 663
                 />
@@ -765,10 +762,12 @@ var NodeInterface = React.createClass({
765 762
   },
766 763
   getAvailableBondingModes() {
767 764
     var {configModels, bondingProperties} = this.props;
768
-    var modes = bondingProperties.mode;
765
+    var ifc = this.props.interface;
766
+    var bondType = ifc.get('bond_properties').type__;
767
+    var modes = bondingProperties[bondType].mode;
768
+
769 769
     var availableModes = [];
770
-    var interfaces = this.props.interface.isBond() ? this.props.interface.getSlaveInterfaces() :
771
-      [this.props.interface];
770
+    var interfaces = ifc.isBond() ? ifc.getSlaveInterfaces() : [ifc];
772 771
     _.each(interfaces, (ifc) => {
773 772
       availableModes.push(_.reduce(modes, (result, modeSet) => {
774 773
         if (
@@ -784,7 +783,8 @@ var NodeInterface = React.createClass({
784 783
     return _.intersection(...availableModes);
785 784
   },
786 785
   getBondPropertyValues(propertyName, value) {
787
-    return _.flatten(_.pluck(this.props.bondingProperties[propertyName], value));
786
+    var bondType = this.props.interface.get('bond_properties').type__;
787
+    return _.flatten(_.pluck(this.props.bondingProperties[bondType][propertyName], value));
788 788
   },
789 789
   updateBondProperties(options) {
790 790
     var bondProperties = _.cloneDeep(this.props.interface.get('bond_properties')) || {};
@@ -1021,20 +1021,45 @@ var NodeInterface = React.createClass({
1021 1021
         return this.renderDPDK(errors);
1022 1022
     }
1023 1023
   },
1024
+  changeBondType(newType) {
1025
+    this.props.interface.set('bond_properties.type__', newType);
1026
+    var newMode = _.flatten(
1027
+      _.pluck(this.props.bondingProperties[newType].mode, 'values')
1028
+    )[0];
1029
+    this.bondingModeChanged(null, newMode);
1030
+  },
1024 1031
   renderDPDK(errors) {
1025 1032
     var ifc = this.props.interface;
1026
-    var isOVSBond = ifc.isBond() && ifc.get('bond_properties').type__ === 'ovs';
1033
+    var currentDPDKValue = ifc.get('interface_properties').dpdk.enabled;
1034
+    var isBond = ifc.isBond();
1035
+
1036
+    // check if DPDK can be switched
1037
+    var newBondType = isBond ?
1038
+      _.without(_.intersection(... _.compact(
1039
+        _.map(ifc.getSlaveInterfaces(), (slave) => {
1040
+          slave.get('interface_properties').dpdk.enabled = !currentDPDKValue;
1041
+          var bondTypes = this.props.getAvailableBondingTypes(slave);
1042
+          slave.get('interface_properties').dpdk.enabled = currentDPDKValue;
1043
+          return bondTypes;
1044
+        })
1045
+      )), ifc.get('bond_properties').type__)[0]
1046
+    :
1047
+      null;
1048
+
1027 1049
     return (
1028 1050
       <div className='dpdk-panel'>
1029 1051
         <div className='description'>{i18n(ns + 'dpdk_description')}</div>
1030 1052
         <Input
1031 1053
           type='checkbox'
1032 1054
           label={i18n('common.enabled')}
1033
-          checked={ifc.get('interface_properties').dpdk.enabled}
1055
+          checked={currentDPDKValue}
1034 1056
           name='dpdk.enabled'
1035
-          onChange={this.onInterfacePropertiesChange}
1036
-          disabled={this.props.locked || isOVSBond}
1037
-          tooltipText={isOVSBond && i18n(ns + 'dpdk_in_ovs_bond')}
1057
+          onChange={(propertyName, propertyValue) => {
1058
+            this.onInterfacePropertiesChange('dpdk.enabled', propertyValue);
1059
+            if (isBond) this.changeBondType(newBondType);
1060
+          }}
1061
+          disabled={this.props.locked || isBond && !newBondType}
1062
+          tooltipText={isBond && !newBondType && i18n(ns + 'locked_dpdk_bond')}
1038 1063
           wrapperClassName='dpdk-control'
1039 1064
           error={errors && errors.common}
1040 1065
         />

Loading…
Cancel
Save