From 228c5c6b5f36aaf4882016fb427a0caf43640dfc Mon Sep 17 00:00:00 2001 From: Vishnu Vardhan V Date: Sat, 23 May 2015 12:57:16 +0530 Subject: [PATCH] Related-Bug:#1455170 1)Search flows tab we gave the option to select the number of records,with maximum 5000 2)Removed the formatters and setting the formatted value in the datasource 3)Sorting the data based on the vrouter and other vrouter ips null or valid 4)Trace flow tab, instance flows limit set to 5000. Change-Id: Iebbceb56d86ce21898d3e6a307def3eda02289c5 --- .../infra/underlay/ui/js/flow_queries.js | 102 ++++++++++-------- .../underlay/ui/js/monitor_infra_underlay.js | 17 ++- .../infra/underlay/ui/views/flow_queries.view | 6 ++ webroot/reports/api/qe.api.js | 9 +- 4 files changed, 84 insertions(+), 50 deletions(-) diff --git a/webroot/monitor/infra/underlay/ui/js/flow_queries.js b/webroot/monitor/infra/underlay/ui/js/flow_queries.js index bec0b3ff5..77455b3fb 100644 --- a/webroot/monitor/infra/underlay/ui/js/flow_queries.js +++ b/webroot/monitor/infra/underlay/ui/js/flow_queries.js @@ -41,50 +41,15 @@ fsQuery['fcColumnDisplay'] = [ ]; frQuery['columnDisplay'] = [ - {select:"other_vrouter_ip", display:{id:'other_vrouter_ip', field:'other_vrouter_ip', width:150, name:"Other Virtual Router", groupable:false,formatter: - function(r, c, v, cd, dc){ - var ip = validateIPAddress(handleNull4Grid(dc['other_vrouter_ip'])) == true ? handleNull4Grid(dc['other_vrouter_ip']) : noDataStr, - retStr = '-'; - if(ip != noDataStr) { - if(null !== underlayRenderer && typeof underlayRenderer === "object") { - var vRouterDetails = underlayRenderer.getView().getvRouterVMDetails(ip,'self_ip_list',VROUTER); - retStr = contrail.format('{0} ({1})',ifNull(vRouterDetails['name'],'-'), ip); - } - } - return retStr; - } - } - }, - {select:"vrouter_ip", display:{id:'vrouter_ip', field:'vrouter_ip', width:150, name:"Virtual Router", groupable:false,formatter: - function(r, c, v, cd, dc){ - var ip = validateIPAddress(handleNull4Grid(dc['vrouter_ip'])) == true ? handleNull4Grid(dc['vrouter_ip']) : noDataStr, - retStr = '-'; - var vrouter = ifNull(dc['vrouter'],noDataStr); - if(ip != noDataStr || vrouter != noDataStr) - retStr = contrail.format('{0} ({1})',vrouter, ip); - return retStr; - } - } - }, + {select:"other_vrouter_ip", display:{id:'formattedOtherVrouter', field:'formattedOtherVrouter', width:150, name:"Other Virtual Router", groupable:false}}, + {select:"vrouter_ip", display:{id:'formattedVrouter', field:'formattedVrouter', width:150, name:"Virtual Router", groupable:false}}, {select:"protocol", display:{id:"protocol", field:"protocol", width:75, name:"Protocol", groupable:true, formatter: function(r, c, v, cd, dc){ return handleNull4Grid(getProtocolName(dc.protocol));}}}, - {select:"sourcevn", display:{id:"sourcevn", field:"sourcevn", width:125, name:"Source VN", groupable:true, formatter: - function(r, c, v, cd, dc){ - var vn = handleNull4Grid(dc.sourcevn); - return formatVN(vn); - } - } - }, + {select:"sourcevn", display:{id:"formattedSrcVN", field:"formattedSrcVN", width:125, name:"Source VN", groupable:true}}, {select:"sourceip", display:{id:"sourceip", field:"sourceip", width:90, name:"Source IP", groupable:true, formatter: function(r, c, v, cd, dc){ return ( validateIPAddress(handleNull4Grid(dc['sourceip'])) == true ? handleNull4Grid(dc['sourceip']) : noDataStr)}}}, {select:"sport", display:{id:"sport", field:"sport", width:70, name:"Source Port", groupable:true, formatter: function(r, c, v, cd, dc){ return handleNull4Grid(dc.sport);}}}, {select:"direction_ing", display:{id:"direction_ing", field:"direction_ing", width:90, name:"Direction", groupable:true, formatter: function(r, c, v, cd, dc){ return handleNull4Grid(getDirName(dc.direction_ing));}}}, - {select:"destvn", display:{id:"destvn", field:"destvn", width:125, name:"Destination VN", groupable:true, formatter: - function(r, c, v, cd, dc){ - var vn = handleNull4Grid(dc.destvn); - return formatVN(vn); - } - } - }, + {select:"destvn", display:{id:"formattedDestVN", field:"formattedDestVN", width:125, name:"Destination VN", groupable:true}}, {select:"destip", display:{id:"destip", field:"destip", width:90, name:"Destination IP", groupable:true, formatter: function(r, c, v, cd, dc){ return (validateIPAddress(handleNull4Grid(dc['destip'])) == true ? handleNull4Grid(dc['destip']) : noDataStr)}}}, {select:"dport", display:{id:"dport", field:"dport", width:70, name:"Destination Port", groupable:true, formatter: function(r, c, v, cd, dc){ return handleNull4Grid(dc.dport);}}}, {select:"agg-bytes", display:{id:'agg-bytes', field:'agg-bytes', width:120, name:"Bytes/Packets", groupable:false,formatter: function(r, c, v, cd, dc) {return contrail.format("{0}/{1}",formatBytes(dc['agg-bytes'],'-'),dc['agg-packets']);}}}, @@ -737,7 +702,7 @@ function runFRQuery() { //validator = initValidateDate("fr"), queryPrefix = 'fr', options = getFRDefaultOptions(), - columnDisplay, selectArray, queryId; + columnDisplay, selectArray,limit = defaultUnderlayFlowLimit; //if ($("#" + queryPrefix + "-query-form").valid()) { //collapseWidget('#fr-query-widget'); collapseWidget('#fr-query-widget'); @@ -762,8 +727,14 @@ function runFRQuery() { $("#"+queryPrefix+"-results").data('endTimeUTC', option['toTime']); $("#"+queryPrefix+"-results").data('startTimeUTC',option['fromTime']); } - reqQueryObj.select = "other_vrouter_ip,agg-bytes,agg-packets", - reqQueryObj.excludeInSelect = ['UuidKey', 'action', 'sg_rule_uuid', 'nw_ace_uuid','underlay_proto', 'underlay_source_port'], + var limitDropdown = $('#fr-limit').data('contrailDropdown'); + var selected = limitDropdown.getSelectedData()[0]; + if(selected != null && selected['text'] != null) { + limit = selected['text'] + } + reqQueryObj.select = "other_vrouter_ip,agg-bytes,agg-packets"; + reqQueryObj.excludeInSelect = ['UuidKey', 'action', 'sg_rule_uuid', 'nw_ace_uuid','underlay_proto', 'underlay_source_port']; + reqQueryObj.filters = "limit:"+limit; reqQueryObj.engQueryStr = getEngQueryStr(reqQueryObj); loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay); //} @@ -871,6 +842,10 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD type: 'error', iconClasses: 'icon-warning', text: 'Error in fetching details' + },timeout: { + type: 'timeout', + iconClasses: 'icon-warning', + text: 'Timeout in fetching details' //need to change the message to something like specify query } } }, @@ -949,20 +924,57 @@ function loadFlowResultsForUnderlay(options, reqQueryObj, columnDisplay, fcGridD gridObject = $("#"+options.elementId).data('contrailGrid'); $.ajax({ url:url+'?'+$.param(reqQueryObj), + timeout:1000 * 60 * 10,//10 mins }).done(function(response){ if(reqQueryObj['startAt'] != null && underlayLastInteracted > reqQueryObj['startAt']) return; $("#" + options.elementId).find('.grid-header-icon-loading').hide(); - dataView.setData(response['data']); + var computeNodes = getValueByJsonPath(globalObj,'topologyResponse;vRouterList',[]); + $.each(ifNull(response['data'],[]),function (idx,obj) { + var formattedVrouter,formattedOtherVrouter,formattedSrcVN,formattedDestVN; + var vRouterIp = validateIPAddress(handleNull4Grid(obj['vrouter_ip'])) == true ? handleNull4Grid(obj['vrouter_ip']) : noDataStr, + formattedVrouter = noDataStr; + var vrouter = ifNull(obj['vrouter'],noDataStr); + if(vRouterIp != noDataStr || vrouter != noDataStr) + formattedVrouter = contrail.format('{0} ({1})',vrouter, vRouterIp); + var othervRouterIp = validateIPAddress(handleNull4Grid(obj['other_vrouter_ip'])) == true ? handleNull4Grid(obj['other_vrouter_ip']) : noDataStr, + formattedOtherVrouter = noDataStr; + if(othervRouterIp != noDataStr) { + $.each(computeNodes,function(idx,obj){ + var ipList = getValueByJsonPath(obj,'more_attributes;VrouterAgent;self_ip_list',[]); + if(ipList.indexOf(othervRouterIp) > -1) + formattedOtherVrouter = contrail.format('{0} ({1})',ifNull(obj['name'],noDataStr), othervRouterIp); + }); + } + var formattedSrcVN = handleNull4Grid(obj['sourcevn']); + formattedSrcVN = formatVN(formattedSrcVN); + var formattedDestVN = handleNull4Grid(obj['destvn']); + formattedDestVN = formatVN(formattedSrcVN); + obj['formattedVrouter'] = formattedVrouter; + obj['formattedOtherVrouter'] = formattedOtherVrouter; + obj['formattedSrcVN'] = formattedSrcVN[0]; + obj['formattedDestVN'] = formattedDestVN[0]; + }); + var sortedData = response['data'].sort(function(dataItem1,dataItem2){ + if(dataItem1['vrouter_ip'] != null) + return -1; + else + return 1; + }); + dataView.setData(sortedData); if(response['data'].length == 0 && gridObject != null) { gridObject.showGridMessage('empty'); } - }).fail(function(error){ + }).fail(function(error,status){ if(reqQueryObj['startAt'] != null && underlayLastInteracted > reqQueryObj['startAt']) return; $("#" + options.elementId).find('.grid-header-icon-loading').hide(); if(gridObject != null) { - gridObject.showGridMessage('error'); + if(status == 'timeout') { + gridObject.showGridMessage('timeout'); + } else { + gridObject.showGridMessage('error'); + } } }); $("#" + options.elementId).find('input.headerRowCheckbox').parent('span').remove(); diff --git a/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js b/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js index 806f76008..f98732b8f 100644 --- a/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js +++ b/webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js @@ -3,7 +3,6 @@ * * Underlay Overlay Visualisation Page */ - var underlayRenderer = new underlayRenderer(); var PROUTER_DBL_CLICK = 'config_net_vn'; var PROUTER = 'physical-router'; @@ -12,6 +11,7 @@ var VIRTUALMACHINE = 'virtual-machine'; var timeout; var expanded = true; var underlayLastInteracted; +var defaultUnderlayFlowLimit = 5000; function underlayRenderer() { this.load = function(obj) { this.configTemplate = Handlebars.compile($("#visualization-template").html()); @@ -2061,6 +2061,14 @@ underlayView.prototype.renderFlowRecords = function() { queries['fr'].queryViewModel.isCustomTRVisible(false); ko.applyBindings(queries.fr.queryViewModel, document.getElementById('fr-query')); whereClauseStr = this.updateWhereClause(); + $("#fr-limit").contrailDropdown({ + dataTextField:'text', + dataValueField:'value', + }); + var limitDropdown = $("#fr-limit").data('contrailDropdown'); + var dropdownData = [{value:500,text:'500'},{value:1000,text:'1000'},{value:2500,text:'2500'},{value:5000,text:'5000'}]; + limitDropdown.setData(dropdownData); + $("#fr-limit").select2('val','5000'); } } /* @@ -2462,10 +2470,11 @@ underlayView.prototype.renderTracePath = function(options) { select: 'agg-bytes,agg-packets,vrouter_ip,other_vrouter_ip', fromTimeUTC: 'now-300s', toTimeUTC: 'now', - queryId: randomUUID(), - async: true, - table:'FlowRecordTable', startAt: new Date().getTime(), + async: false, + table:'FlowRecordTable', + filters : "limit:"+defaultUnderlayFlowLimit + }; var vmData = instMap[name]; var intfData = getValueByJsonPath(vmData,'more_attributes;interface_list',[]); diff --git a/webroot/monitor/infra/underlay/ui/views/flow_queries.view b/webroot/monitor/infra/underlay/ui/views/flow_queries.view index 643f27c5c..51915c77e 100644 --- a/webroot/monitor/infra/underlay/ui/views/flow_queries.view +++ b/webroot/monitor/infra/underlay/ui/views/flow_queries.view @@ -542,6 +542,12 @@ +
+ +
+ +
+
diff --git a/webroot/reports/api/qe.api.js b/webroot/reports/api/qe.api.js index be5cf6634..f98c97403 100644 --- a/webroot/reports/api/qe.api.js +++ b/webroot/reports/api/qe.api.js @@ -664,14 +664,18 @@ function parseStatsQuery(reqQuery) function parseFRQuery(reqQuery) { - var select, where, fromTimeUTC, toTimeUTC, frQuery, table, direction; + var select, where, fromTimeUTC, toTimeUTC, frQuery, table, direction,filters; table = reqQuery['table']; frQuery = getQueryJSON4Table(table); fromTimeUTC = reqQuery['fromTimeUTC']; toTimeUTC = reqQuery['toTimeUTC']; select = reqQuery['select']; where = reqQuery['where']; + filters = reqQuery['filters']; direction = parseInt(reqQuery['direction']); + if(reqQuery['limit'] != null) { + frQuery['limit'] = reqQuery['limit']; + } setMicroTimeRange(frQuery, fromTimeUTC, toTimeUTC); if (select != "") { parseSelect(frQuery, select); @@ -680,6 +684,9 @@ function parseFRQuery(reqQuery) if (direction >= 0) { frQuery['dir'] = direction; } + if(filters != null) { + parseFSFilter(frQuery, filters); + } return frQuery; };