Univention Bugzilla – Attachment 5539 Details for
Bug 33008
Nobody calls ldap_available.sh anymore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
ldap_available.sh in Python
300xx_uss-ldap-check.diff (text/plain), 6.93 KB, created by
Philipp Hahn
on 2013-10-29 20:19:33 CET
(
hide
)
Description:
ldap_available.sh in Python
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2013-10-29 20:19:33 CET
Size:
6.93 KB
patch
obsolete
>diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/util.py b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/util.py >index 81e54a5..721dd21 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/util.py >+++ b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/umc/python/setup/util.py >@@ -46,6 +46,7 @@ import psutil > import csv > import imp > import os.path >+import socket > > from univention.lib.i18n import Translation > from univention.management.console.log import MODULE >@@ -96,9 +97,11 @@ UCR_VARIABLES = [ > 'ssl/organization', 'ssl/organizationalunit', 'ssl/email', > ] > >+ > def timestamp(): > return time.strftime('%Y-%m-%d %H:%M:%S') > >+ > def load_values(): > # load UCR variables > ucr.load() >@@ -128,6 +131,7 @@ def load_values(): > > return values > >+ > def _xkeymap(keymap): > '''Determine the x-keymap which belongs to 'keymap' by > parsing /lib/univention-installer/locale/all-kmaps''' >@@ -176,10 +180,6 @@ def pre_save(newValues): > installComponents = list(allComponents & (selectedComponents - currentComponents)) > newValues['packages_install'] = ' '.join([ i.replace(':', ' ') for i in installComponents ]) > >-# if 'locale' in newValues: >-# # js returns locale as list >-# newValues['locale'] = ' '.join(newValues['locale']) >- > if 'locale/keymap' in newValues: > xkeymap = _xkeymap(newValues['locale/keymap']) > if xkeymap: >@@ -196,6 +196,7 @@ def write_profile(values): > finally: > os.umask(old_umask) > >+ > class ProgressState( object ): > def __init__( self ): > self.reset() >@@ -225,6 +226,7 @@ class ProgressState( object ): > def __nonzero__( self ): > return bool( self.name or self.message or self.percentage or self._join_error or self._misc_error ) > >+ > class ProgressParser( object ): > # regular expressions > NAME = re.compile( '^__NAME__: *(?P<key>[^ ]*) (?P<name>.*)\n$' ) >@@ -339,6 +341,7 @@ class ProgressParser( object ): > > return False > >+ > def sorted_files_in_subdirs( directory ): > for entry in sorted(os.listdir(directory)): > path = os.path.join(directory, entry) >@@ -346,12 +349,29 @@ def sorted_files_in_subdirs( directory ): > for filename in sorted(os.listdir(path)): > yield os.path.join(path, filename) > >+ >+LDAP_STATE_FILE = "/var/run/univention-system-setup.ldap" >+def check_ldap_access(): >+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >+ sock.settimeout(10) >+ try: >+ sock.connect((ucr["ldap/master"], 7389)) >+ value = "ldap" >+ except socket.error: >+ value = "no-ldap" >+ sock.close() >+ with open(LDAP_STATE_FILE, "w") as state_file: >+ print >> state_file, value >+ >+ > def run_scripts( progressParser, restartServer = False ): > # write header before executing scripts > f = open(LOG_FILE, 'a') > f.write('\n\n=== RUNNING SETUP SCRIPTS (%s) ===\n\n' % timestamp()) > f.flush() > >+ check_ldap_access() >+ > # make sure that UMC servers and apache will not be restartet > subprocess.call( CMD_DISABLE_EXEC, stdout = f, stderr = f ) > >@@ -370,6 +390,8 @@ def run_scripts( progressParser, restartServer = False ): > # enable execution of servers again > subprocess.call(CMD_ENABLE_EXEC, stdout=f, stderr=f) > >+ os.unlink(LDAP_STATE_FILE) >+ > if restartServer: > f.write('=== Restart of UMC server and web server (%s) ===\n' % timestamp()) > f.flush() >@@ -379,6 +401,7 @@ def run_scripts( progressParser, restartServer = False ): > f.write('\n=== DONE (%s) ===\n\n' % timestamp()) > f.close() > >+ > def run_joinscript( progressParser, _username, password ): > # write header before executing join script > f = open(LOG_FILE, 'a') >@@ -421,6 +444,7 @@ def run_joinscript( progressParser, _username, password ): > f.write('\n=== DONE (%s) ===\n\n' % timestamp()) > f.close() > >+ > def cleanup(): > # write header before executing scripts > f = open(LOG_FILE, 'a') >@@ -472,6 +496,7 @@ def cleanup(): > > return True > >+ > def detect_interfaces(): > """ > Function to detect network interfaces in local sysfs. >@@ -505,6 +530,7 @@ def detect_interfaces(): > > return interfaces > >+ > def dhclient(interface, timeout=None): > """ > perform DHCP request for specified interface. If succesful, returns a dict >@@ -564,6 +590,7 @@ def dhclient(interface, timeout=None): > os.unlink(tempfilename) > return dhcp_dict > >+ > def get_components(role=None): > '''Returns a list of components that may be installed on the current system.''' > >@@ -597,17 +624,20 @@ def get_components(role=None): > > return pkglist > >+ > def get_installed_packages(): > '''Returns a list of all installed packages on the system.''' > cache = apt.Cache() > return [ p.name for p in cache if p.is_installed ] > >+ > def get_installed_components(): > '''Returns a list of components that are currently fully installed on the system.''' > allPackages = set(get_installed_packages()) > allComponents = get_components() > return [ icomp for icomp in allComponents if not len(set(icomp['Packages']) - allPackages) ] > >+ > # from univention-installer/installer/modules/70_net.py > def is_proxy(proxy): > if proxy and proxy != 'http://' and proxy != 'https://': >@@ -615,6 +645,7 @@ def is_proxy(proxy): > return False > return True > >+ > def is_ipaddr(addr): > try: > ipaddr.IPAddress(addr) >@@ -622,6 +653,7 @@ def is_ipaddr(addr): > return False > return True > >+ > def is_ipv4addr(addr): > try: > ipaddr.IPv4Address(addr) >@@ -629,6 +661,7 @@ def is_ipv4addr(addr): > return False > return True > >+ > def is_ipv4netmask(addr_netmask): > try: > ipaddr.IPv4Network(addr_netmask) >@@ -636,6 +669,7 @@ def is_ipv4netmask(addr_netmask): > return False > return True > >+ > def is_ipv6addr(addr): > try: > ipaddr.IPv6Address(addr) >@@ -643,6 +677,7 @@ def is_ipv6addr(addr): > return False > return True > >+ > def is_ipv6netmask(addr_netmask): > try: > ipaddr.IPv6Network(addr_netmask) >@@ -650,11 +685,13 @@ def is_ipv6netmask(addr_netmask): > return False > return True > >+ > # from univention-installer/installer/objects.py > def is_hostname(hostname): > return is_hostname.RE.match(hostname) is not None > is_hostname.RE = re.compile("^[a-z]([a-z0-9-]*[a-z0-9])*$") > >+ > def is_domainname(domainname): > """ > Check if domainname is a valid DNS domainname accoring to RFC952/1123. >@@ -676,14 +713,17 @@ def is_domainname(domainname): > return all(is_domainname.RE.match(_) for _ in domainname.split('.')) > is_domainname.RE = re.compile(r'^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$', re.I) > >+ > def is_windowsdomainname(domainname): > return is_windowsdomainname.RE.match(domainname) is not None > is_windowsdomainname.RE = re.compile(r"^[A-Z](?:[A-Z0-9-]*[A-Z0-9])?$") > >+ > def is_domaincontroller(domaincontroller): > return is_domaincontroller.RE.match(domaincontroller) is not None > is_domaincontroller.RE = re.compile("^[a-zA-Z].*\..*$") > >+ > # new defined methods > def is_ascii(str): > try: >@@ -692,6 +732,7 @@ def is_ascii(str): > except: > return False > >+ > def get_available_locales(pattern, category='language_en'): > '''Return a list of all available locales.''' > try: >@@ -760,4 +801,3 @@ def get_available_locales(pattern, category='language_en'): > }) > > return locales >-
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 33008
: 5539