From 4e89a63d4fcb6de0acb0195d7dd3479ec45c30f0 Mon Sep 17 00:00:00 2001 From: balamurugang Date: Wed, 27 Jan 2016 19:51:24 +0530 Subject: [PATCH] ECMP hashing is done in port page. ECMP Hashing is done in ports page. Related-Bug: #1532667 Change-Id: Ifa1c9825cfa36d80c4575e2b4a7ec4d1f7636d46 --- .../networking/port/ui/js/models/portModel.js | 52 ++++++++++++++++++- .../port/ui/js/views/portEditView.js | 36 ++++++++++++- .../port/ui/js/views/portFormatters.js | 16 ++++++ .../port/ui/js/views/portGridView.js | 11 ++++ 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/webroot/config/networking/port/ui/js/models/portModel.js b/webroot/config/networking/port/ui/js/models/portModel.js index bcc9b18a5..fdcac66d7 100644 --- a/webroot/config/networking/port/ui/js/models/portModel.js +++ b/webroot/config/networking/port/ui/js/models/portModel.js @@ -70,7 +70,16 @@ define([ 'subInterfaceVMIValue':'', 'templateGeneratorData': 'rawData', 'disable_sub_interface' : false, - 'subnetGroupVisible': true + 'subnetGroupVisible': true, + 'ecmp_hashing_include_fields': { + 'source_mac': true, + 'destination_mac': true, + 'source_ip': true, + 'destination_ip': true, + 'ip_protocol': true, + 'source_port': true, + 'destination_port': true + } }, setVNData: function(allNetworks) { self.allNetworks = allNetworks; @@ -229,6 +238,21 @@ define([ modelConfig['staticRoute'].push(SRVal); } } + + //Modal config default ECMP formatting + var ecmpHashIncFields = []; + if ('ecmp_hashing_include_fields' in modelConfig) { + var ecmpHashIncFieldsObj = + modelConfig['ecmp_hashing_include_fields']; + for (var key in ecmpHashIncFieldsObj) { + if (true == ecmpHashIncFieldsObj[key]) { + ecmpHashIncFields.push(key); + } + } + } + modelConfig['ecmp_hashing_include_fields'] = + ecmpHashIncFields.join(','); + //Modal config default Fat Flow option formatting var fatFlows = []; var fatFlowList = @@ -558,6 +582,7 @@ define([ portBindingCollection.remove(delPortBinding); } }, + //Binding value disable enableDisablePortBindingValue: function(portBindingModel, mode) { portBindingModel.disablePortBindValue = ko.computed((function() { @@ -580,6 +605,12 @@ define([ }), portBindingModel); }, + getNonDefaultECMPHashingFields: function() { + return { 'source_mac': false, 'destination_mac': false, + 'source_ip': false, 'destination_ip': false, + 'ip_protocol': false, 'source_port': false, + 'destination_port': false}; + }, groupBy: function(array, f) { var groups = {}; array.forEach( function(o) { @@ -813,6 +844,24 @@ define([ } else { newPortData.interface_route_table_refs = []; } + /* ECMP Hashing */ + var ecmpHashIncFields = this.getNonDefaultECMPHashingFields(); + if (null != newPortData['ecmp_hashing_include_fields']) { + var tmpEcmpHashIncFields = + newPortData['ecmp_hashing_include_fields'].split(','); + var cnt = tmpEcmpHashIncFields.length; + for (var i = 0; i < cnt; i++) { + if (tmpEcmpHashIncFields[i].length > 0) { + ecmpHashIncFields[tmpEcmpHashIncFields[i]] = true; + } + } + } else { + for (key in ecmpHashIncFields) { + ecmpHashIncFields[key] = true; + } + } + newPortData['ecmp_hashing_include_fields'] + = ecmpHashIncFields; /* Fixed IP*/ var allFixedIPCollectionValue = newPortData["fixedIPCollection"].toJSON(); @@ -1015,6 +1064,7 @@ define([ delete(newPortData.disablePort); delete(newPortData.disable_sub_interface); delete(newPortData.subnetGroupVisible); + delete(newPortData.disablePort); if("parent_href" in newPortData) { delete(newPortData.parent_href); } diff --git a/webroot/config/networking/port/ui/js/views/portEditView.js b/webroot/config/networking/port/ui/js/views/portEditView.js index e191f33e6..fe282c8ad 100644 --- a/webroot/config/networking/port/ui/js/views/portEditView.js +++ b/webroot/config/networking/port/ui/js/views/portEditView.js @@ -567,7 +567,41 @@ define([ } } }] - },{ + }, { + columns: [ + { + elementId: 'ecmpHashingIncFields', + view: 'FormMultiselectView', + viewConfig: { + label: 'ECMP Hashing', + path: 'ecmp_hashing_include_fields', + class: 'span12', + dataBindValue: + 'ecmp_hashing_include_fields', + elementConfig: { + dataTextField: "text", + dataValueField: "id", + data: [ + {text: 'source-mac', + id: 'source_mac'}, + {text: 'destination-mac', + id: 'destination_mac'}, + {text: 'source-ip', + id: 'source_ip'}, + {text: 'destination-ip', + id: 'destination_ip'}, + {text: 'ip-protocol', + id: 'ip_protocol'}, + {text: 'source-port', + id: 'source_port'}, + {text: 'destination-port', + id: 'destination_port'} + ] + } + } + } + ] + }, { columns: [{ elementId: 'fatFlowCollection', view: 'FormEditableGridView', diff --git a/webroot/config/networking/port/ui/js/views/portFormatters.js b/webroot/config/networking/port/ui/js/views/portFormatters.js index ca80dc9f8..5fa006c78 100644 --- a/webroot/config/networking/port/ui/js/views/portFormatters.js +++ b/webroot/config/networking/port/ui/js/views/portFormatters.js @@ -236,6 +236,22 @@ define([ } return staticRout; }; + //Grid column expand label: Static Routes// + this.ECMPHashingFormatter = function(d, c, v, cd, dc) { + var ecmp = getValueByJsonPath(dc, "ecmp_hashing_include_fields", ""), + dispStr = '-'; + fields = []; + for (var key in ecmp) { + if (true == ecmp[key]) { + key = key.replace('_', '-'); + fields.push(key); + } + } + if (fields.length > 0) { + return fields.join(', '); + } + return dispStr; + }; //Grid column expand label: Fat Flow// this.FatFlowFormatter = function(d, c, v, cd, dc) { var fatFlow = ""; diff --git a/webroot/config/networking/port/ui/js/views/portGridView.js b/webroot/config/networking/port/ui/js/views/portGridView.js index 1887c6a0c..9f1059aa2 100644 --- a/webroot/config/networking/port/ui/js/views/portGridView.js +++ b/webroot/config/networking/port/ui/js/views/portGridView.js @@ -408,6 +408,14 @@ define([ templateGeneratorConfig:{ formatter: "staticRoutFormatter" } + }, { + key: 'id_perms', + name:"id_perms", + label:"ECMP Hashing", + templateGenerator: 'TextGenerator', + templateGeneratorConfig:{ + formatter: "ECMPHashingFormatter" + } }, { key: 'virtual_machine_interface_fat_flow_protocols', name:"virtual_machine_interface_fat_flow_protocols", @@ -519,6 +527,9 @@ define([ this.staticRoutFormatter = function(v, dc) { return portFormatters.staticRoutFormatter("", "", v, "", dc); }; + this.ECMPHashingFormatter = function(v, dc) { + return portFormatters.ECMPHashingFormatter("", "", v, "", dc); + }; this.AAPFormatter = function(v, dc) { return portFormatters.AAPFormatter("", "", v, "", dc); };