Skip to content

Commit

Permalink
Merge "ECMP hashing is done in port page."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 27, 2016
2 parents 06c9095 + 4e89a63 commit c791d0c
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
52 changes: 51 additions & 1 deletion webroot/config/networking/port/ui/js/models/portModel.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -558,6 +582,7 @@ define([
portBindingCollection.remove(delPortBinding);
}
},

//Binding value disable
enableDisablePortBindingValue: function(portBindingModel, mode) {
portBindingModel.disablePortBindValue = ko.computed((function() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
36 changes: 35 additions & 1 deletion webroot/config/networking/port/ui/js/views/portEditView.js
Expand Up @@ -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',
Expand Down
16 changes: 16 additions & 0 deletions webroot/config/networking/port/ui/js/views/portFormatters.js
Expand Up @@ -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 = "";
Expand Down
11 changes: 11 additions & 0 deletions webroot/config/networking/port/ui/js/views/portGridView.js
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit c791d0c

Please sign in to comment.