[PATCH] Enable picking vnc port (#768318)
Jesse Keating
jkeating at redhat.com
Wed Aug 1 18:13:09 UTC 2012
This code allows a user to specify a vnc port for the vnc server to run
on. Passing "vncport=<port>" as a boot parameter accomplishes this.
Later we can wire it up into kickstart too.
---
anaconda | 2 ++
pyanaconda/vnc.py | 12 ++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/anaconda b/anaconda
index fc679c9..358ab80 100755
--- a/anaconda
+++ b/anaconda
@@ -240,6 +240,7 @@ def parseOptions(argv=None, cmdline=None):
op.add_option("--vnc", action="store_true", default=False)
op.add_option("--vncconnect")
op.add_option("--vncpassword", default="")
+ op.add_option("--vncport", default="5901")
op.add_option("--xdriver", dest="xdriver", action="store", type="string", default=None)
# Language
@@ -454,6 +455,7 @@ def setupDisplay(anaconda, opts):
flags.usevnc = 1
anaconda.displayMode = 'g'
vncS.password = opts.vncpassword
+ vncS.rfbport = opts.vncport
# Only consider vncconnect when vnc is a param
if opts.vncconnect:
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py
index 2f87650..2798b1f 100644
--- a/pyanaconda/vnc.py
+++ b/pyanaconda/vnc.py
@@ -51,6 +51,7 @@ class VncServer:
self.name = name
self.desktop = desktop
self.password = password
+ self.rfbport = "5901"
self.vncconnecthost = vncconnecthost
self.vncconnectport = vncconnectport
self.log_file = log_file
@@ -101,10 +102,16 @@ class VncServer:
if self.ip.find(':') != -1:
ipstr = "[%s]" % (self.ip,)
+ display = self.display
+ # We default to 5901, which is :1. But if the port is changed we can't
+ # know what the shortcut is, so display the whole port.
+ if self.rfbport != "5901":
+ display = self.rfbport
+
if (self.name is not None) and (not self.name.startswith('localhost')) and (ipstr is not None):
- self.connxinfo = "%s:%s (%s)" % (socket.getfqdn(name=self.name), self.display, ipstr,)
+ self.connxinfo = "%s:%s (%s)" % (socket.getfqdn(name=self.name), display, ipstr,)
elif ipstr is not None:
- self.connxinfo = "%s:%s" % (ipstr, self.display,)
+ self.connxinfo = "%s:%s" % (ipstr, display,)
else:
self.connxinfo = None
@@ -197,6 +204,7 @@ class VncServer:
xvnccommand = [ "Xvnc", ":%s" % self.display,
"-depth", "16", "-br",
"IdleTimeout=0", "-auth", "/dev/null", "-once",
+ "-rfbport=%s" % self.rfbport,
"DisconnectClients=false", "desktop=%s" % (self.desktop,),
"SecurityTypes=%s" % SecurityTypes, "rfbauth=%s" % rfbauth ]
--
1.7.11.2
More information about the anaconda-patches
mailing list