Update tooltips info for IOS and IOU devices.

This commit is contained in:
grossmj
2014-04-09 15:19:08 -06:00
parent 0cdd12b554
commit 8386609ee1
3 changed files with 77 additions and 73 deletions

View File

@@ -21,9 +21,14 @@ import sys
import logging
import traceback
import time
from gns3.version import __version__
try:
from gns3.qt import QtCore, QtGui, DEFAULT_BINDING
except ImportError:
raise RuntimeError("Can't import Qt modules: Qt and/or PyQt is probably not installed correctly...")
from gns3.main_window import MainWindow
from gns3.qt import QtGui
from gns3.version import __version__
def main():
@@ -59,11 +64,6 @@ def main():
elif sys.version_info[0] == 3 and sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or higher is required")
try:
from gns3.qt import QtCore, DEFAULT_BINDING
except ImportError:
raise RuntimeError("Can't import Qt modules, Python binding is probably not installed...")
version = lambda version_string: [int(i) for i in version_string.split('.')]
if version(QtCore.QT_VERSION_STR) < version("4.6"):

View File

@@ -718,68 +718,61 @@ class Router(Node):
:returns: formated string
"""
if self.status() == Node.started:
state = "started"
elif self.status() == Node.suspended:
state = "suspended"
else:
state = "stopped"
platform = self._settings["platform"]
router_specific_info = ""
if platform == "c7200":
router_specific_info = self._settings["midplane"] + " " + self._settings["npe"]
router_specific_info = "{midplane} {npe}".format(midplane=self._settings["midplane"],
npe=self._settings["npe"])
router_specific_info = router_specific_info.upper()
#get info about image and ghostios
image_info = '\n Image is '
# if self.ghost_status == 2:
# #we are running on ghost IOS
# image_info = image_info + 'shared ' + self.ghost_file
# else:
image_info = image_info + self._settings["image"]
jitsharing_group_info = ' JIT blocks sharing group is '
# get info about JIT sharing
jitsharing_group_info = "No JIT blocks sharing enabled"
if self._settings["jit_sharing_group"] != None:
jitsharing_group_info = jitsharing_group_info + str(self._settings["jit_sharing_group"])
else:
jitsharing_group_info = ' No JIT blocks sharing enabled'
jitsharing_group_info = "JIT blocks sharing group is {group}".format(group=str(self._settings["jit_sharing_group"]))
#get info about idle-pc value
idlepc_info = ""
if not self._settings["idlepc"]:
idlepc_info = ' with no idlepc value'
else:
idlepc_info = ' with idlepc value of ' + self._settings["idlepc"]# + '\n idlemax value is ' + str(self.idlemax) + ', idlesleep is ' + str(self.idlesleep) + ' ms'
# get info about idle-pc
idlepc_info = "with no idlepc value"
if self._settings["idlepc"]:
idlepc_info = "with idlepc value of {idlepc}, idlemax of {idlemax} and idlesleep of {idlesleep} ms".format(idlepc=self._settings["idlepc"],
idlemax=self._settings["idlemax"],
idlesleep=self._settings["idlesleep"])
info = """Router {name} [id={id}] is {state}
Hardware is Dynamips emulated Cisco {platform} {specific_info} with {ram} MB RAM and {nvram} KB NVRAM
Device uptime is unknown
Router's server runs on {host}:{port}, console is on port {console}, aux is on port {aux}
Image is {image_name}
{idlepc_info}
{jitsharing_group_info}
{disk0} MB disk0 size, {disk1} MB disk1 size
""".format(name=self.name(),
id=self._router_id,
state=state,
platform=platform,
specific_info=router_specific_info,
ram=str(self._settings["ram"]),
nvram=str(self._settings["nvram"]),
host=self._server.host,
port=str(self._server.port),
console=str(self._settings["console"]),
aux=str(self._settings["aux"]),
image_name=os.path.basename(self._settings["image"]),
idlepc_info=idlepc_info,
jitsharing_group_info=jitsharing_group_info,
disk0=str(self._settings["disk0"]),
disk1=str(self._settings["disk1"]))
#gather information about PA, their interfaces and connections
slot_info = self._slot_info()
# # Uptime of the router.
# def utimetotxt(utime):
# (zmin, zsec) = divmod(utime, 60)
# (zhur, zmin) = divmod(zmin, 60)
# (zday, zhur) = divmod(zhur, 24)
# utxt = ('%d %s, ' % (zday, 'days' if (zday != 1) else 'day') if (zday > 0) else '') + \
# ('%d %s, ' % (zhur, 'hours' if (zhur != 1) else 'hour') if ((zhur > 0) or (zday > 0)) else '') + \
# ('%d %s' % (zmin, 'mins' if (zmin != 1) else 'min'))
# return utxt
#
# if (self.state == 'running'):
# txtuptime = ' Router running time is ' + utimetotxt((int(time.time()) - self.starttime) - self.waittime) + '\n'
# elif (self.state == 'suspended'):
# txtuptime = ' Router suspended time is ' + utimetotxt(int(time.time()) - self.suspendtime) + '\n'
# elif (self.state == 'stopped'):
# txtuptime = ' Router stopped time is ' + utimetotxt(int(time.time()) - self.stoptime) + '\n'
# else:
txtuptime = ' Router uptime is unknown\n'
if self.status() == Node.started:
self.state = "started"
elif self.status() == Node.suspended:
self.state = "suspended"
else:
self.state = "stopped"
#create final output, with proper indentation
return 'Router ' + self.name() + ' is ' + self.state + '\n' + ' Hardware is Dynamips emulated Cisco ' + platform + router_specific_info + ' with ' + \
str(self._settings["ram"]) + ' MB RAM\n' + txtuptime + ' Router\'s server runs on ' + self._server.host + ":" + str(self._server.port) + \
', console is on port ' + str(self._settings["console"]) + ', aux is on port ' + str(self._settings["aux"]) + image_info + idlepc_info + '\n' + \
jitsharing_group_info + '\n ' + str(self._settings["nvram"]) + ' KB NVRAM, ' + str(self._settings["disk0"]) + \
' MB disk0 size, ' + str(self._settings["disk1"]) + ' MB disk1 size' + '\n' + slot_info
return info + slot_info
def dump(self):
"""

