Commit 3e12c248 by Tomas Hlavacek

Add graph error message on empty output

Add error message to BGP graph generation code to inform user that the graph can not be generated out of the know data.
parent 24203e8a
......@@ -64,6 +64,8 @@ STRING_PEERID = "Peer ID"
STRING_RTABLE = "Routing Table"
STRING_DETAILS = "Details of"
STRING_UNKNOWN = "(unknown)"
STRING_BGP_GRAPH='BGP graph'
STRING_BGP_GRAPH_ERROR='Error: Can not produce image out of the received output.'
# URL generator functions
def getASNURL(asn):
......
......@@ -184,13 +184,14 @@ class Session(object):
# TODO
return decorator_helper.pre(self.getResult())
else:
result = self.getResult()
if(result):
dr = self.getCommand().decorateResult(self,decorator_helper)
dr = self.getCommand().decorateResult(self,decorator_helper)
if(dr):
self.resultlines = dr[1]
return dr[0]
else:
return None
self.resultlines = 0
return ''
def appendResult(self,result_fragment):
fn = Session.getSessionOutputFileName(self.sessionid)
......
......@@ -28,9 +28,6 @@ import defaults
import ulgmodel
import ulggraph
STRING_BGP_GRAPH='BGP graph'
STRING_BGP_GRAPH_ERROR='Error: Can not produce image out of the received output.'
IPV46_SUBNET_REGEXP = '^[0-9a-fA-F:\.]+(/[0-9]{1,2}){0,1}$'
RTNAME_REGEXP = '^[a-zA-Z0-9]+$'
STRING_SYMBOL_ROUTING_TABLE = 'routing table'
......@@ -361,9 +358,9 @@ class BirdGraphShowRouteAll(ulgmodel.TextCommand):
def decorateResult(self,session,decorator_helper=None):
if(session.isFinished()):
if(session.getData() != None) and (session.getData() != []):
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),STRING_BGP_GRAPH),1)
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),defaults.STRING_BGP_GRAPH),1)
else:
return (STRING_BGP_GRAPH_ERROR, 1)
return (decorator_helper.pre(defaults.STRING_BGP_GRAPH_ERROR), 1)
else:
return ('',0)
......
......@@ -30,8 +30,6 @@ import ulgmodel
import ulggraph
# module globals
STRING_BGP_GRAPH='BGP graph'
STRING_BGP_GRAPH_ERROR='Error: Can not produce image out of the received output.'
STRING_EXPECT_SSH_NEWKEY='Are you sure you want to continue connecting'
STRING_EXPECT_PASSWORD='(P|p)assword:'
STRING_EXPECT_SHELL_PROMPT_REGEXP = '\n[a-zA-Z0-9\._-]+>'
......@@ -598,12 +596,17 @@ class CiscoCommandGraphShowBgpIPv46Uni(ulgmodel.TextCommand):
name=name)
def decorateResult(self,session,decorator_helper=None):
ulgmodel.debug("IN BGP GRAPH decorateResult")
if(session.isFinished()):
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.isFinished=TRUE")
if(session.getData() != None) and (session.getData() != []):
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),STRING_BGP_GRAPH),1)
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.getData checked OK")
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),defaults.STRING_BGP_GRAPH),1)
else:
return (STRING_BGP_GRAPH_ERROR, 1)
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.getData checked failed, producing error")
return (decorator_helper.pre(defaults.STRING_BGP_GRAPH_ERROR), 1)
else:
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.isFinished=FALSE")
return ('',0)
def finishHook(self,session):
......
......@@ -29,8 +29,6 @@ import ulgmodel
import ulggraph
JUNIPER_GRAPH_SH_ROUTE = "Graph show route <IP subnet>"
STRING_BGP_GRAPH='BGP graph'
STRING_BGP_GRAPH_ERROR='Error: Can not produce image out of the received output.'
IPV46_SUBNET_REGEXP = '^[0-9a-fA-F:\.]+(/[0-9]{1,2}){0,1}$'
......@@ -168,9 +166,9 @@ class JuniperGraphShowRoute(ulgmodel.TextCommand):
def decorateResult(self,session,decorator_helper=None):
if(session.isFinished()):
if(session.getData() != None) and (session.getData() != []):
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),STRING_BGP_GRAPH),1)
return (decorator_helper.img(decorator_helper.getSpecialContentURL(session.getSessionId()),defaults.STRING_BGP_GRAPH),1)
else:
return (STRING_BGP_GRAPH_ERROR, 1)
return (decorator_helper.pre(defaults.STRING_BGP_GRAPH_ERROR), 1)
else:
return ('',0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment