Skip to content

Commit

Permalink
Merge "Related-Bug:#1443458 Adding the nodes which are missing in con…
Browse files Browse the repository at this point in the history
…fig server and opserver to topology with red color and corresponding message in tooltip" into R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 8, 2015
2 parents 7559024 + fd96e93 commit 861d4fb
Showing 1 changed file with 111 additions and 12 deletions.
123 changes: 111 additions & 12 deletions webroot/monitor/infra/underlay/ui/js/monitor_infra_underlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ underlayModel.prototype.getNodes = function() {
return this.nodes;
}

underlayModel.prototype.getUVEMissingNodes = function() {
return this.uveMissingNodes;
}

underlayModel.prototype.getConfigMissingNodes = function() {
return this.configMissingNodes;
}

underlayModel.prototype.getLinks = function() {
return this.links;
}
Expand Down Expand Up @@ -312,6 +320,24 @@ underlayModel.prototype.setNodes = function(nodes) {
}
}

underlayModel.prototype.setUVEMissingNodes = function(errorNodes) {
if(null !== errorNodes && typeof errorNodes !== "undefined" &&
errorNodes.length > 0) {
this.uveMissingNodes = errorNodes;
} else {
this.uveMissingNodes = [];
}
}

underlayModel.prototype.setConfigMissingNodes = function(errorNodes) {
if(null !== errorNodes && typeof errorNodes !== "undefined" &&
errorNodes.length > 0) {
this.configMissingNodes = errorNodes;
} else {
this.configMissingNodes = [];
}
}