View File

@@ -430,27 +430,38 @@ class IOUDevice(Node):
:returns: formated string
"""
image_info = '\n Image is '
image_info = image_info + os.path.basename(self._settings["path"])
txtuptime = ' Device uptime is unknown\n'
if self.status() == Node.started:
self.state = "started"
state = "started"
else:
self.state = "stopped"
state = "stopped"
port_info = " {} Ethernet adapters and {} serial adapters\n".format(self._settings["ethernet_adapters"], self._settings["serial_adapters"])
info = """Device {name} [id={id}] is {state}
Hardware is Cisco IOU generic device with {ram} MB RAM and {nvram} KB NVRAM
Device uptime is unknown
Router's server runs on {host}:{port}, console is on port {console}
Image is {image_name}
{nb_ethernet} Ethernet adapters and {nb_serial} serial adapters
""".format(name=self.name(),
id=self._iou_id,
state=state,
ram=str(self._settings["ram"]),
nvram=str(self._settings["nvram"]),
host=self._server.host,
port=str(self._server.port),
console=str(self._settings["console"]),
image_name=os.path.basename(self._settings["path"]),
nb_ethernet=self._settings["ethernet_adapters"],
nb_serial=self._settings["serial_adapters"])
port_info = ""
for port in self._ports:
if port.isFree():
port_info += ' ' + port.name() + ' is empty\n'
port_info += " {port_name} is empty\n".format(port_name=port.name())
else:
port_info += ' ' + port.name() + ' ' + port.description() + '\n'
port_info += " {port_name} {port_description}\n".format(port_name=port.name(),
port_description=port.description())
#create final output, with proper indentation
return 'Device ' + self.name() + ' is ' + self.state + '\n' + ' Hardware is Cisco IOU generic device with ' + \
str(self._settings["ram"]) + ' MB RAM and ' + str(self._settings["nvram"]) + ' KB NVRAM\n' + txtuptime + ' Router\'s server runs on ' + self._server.host + ":" + str(self._server.port) + \
', console is on port ' + str(self._settings["console"]) + image_info + '\n' + port_info
return info + port_info
def dump(self):
"""