Skip to content

Commit

Permalink
Changes for issue "Need to get peers list via remote for peer's dropd…
Browse files Browse the repository at this point in the history
…own"

Fixed below issues as well
1)Need to get peers list via remote for peer's dropdown instead of deriving the
data from landing page data source
2)Remove Filter out data for peer's dropdown when we go for next row
3)Have Peers are repeated validation
4)No Peer message should not come for cn when bgp_mesh is on
5)Hide bgpass-server and client info in monitor --> infra --> Control Nodes

Change-Id: I45e1244516878f2c2d8e4236b6ed4ac53ffec279
Closes-bug: #1546902
  • Loading branch information
sbavanasi committed Feb 18, 2016
1 parent 2c4b6be commit 3d69752
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 63 deletions.
16 changes: 12 additions & 4 deletions webroot/config/infra/bgp/ui/js/bgpConfigTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/

define(['underscore'], function(_){
define(['underscore', 'config/infra/bgp/ui/js/bgpFormatters'],
function(_, BGPFormatters){
var bgpFormatters = new BGPFormatters();
var bgpConfigTemplates = function() {
var self = this;
self.advancedOptions = function(disableId) {
Expand Down Expand Up @@ -164,7 +166,7 @@ define(['underscore'], function(_){
}
];
};
self.peerSelection = function() {
self.peerSelection = function(bgpName) {
return [{
elementId : 'peer_selection_accordian',
view : 'AccordianView',
Expand Down Expand Up @@ -214,13 +216,19 @@ define(['underscore'], function(_){
path: "peerName",
dataBindValue: "peerName()",
width: 150,
dataBindOptionList : "peerDataSource()",
templateId:
cowc.TMPL_EDITABLE_GRID_DROPDOWN_VIEW,
elementConfig: {
placeholder: "Select Peer",
dataTextField: "name",
dataValueField: "uuid"
dataValueField: "uuid",
dataSource: {
type: "remote",
url: ctwc.URL_GET_BGP,
parse: function(result) {
return bgpFormatters.availablePeers(result, bgpName);
}
}
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions webroot/config/infra/bgp/ui/js/bgpFormatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ define(['underscore'], function(_){
self.availablePeers = function(data, currentBGP) {
var peers = [];
for(var i = 0; i < data.length; i++) {
var row = data[i];
var row = data[i]["bgp-router"];
if(currentBGP && currentBGP === row.name) {
continue;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ define(['underscore'], function(_){
adminState = adminDown ? "False" : "True";
}
return adminState;
}
};
};
return bgpFormatters;
});
44 changes: 18 additions & 26 deletions webroot/config/infra/bgp/ui/js/models/bgpModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ define([
var selectedPeers = ifNull(modelConfig['bgp_router_refs'],[]),
peerModels = [], peerModel,
peerCollectionModel;
var availablePeers = window.bgp != null &&
window.bgp.availablePeers != null ?
window.bgp.availablePeers : [];
if(selectedPeers.length > 0) {
for(var i = 0; i < selectedPeers.length; i++) {
var currentPeer = selectedPeers[i];
Expand Down Expand Up @@ -141,8 +138,7 @@ define([
currentPeer.bgp_router_parameters.autonomous_system,*/
family_attributes: familyAttrs,
user_created_auth_key_type : null,
user_created_auth_key: null,
peerDataSource: availablePeers
user_created_auth_key: null
});
self.subscribePeerModelChangeEvents(peerModel);
peerModels.push(peerModel)
Expand Down Expand Up @@ -177,24 +173,6 @@ define([
addPeer: function() {
var peers = this.model().attributes['peers'],
peersArry = peers.toJSON();
var filteredPeers = [], peerUUIDS = [];
var newPeer;
var avlPeers = window.bgp.availablePeers;
if(peersArry.length) {
_.each(peersArry, function(peer) {
peerUUIDS.push(peer.peerName());
});
_.each(avlPeers, function(peer) {
if($.inArray(peer.uuid, peerUUIDS) === -1) {
filteredPeers.push(peer);
}
});
if(!filteredPeers.length) {
return;
}
} else {
filteredPeers = avlPeers;
}
newPeer = new BGPPeersModel({
peerName : null,
disabled: false,
Expand All @@ -205,9 +183,7 @@ define([
loop_count : null,
family_attributes: [],
user_created_auth_key_type : null,
user_created_auth_key: null,
peerDataSource: filteredPeers

user_created_auth_key: null
});
this.subscribePeerModelChangeEvents(newPeer);
kbValidation.bind(this.editView,
Expand Down Expand Up @@ -510,6 +486,22 @@ define([
if(!value) {
return "At least one Address Family is required";
}
},
"peers" : function(value, attr, finalObj) {
var peersArray = finalObj.peers.toJSON();
var peers = [], sortedPeers, sortedPeerCnt, i;
if(peersArray) {
_.each(peersArray, function(item){
peers.push(item.peerName());
});
sortedPeers = peers.sort();
sortedPeerCnt = sortedPeers.length;
for(i = 0; i < sortedPeerCnt; i++){
if(sortedPeers[i] === sortedPeers[i + 1]){
return "Peers are repeated";
}
}
}
}
}
},
Expand Down
41 changes: 20 additions & 21 deletions webroot/config/infra/bgp/ui/js/models/bgpPeersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ define([
'passive' : false,
'hold_time' : null,
'loop_count' : null,
'family_attributes': [],
'peerDataSource': [],
'family_attributes': []
},
formatModelConfig: function(modelConfig){
//populate auth data
Expand Down Expand Up @@ -63,8 +62,6 @@ define([
addFamilyAttrs: function(root, index) {
var familyAttrs = root.model().attributes.peers.toJSON()[index()].
model().attributes.family_attrs;
var familyAttrsArry = familyAttrs.toJSON();
var filteredFamilyAttrs = [], selFamilyAttrNames = [];
var newFamilyAttr;
var avlFamilyAttrs = ctwc.FAMILY_ATTR_ADDRESS_FAMILY_DATA;
if(root.model().attributes.user_created_router_type ===
Expand All @@ -73,27 +70,12 @@ define([
return familyAttr.text !== "erm-vpn";
});
}
if(familyAttrsArry.length) {
_.each(familyAttrsArry, function(familyAttr){
selFamilyAttrNames.push(familyAttr.address_family());
});
_.each(avlFamilyAttrs, function(familyAttr){
if($.inArray(familyAttr.value, selFamilyAttrNames) === -1) {
filteredFamilyAttrs.push(familyAttr);
}
});
if(!filteredFamilyAttrs.length) {
return;
}
} else {
filteredFamilyAttrs = avlFamilyAttrs;
}
newFamilyAttr = new BGPFamilyAttrsModel(
{
address_family: null,
loop_count: null,
prefix_limit: null,
familyAttrDataSource: filteredFamilyAttrs,
familyAttrDataSource: avlFamilyAttrs,
disableFamilyAttr : false
}
);
Expand Down Expand Up @@ -154,7 +136,24 @@ define([
return "Enter Loop count between 0 - 16 "
}
}
}
},
"family_attrs" : function(value, attr, finalObj) {
var familyAttrsArray = finalObj.family_attrs.toJSON();
var familyAttrs = [], sortedFamilyAttrs,
sortedFamilyAttrsCnt, i;
if(familyAttrsArray) {
_.each(familyAttrsArray, function(item){
familyAttrs.push(item.address_family());
});
sortedFamilyAttrs = familyAttrs.sort();
sortedFamilyAttrsCnt = sortedFamilyAttrs.length;
for(i = 0; i < sortedFamilyAttrsCnt; i++){
if(sortedFamilyAttrs[i] === sortedFamilyAttrs[i + 1]){
return "Family Attributes are repeated";
}
}
}
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions webroot/config/infra/bgp/ui/js/views/bgpEditView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define([
'title': options['title'], 'body': editLayout,
'onSave': function () {
if((!self.model.isAutoMeshEnabled() ||
self.model.user_created_router_type !== ctwl.CONTROL_NODE_TYPE) &&
self.model.user_created_router_type() !== ctwl.CONTROL_NODE_TYPE) &&
self.model.getPeers(self.model.model().attributes).length === 0) {
var confTemplate = contrail.getTemplate4Id("controller-bgp-peer-conf-form-template");
var confTempLayout = confTemplate();
Expand Down Expand Up @@ -299,7 +299,7 @@ define([
},
{
columns :
bgpConfigTemplates.peerSelection()
bgpConfigTemplates.peerSelection(self.model.name())
}

]
Expand Down
8 changes: 0 additions & 8 deletions webroot/config/infra/bgp/ui/js/views/bgpGridView.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ define([
var dataItem =
$('#' + ctwl.BGP_GRID_ID).data("contrailGrid").
_dataView.getItem(rowIndex);
window.bgp = window.bgp || {};
window.bgp.availablePeers =
bgpFormatters.availablePeers($('#' + ctwl.BGP_GRID_ID).
data("contrailGrid")._dataView.getItems(), dataItem['name']);
var bgpModel = new BGPModel(dataItem),
checkedRow = dataItem,
title =
Expand Down Expand Up @@ -199,10 +195,6 @@ define([
"title" : ctwl.TITLE_ADD_BGP,
"iconClass" : "icon-plus",
"onClick" : function() {
window.bgp = window.bgp || {};
window.bgp.availablePeers =
bgpFormatters.availablePeers($('#' + ctwl.BGP_GRID_ID).
data("contrailGrid")._dataView.getItems());
var bgpModel = new BGPModel();
subscribeModelChangeEvents(bgpModel);
bgpEditView.model = bgpModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ define(
var retArr = [];
$.each(result,function(idx,d) {
var obj = {};
var routerType = getValueByJsonPath(d,
"value;ConfigData;bgp-router;bgp_router_parameters;router_type",
null);
if($.inArray(routerType, ctwc.BGP_AAS_ROUTERS) !== -1) {
return true;
}
obj['x'] = parseFloat(jsonPath(d,'$.value.ControlCpuState.cpu_info[0].cpu_share')[0]);
//Info:Need to specify the processname explictly
//for which we need res memory && Convert to MB
Expand Down

0 comments on commit 3d69752

Please sign in to comment.