underlayModel.prototype.setLinks = function(links) {
if(null !== links && typeof links !== "undefined" &&
links.length > 0) {
Expand Down Expand Up @@ -647,9 +673,30 @@ underlayView.prototype.addElementsToGraph = function(els) {
this.getPaper().fitToContent();
}
this.initTooltipConfig();
if(typeof underlayRenderer === 'object') {
var uveMissingNodes = underlayRenderer.getModel().getUVEMissingNodes();
var configMissingNodes = underlayRenderer.getModel().getConfigMissingNodes();
var errorNodes = uveMissingNodes.concat(configMissingNodes);
this.markErrorNodes(errorNodes);
}
}


underlayView.prototype.markErrorNodes = function(nodes) {
var elementMap = this.getElementMap();
var elementMapNodes = ifNull(elementMap['nodes'],{});
if(!$.isArray(nodes)) {
nodes = [nodes]
}
var nodesLen = nodes.length;
for (var i = 0; i < nodesLen; i++) {
if(elementMapNodes[nodes[i]] != null) {
$('div.font-element[font-element-model-id="' + elementMapNodes[nodes[i]] + '"]')
.find('i')
.css("color", '#b94a48');
}
}
}

underlayView.prototype.DGPrepare = function(prop, propObj, adjList, stopAt) {
if ( typeof prop === "undefined" || null === prop ||
{} === prop || false === prop)
Expand Down Expand Up @@ -972,24 +1019,31 @@ underlayView.prototype.initTooltipConfig = function() {
content: function(element, graph) {
var viewElement = _this.getGraph().getCell(element.attr('model-id'));
var tooltipContent = contrail.getTemplate4Id('tooltip-content-template');

var tooltipLblValues = [];
var ifLength = 0;
if(viewElement.attributes && viewElement.attributes.hasOwnProperty('nodeDetails') &&
viewElement.attributes.nodeDetails.hasOwnProperty('more_attributes') &&
viewElement.attributes.nodeDetails.more_attributes.hasOwnProperty('ifTable') &&
viewElement.attributes.nodeDetails.more_attributes.ifTable.length) {
ifLength = viewElement.attributes.nodeDetails.more_attributes.ifTable.length;
}
return tooltipContent([
{
lbl:'Name',
value: viewElement.attributes.nodeDetails['name']
},
{
tooltipLblValues.push({
lbl:'Name',
value: viewElement.attributes.nodeDetails['name']
});
var nodeDetails = getValueByJsonPath(viewElement,'attributes;nodeDetails',{});
if(nodeDetails['errorMsg'] != null) {
tooltipLblValues.push({
lbl:'Events',
value: nodeDetails['errorMsg']
});
} else {
tooltipLblValues.push({
lbl:'Interfaces',
value: ifLength
}
]);
});
}
return tooltipContent(tooltipLblValues);
}
},
VirtualMachine: {
Expand Down Expand Up @@ -1334,6 +1388,11 @@ underlayView.prototype.clearHighlightedConnectedElements = function() {
.css("opacity", "")
.css("fill", "")
.css("stroke", "");
if(typeof underlayRenderer === 'object') {
var errorNodes = underlayRenderer.getModel().getUVEMissingNodes()
.concat(underlayRenderer.getModel().getConfigMissingNodes());
this.markErrorNodes(errorNodes);
}
}

underlayView.prototype.initGraphEvents = function() {
Expand Down Expand Up @@ -2364,6 +2423,7 @@ underlayView.prototype.renderTracePath = function(options) {
doTraceFlow(postData);
});
}

function doTraceFlow (postData) {
$.ajax({
url:'/api/tenant/networking/trace-flow',
Expand Down Expand Up @@ -2452,7 +2512,6 @@ underlayView.prototype.renderTracePath = function(options) {
doReverseFlow(postData);
});
}

function doReverseFlow (postData) {
$.ajax({
url:'/api/tenant/networking/trace-flow',
Expand Down Expand Up @@ -3080,12 +3139,52 @@ underlayController.prototype.getModelData = function(cfg) {
});
globalObj['topologyResponse']['VMList'] = virtualMachineList;
globalObj['topologyResponse']['vRouterList'] = vRouterList;
_this.getModel().setNodes(response['nodes']);
//Adding the config missing and uve missing nodes to topology
var nodes = ifNull(response['nodes'],[]),errorNodes = [];
var configMissingNodes = getValueByJsonPath(response,'errors;configNotFound',[]);
var configMissingLen = configMissingNodes.length;
var uveMissingNodes = getValueByJsonPath(response,'errors;uveNotFound',[]);
var uveMissingLen = uveMissingNodes.length;
for(var i = 0; i < configMissingLen; i++) {
errorNodes.push(configMissingNodes[i]);
var nodeObj = {
name:configMissingNodes[i],
node_type: "physical-router",
chassis_type: "coreswitch",
more_attributes: {},
errorMsg:'Configuration Unavailable'
}
nodes.push(nodeObj);
}
for(var i = 0; i < uveMissingLen; i++) {
errorNodes.push(uveMissingNodes[i]);
var nodeObj = {
name:uveMissingNodes[i],
node_type: "physical-router",
chassis_type: "coreswitch",
more_attributes: {},
errorMsg:'System Information Unavailable'
}
nodes.push(nodeObj);
}
_this.getModel().setNodes(nodes);
_this.getModel().setLinks(response['links']);
_this.getModel().setUVEMissingNodes(uveMissingNodes);
_this.getModel().setConfigMissingNodes(configMissingNodes);
_this.getModel().updateChassisType(response['nodes']);
_this.getModel().categorizeNodes(response['nodes']);
_this.getModel().formTree();
_this.getView().renderTopology(response);
var elementMap = _this.getView().getElementMap();
var errorNodesLen = errorNodes.length;
for(var i = 0; i < errorNodesLen; i++) {
var nodes = ifNull(elementMap['nodes'],{});
if (nodes[errorNodes[i]] != null ) {
$('div.font-element[font-element-model-id="' + nodes[errorNodes[i]] + '"]')
.find('i')
.css('color','#b94a48');
}
}
}
function showEmptyInfo(container) {
$("#"+container).html('<div class="display-nonodes">No Physical Devices found</div>');
Expand Down

0 comments on commit 861d4fb

Please sign in to comment.