Univention Bugzilla – Attachment 2910 Details for
Bug 19955
Sitzungsaufbau per Web
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Query IP-address of Session-Broker for Web-Client (Bug #19955)
19955_dvs_sb_web.diff (text/plain), 6.33 KB, created by
Philipp Hahn
on 2010-12-10 21:45 CET
(
hide
)
Description:
Query IP-address of Session-Broker for Web-Client (Bug #19955)
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2010-12-10 21:45 CET
Size:
6.33 KB
patch
obsolete
>Index: debian/control >=================================================================== >--- debian/control (Revision 21458) >+++ debian/control (Arbeitskopie) >@@ -49,7 +49,6 @@ > Alive Events while the DVS Session is open. Via HTTPS > it listens for commands issued by the Sessionbroker. > >- > Package: univention-thin-client-dvs-client > Architecture: all > Depends: rdesktop, >@@ -79,4 +78,3 @@ > Description: UCS DVS Webaccess > This package provides the Webaccess html for UCS DVS. > Primarily intended for installation on an xrdp server. >- >Index: debian/changelog >=================================================================== >--- debian/changelog (Revision 21458) >+++ debian/changelog (Arbeitskopie) >@@ -1,3 +1,9 @@ >+univention-dvs-sessionbroker (0.4.3-1) unstable; urgency=low >+ >+ * Query IP-address of Session-Broker for Web-Client (Bug #19955) >+ >+ -- Philipp Hahn <hahn@univention.de> Fri, 10 Dec 2010 21:42:00 +0100 >+ > univention-dvs-sessionbroker (0.4.2-1) unstable; urgency=low > > * add option for base64 encoded passord file (Bug #18191) >Index: univention-dvs-sessionbroker-client >=================================================================== >--- univention-dvs-sessionbroker-client (Revision 21458) >+++ univention-dvs-sessionbroker-client (Arbeitskopie) >@@ -46,8 +46,7 @@ > import gettext > import socket > import errno >-import DNS >-import random >+from univention.dvs.sessionbroker import SRV_Resolver > try: > import cPickle as pickle > except ImportError: >@@ -322,56 +321,6 @@ > conn2.close() > > >-class SRV_Resolver: >- '''DNS SRV Record Resolver''' >- >- def __init__(self, srv_record): # query entries for given SRV record from DNS >- self.servers = [] >- DNS.ParseResolvConf() >- r = DNS.Request(name=srv_record, qtype='srv') >- for record in r.req().answers: >- prio, weight, port, target = record['data'] >- self.servers.append((prio, weight, target, port)) >- >- def __iter__(self): >- return self >- >- def next(self): >- if not self.servers: # out of stock >- raise StopIteration >- >- self.servers.sort(self._serverCmp) >- minPriority = self.servers[0][0] >- >- weightIndex = zip(xrange(len(self.servers)), [x[1] for x in self.servers if x[0] == minPriority]) >- if len(weightIndex) == 1: >- index, weight = weightIndex[0] >- prio, weight, host, port = self.servers[index] >- del self.servers[index] # drop this server from the list >- return host, port >- else: >- weightSum = reduce(lambda x, y: (None, x[1]+y[1]), weightIndex, (None, 0))[1] >- offset = random.randint(0, weightSum-1) # random variable >- for index, weight in weightIndex: >- if offset < weight: # probability according to weight >- prio, weight, host, port = self.servers[index] >- del self.servers[index] # drop this server from the list >- return host, port >- offset -= weight >- >- def _serverCmp(self, a, b): # sort by prio (and weight) >- if a[0]!=b[0]: >- return cmp(a[0], b[0]) >- else: >- return cmp(a[1], b[1]) >- >- def getavailable(self): # return first available host:port >- for host, port in self: # try in order of SRV RR priority and weight >- retcode = subprocess.call(["nc", "-z", "-w1", host, '%s' % port]) >- if retcode == 0: >- return host, port >- return (None , None) # fallback for no open host:port >- > def connect_xrdp(response_dict, options): > """Print the ip of the desktop vm to stdout for xrdp .""" > print "ip: %s" % response_dict['desktop_host'] >Index: univention/dvs/sessionbroker/__init__.py >=================================================================== >--- univention/dvs/sessionbroker/__init__.py (Revision 21458) >+++ univention/dvs/sessionbroker/__init__.py (Arbeitskopie) >@@ -30,3 +30,56 @@ > # License with the Debian GNU/Linux or Univention distribution in file > # /usr/share/common-licenses/AGPL-3; if not, see > # <http://www.gnu.org/licenses/>. >+import DNS >+import random >+import subprocess >+class SRV_Resolver: >+ '''DNS SRV Record Resolver''' >+ >+ def __init__(self, srv_record): >+ """query entries for given SRV record from DNS.""" >+ self.servers = [] >+ DNS.ParseResolvConf() >+ r = DNS.Request(name=srv_record, qtype='srv') >+ for record in r.req().answers: >+ prio, weight, port, target = record['data'] >+ self.servers.append((prio, weight, target, port)) >+ >+ def __iter__(self): >+ return self >+ >+ def next(self): >+ if not self.servers: # out of stock >+ raise StopIteration >+ >+ self.servers.sort(self._serverCmp) >+ minPriority = self.servers[0][0] >+ >+ weightIndex = zip(xrange(len(self.servers)), [x[1] for x in self.servers if x[0] == minPriority]) >+ if len(weightIndex) == 1: >+ index, weight = weightIndex[0] >+ prio, weight, host, port = self.servers[index] >+ del self.servers[index] # drop this server from the list >+ return host, port >+ else: >+ weightSum = reduce(lambda x, y: (None, x[1]+y[1]), weightIndex, (None, 0))[1] >+ offset = random.randint(0, weightSum-1) # random variable >+ for index, weight in weightIndex: >+ if offset < weight: # probability according to weight >+ prio, weight, host, port = self.servers[index] >+ del self.servers[index] # drop this server from the list >+ return host, port >+ offset -= weight >+ >+ def _serverCmp(self, a, b): # sort by prio (and weight) >+ if a[0]!=b[0]: >+ return cmp(a[0], b[0]) >+ else: >+ return cmp(a[1], b[1]) >+ >+ def getavailable(self): # return first available host:port >+ for host, port in self: # try in order of SRV RR priority and weight >+ retcode = subprocess.call(["nc", "-z", "-w1", host, '%s' % port]) >+ if retcode == 0: >+ return host, port >+ return (None , None) # fallback for no open host:port >Index: conffiles/var/www/DVS/index.html >=================================================================== >--- conffiles/var/www/DVS/index.html (Revision 21458) >+++ conffiles/var/www/DVS/index.html (Arbeitskopie) >@@ -310,8 +310,14 @@ > > <!-- Column 4 --> > <td id="ServerKeyWidth" width="40%" valign="bottom"> >- <br> <input type="text" name="Server" value="@%@interfaces/eth0/address@%@" size="41" id="editServer"> >- >+ <br> <input type="text" name="Server" value="@!@ >+import sys >+from univention.dvs.sessionbroker import SRV_Resolver >+srv_record = "_dvs_sessionbroker._tcp.%(domainname)s" % baseConfig >+srv_resolver = SRV_Resolver(srv_record) >+sessionbrokerhost, port = srv_resolver.getavailable() >+sys.stdout.write("%s" % sessionbrokerhost)@!@" size="41" id="editServer"> >+@!@" size="41" id="editServer"> > </td> > </tr> > <!-- Row 2 -->
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 19955
:
2796
|
2799
|
2800
|
2836
|
2840
| 2910