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 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 # . +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 @@ -
   - +
   +@!@" size="41" id="editServer">