Commit 3e12c248 authored by Tomas Hlavacek's avatar 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" ...@@ -64,6 +64,8 @@ STRING_PEERID = "Peer ID"
STRING_RTABLE = "Routing Table" STRING_RTABLE = "Routing Table"
STRING_DETAILS = "Details of" STRING_DETAILS = "Details of"
STRING_UNKNOWN = "(unknown)" 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 # URL generator functions
def getASNURL(asn): def getASNURL(asn):
......
...@@ -184,13 +184,14 @@ class Session(object): ...@@ -184,13 +184,14 @@ class Session(object):
# TODO # TODO
return decorator_helper.pre(self.getResult()) return decorator_helper.pre(self.getResult())
else: else:
result = self.getResult() dr = self.getCommand().decorateResult(self,decorator_helper)
if(result):
dr = self.getCommand().decorateResult(self,decorator_helper) if(dr):
self.resultlines = dr[1] self.resultlines = dr[1]
return dr[0] return dr[0]
else: else:
return None self.resultlines = 0
return ''
def appendResult(self,result_fragment): def appendResult(self,result_fragment):
fn = Session.getSessionOutputFileName(self.sessionid) fn = Session.getSessionOutputFileName(self.sessionid)
......
...@@ -28,9 +28,6 @@ import defaults ...@@ -28,9 +28,6 @@ import defaults
import ulgmodel import ulgmodel
import ulggraph 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}$' IPV46_SUBNET_REGEXP = '^[0-9a-fA-F:\.]+(/[0-9]{1,2}){0,1}$'
RTNAME_REGEXP = '^[a-zA-Z0-9]+$' RTNAME_REGEXP = '^[a-zA-Z0-9]+$'
STRING_SYMBOL_ROUTING_TABLE = 'routing table' STRING_SYMBOL_ROUTING_TABLE = 'routing table'
...@@ -361,9 +358,9 @@ class BirdGraphShowRouteAll(ulgmodel.TextCommand): ...@@ -361,9 +358,9 @@ class BirdGraphShowRouteAll(ulgmodel.TextCommand):
def decorateResult(self,session,decorator_helper=None): def decorateResult(self,session,decorator_helper=None):
if(session.isFinished()): if(session.isFinished()):
if(session.getData() != None) and (session.getData() != []): 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: else:
return (STRING_BGP_GRAPH_ERROR, 1) return (decorator_helper.pre(defaults.STRING_BGP_GRAPH_ERROR), 1)
else: else:
return ('',0) return ('',0)
......
...@@ -30,8 +30,6 @@ import ulgmodel ...@@ -30,8 +30,6 @@ import ulgmodel
import ulggraph import ulggraph
# module globals # 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_SSH_NEWKEY='Are you sure you want to continue connecting'
STRING_EXPECT_PASSWORD='(P|p)assword:' STRING_EXPECT_PASSWORD='(P|p)assword:'
STRING_EXPECT_SHELL_PROMPT_REGEXP = '\n[a-zA-Z0-9\._-]+>' STRING_EXPECT_SHELL_PROMPT_REGEXP = '\n[a-zA-Z0-9\._-]+>'
...@@ -598,12 +596,17 @@ class CiscoCommandGraphShowBgpIPv46Uni(ulgmodel.TextCommand): ...@@ -598,12 +596,17 @@ class CiscoCommandGraphShowBgpIPv46Uni(ulgmodel.TextCommand):
name=name) name=name)
def decorateResult(self,session,decorator_helper=None): def decorateResult(self,session,decorator_helper=None):
ulgmodel.debug("IN BGP GRAPH decorateResult")
if(session.isFinished()): if(session.isFinished()):
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.isFinished=TRUE")
if(session.getData() != None) and (session.getData() != []): 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: 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: else:
ulgmodel.debug("IN BGP GRAPH decorateResult -> session.isFinished=FALSE")
return ('',0) return ('',0)
def finishHook(self,session): def finishHook(self,session):
......
...@@ -29,8 +29,6 @@ import ulgmodel ...@@ -29,8 +29,6 @@ import ulgmodel
import ulggraph import ulggraph
JUNIPER_GRAPH_SH_ROUTE = "Graph show route <IP subnet>" 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}$' IPV46_SUBNET_REGEXP = '^[0-9a-fA-F:\.]+(/[0-9]{1,2}){0,1}$'
...@@ -168,9 +166,9 @@ class JuniperGraphShowRoute(ulgmodel.TextCommand): ...@@ -168,9 +166,9 @@ class JuniperGraphShowRoute(ulgmodel.TextCommand):
def decorateResult(self,session,decorator_helper=None): def decorateResult(self,session,decorator_helper=None):
if(session.isFinished()): if(session.isFinished()):
if(session.getData() != None) and (session.getData() != []): 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: else:
return (STRING_BGP_GRAPH_ERROR, 1) return (decorator_helper.pre(defaults.STRING_BGP_GRAPH_ERROR), 1)
else: else:
return ('',0) 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