Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
CA-12870: Product name to include Citrix
Browse files Browse the repository at this point in the history
CA-12869: Include hostname in title bar
CA-12777: Map licence names to OEM names
  • Loading branch information
Andy Southgate committed Jan 22, 2008
1 parent 1db69e3 commit 9c2fd17
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
4 changes: 4 additions & 0 deletions XSConsoleConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def FTPName(self):
def FTPServer(self):
return self.ftpserver

def BrandingMap(self):
return {}


# Import a more specific configuration if available
if os.path.isfile(sys.path[0]+'/XSConsoleConfigOEM.py'):
import XSConsoleConfigOEM
Expand Down
18 changes: 18 additions & 0 deletions XSConsoleLang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
# trademarks of Citrix Systems, Inc., in the United States and other
# countries.

from XSConsoleConfig import *

import XenAPI # For XenAPI.Failure


# Global function
def Lang(inLabel, inPad = 0):
retStr = Language.ToString(inLabel)
Expand All @@ -15,6 +18,17 @@ def Lang(inLabel, inPad = 0):
return retStr

class Language:
instance = None

def __init__(self):
self.brandingMap = Config.Inst().BrandingMap()

@classmethod
def Inst(self):
if self.instance is None:
self.instance = Language()
return self.instance

@classmethod
def Quantity(cls, inText, inNumber):
if inNumber == 1:
Expand Down Expand Up @@ -64,3 +78,7 @@ def ReflowText(cls, inText, inWidth):
text = text[lineLength+1:] # Split at space or return so discard

return retArray

def Branding(self, inText):
# Return either the value in the hash or (if not present) the unchanged parameter
return self.brandingMap.get(inText, inText)
4 changes: 2 additions & 2 deletions XSConsoleRemoteDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
oldPath = sys.path

# Local shared_db_util.py overrides system copy
sys.path = ['.', '/opt/xensource/sm'] + sys.path
if os.path.isfile(sys.path[0]+'/shared_db_util.py') or os.path.isfile(sys.path[1]+'/shared_db_util.py'):
sys.path = ['/opt/xensource/sm'] + sys.path
if os.path.isfile(sys.path[0]+'/shared_db_util.py'):
try:
import shared_db_util
except Exception, e:
Expand Down
6 changes: 3 additions & 3 deletions XSConsoleRootDialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def UpdateFieldsSTATUS(self, inPane):
inPane.AddWrappedTextField(data.dmi.system_manufacturer())
inPane.AddWrappedTextField(data.dmi.system_product_name())
inPane.NewLine()
inPane.AddWrappedTextField(data.host.software_version.product_brand() + ' ' +
inPane.AddWrappedTextField(Language.Inst().Branding(data.host.software_version.product_brand()) + ' ' +
data.derived.fullversion())
inPane.NewLine()
inPane.AddTitleField(Lang("Management Network Parameters"))
Expand Down Expand Up @@ -126,7 +126,7 @@ def UpdateFieldsXENSERVER(self, inPane):
data = Data.Inst()

inPane.AddTitleField(Lang("XenServer Product Information"))
inPane.AddStatusField(Lang("Name", 16), str(data.host.software_version.product_brand()))
inPane.AddStatusField(Lang("Name", 16), Language.Inst().Branding((data.host.software_version.product_brand())))
inPane.AddStatusField(Lang("Version", 16), str(data.derived.fullversion()))
inPane.AddStatusField(Lang("Xen Version", 16), str(data.host.software_version.xen()))
inPane.AddStatusField(Lang("Kernel Version",16), str(data.host.software_version.linux()))
Expand All @@ -142,7 +142,7 @@ def UpdateFieldsLICENCE(self, inPane):
expiryStr = expiryStr[0:4]+'-'+expiryStr[4:6]+'-'+expiryStr[6:8]

inPane.AddTitleField(Lang("License"))
inPane.AddStatusField(Lang("Product SKU", 16), str(data.host.license_params.sku_type()))
inPane.AddStatusField(Lang("Product SKU", 16), str(Language.Inst().Branding(data.host.license_params.sku_type())))
inPane.AddStatusField(Lang("Expiry", 16), expiryStr)
inPane.AddStatusField(Lang("Sockets", 16), str(data.host.license_params.sockets()))
inPane.NewLine()
Expand Down
19 changes: 10 additions & 9 deletions XSConsoleTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def MainLoop(self):
startSeconds = time.time()
lastDataUpdateSeconds = startSeconds
resized = False
data = Data.Inst()

self.layout.DoUpdate()
while not doQuit:
Expand Down Expand Up @@ -157,11 +158,11 @@ def MainLoop(self):
secondsNow = time.time()
secondsRunning = secondsNow - startSeconds

if Data.Inst().host.address('') == '':
if data.host.address('') == '':
# If the host doesn't yet have an IP, reload data occasionally to pick up DHCP updates
if secondsNow - lastDataUpdateSeconds >= 4:
lastDataUpdateSeconds = secondsNow
Data.Inst().Update()
data.Update()
self.layout.UpdateRootFields()
needsRefresh = True

Expand All @@ -175,26 +176,26 @@ def MainLoop(self):
self.layout.TopDialogue().Reset()
needsRefresh = True
elif gotKey == 'KEY_F(5)':
Data.Inst().Update()
data.Update()
self.layout.UpdateRootFields()
needsRefresh = True

if self.layout.ExitCommand() is not None:
doQuit = True

bannerStr = Language.Inst().Branding(data.host.software_version.product_brand('')) + ' ' + data.host.software_version.product_version('')

if Auth.Inst().IsAuthenticated():
bannerStr = Lang('User')+': '+Auth.Inst().LoggedInUsername()
# Testing: bannerStr += ' ('+str(int(Auth.Inst().AuthAge()))+')'
hostStr = Auth.Inst().LoggedInUsername()+'@'+data.host.name_label('')
else:
data = Data.Inst()
bannerStr = data.host.software_version.product_brand('') + ' ' + data.host.software_version.product_version('')
hostStr = data.host.name_label('')

# Testing
# if gotKey is not None:
# bannerStr = gotKey

timeStr = time.strftime("%H:%M:%S", time.localtime())
statusLine = "%-70s%10.10s" % (bannerStr ,timeStr)
timeStr = time.strftime(" %H:%M:%S ", time.localtime())
statusLine = ("%-35s%10.10s%35.35s" % (bannerStr[:35], timeStr[:10], hostStr[:35]))
self.renderer.RenderStatus(self.layout.Window(Layout.WIN_TOPLINE), statusLine)

if needsRefresh:
Expand Down

0 comments on commit 9c2fd17

Please sign in to comment.