diff --git a/webroot/config/infra/bgp/ui/js/bgpConfigTemplates.js b/webroot/config/infra/bgp/ui/js/bgpConfigTemplates.js index e6ed419f5..c21c111c0 100644 --- a/webroot/config/infra/bgp/ui/js/bgpConfigTemplates.js +++ b/webroot/config/infra/bgp/ui/js/bgpConfigTemplates.js @@ -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) { @@ -164,7 +166,7 @@ define(['underscore'], function(_){ } ]; }; - self.peerSelection = function() { + self.peerSelection = function(bgpName) { return [{ elementId : 'peer_selection_accordian', view : 'AccordianView', @@ -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); + } + } } } }, diff --git a/webroot/config/infra/bgp/ui/js/bgpFormatters.js b/webroot/config/infra/bgp/ui/js/bgpFormatters.js index 554795c7f..4ec764449 100644 --- a/webroot/config/infra/bgp/ui/js/bgpFormatters.js +++ b/webroot/config/infra/bgp/ui/js/bgpFormatters.js @@ -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; } @@ -194,7 +194,7 @@ define(['underscore'], function(_){ adminState = adminDown ? "False" : "True"; } return adminState; - } + }; }; return bgpFormatters; }); diff --git a/webroot/config/infra/bgp/ui/js/models/bgpModel.js b/webroot/config/infra/bgp/ui/js/models/bgpModel.js index 9af01e0ed..fbb14d606 100644 --- a/webroot/config/infra/bgp/ui/js/models/bgpModel.js +++ b/webroot/config/infra/bgp/ui/js/models/bgpModel.js @@ -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]; @@ -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) @@ -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, @@ -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, @@ -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"; + } + } + } } } }, diff --git a/webroot/config/infra/bgp/ui/js/models/bgpPeersModel.js b/webroot/config/infra/bgp/ui/js/models/bgpPeersModel.js index 6576f0fda..e2fd7836b 100644 --- a/webroot/config/infra/bgp/ui/js/models/bgpPeersModel.js +++ b/webroot/config/infra/bgp/ui/js/models/bgpPeersModel.js @@ -20,8 +20,7 @@ define([ 'passive' : false, 'hold_time' : null, 'loop_count' : null, - 'family_attributes': [], - 'peerDataSource': [], + 'family_attributes': [] }, formatModelConfig: function(modelConfig){ //populate auth data @@ -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 === @@ -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 } ); @@ -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"; + } + } + } + } } } }); diff --git a/webroot/config/infra/bgp/ui/js/views/bgpEditView.js b/webroot/config/infra/bgp/ui/js/views/bgpEditView.js index 85a8ccca9..b9f1fa3cc 100644 --- a/webroot/config/infra/bgp/ui/js/views/bgpEditView.js +++ b/webroot/config/infra/bgp/ui/js/views/bgpEditView.js @@ -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(); @@ -299,7 +299,7 @@ define([ }, { columns : - bgpConfigTemplates.peerSelection() + bgpConfigTemplates.peerSelection(self.model.name()) } ] diff --git a/webroot/config/infra/bgp/ui/js/views/bgpGridView.js b/webroot/config/infra/bgp/ui/js/views/bgpGridView.js index e3e460079..d6b3d9b8c 100644 --- a/webroot/config/infra/bgp/ui/js/views/bgpGridView.js +++ b/webroot/config/infra/bgp/ui/js/views/bgpGridView.js @@ -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 = @@ -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; diff --git a/webroot/monitor/infrastructure/common/ui/js/utils/monitor.infra.parsers.js b/webroot/monitor/infrastructure/common/ui/js/utils/monitor.infra.parsers.js index 6406734ec..1111094aa 100644 --- a/webroot/monitor/infrastructure/common/ui/js/utils/monitor.infra.parsers.js +++ b/webroot/monitor/infrastructure/common/ui/js/utils/monitor.infra.parsers.js @@ -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