ucsschool.lib package

Submodules

ucsschool.lib.create_ou module

Class to create an OU. Used by create_ou script and customer single user HTTP API.

ucsschool.lib.create_ou.create_ou(ou_name, display_name, edu_name, admin_name, share_name, lo, baseDN, hostname, is_single_master, alter_dhcpd_base=None)[source]

Create a ucsschool OU.

Parameters:
  • ou_name (str) – name for the OU
  • display_name (str) – display name for the OU
  • edu_name (str) – host name of educational school server
  • admin_name (str) – host name of administrative school server
  • share_name (str) – host name
  • lo (univention.uldap.acceess) – LDAP connection object
  • baseDN (str) – base DN
  • hostname (str) – hostname of master in case of singlemaster
  • is_single_master (bool) – whther it is a singlemaster
  • alter_dhcpd_base (bool) – if the DHCP base should be modified
Return bool:

whether the OU was sucessfully created (or already existed)

Raises:
  • ValueError – on validation errors
  • uidAlreadyUsed

ucsschool.lib.i18n module

ucsschool.lib.i18n.ucs_school_name_i18n(name, lang='de')[source]

i18n function for localization of UCS@school standard names

ucsschool.lib.info module

class ucsschool.lib.info.MembershipFlags(is_edu_school_member, is_admin_school_member)

Bases: tuple

Create new instance of MembershipFlags(is_edu_school_member, is_admin_school_member)

_asdict()

Return a new OrderedDict which maps field names to their values

_fields = ('is_edu_school_member', 'is_admin_school_member')
classmethod _make(iterable, new=<built-in method __new__ of type object>, len=<built-in function len>)

Make a new MembershipFlags object from a sequence or iterable

_replace(_self, **kwds)

Return a new MembershipFlags object replacing specified fields with new values

is_admin_school_member

Alias for field number 1

is_edu_school_member

Alias for field number 0

ucsschool.lib.info.get_school_membership_type(lo, dn)[source]

Returns a named tuple, that states if the given computer object specified by dn is an educational school slave/memberserver or administrative slave/memberserver.

Parameters:
Returns:

a named tuple that contains flags for educational and administrative membership

Return type:

namedtuple(is_edu_school_member, is_admin_school_member)

ucsschool.lib.info.is_central_computer(lo, dn)[source]

Checks if the given computer object specified by dn is a central system or located at a specific school.

Parameters:
Returns:

is the computer a central system?

Return type:

bool

ucsschool.lib.info.is_school_slave(lo, dn)[source]

Checks if the given domaincontroller_slave object (specified by dn) is a school slave.

Parameters:
Returns:

is the computer a school slave?

Return type:

bool

Raises:

ValueError – computer DN does not refer to a computers/domaincontroller_slave object

ucsschool.lib.internetrules module

class ucsschool.lib.internetrules.Rule(name, type=0, priority=0, wlan=False, domains=[], userRule=False)[source]

Bases: object

_getIndexedDomains(type)[source]
_getAppendedDomains(type)[source]
_getDomains(type)[source]
domains

Return list of all domains, the order respects the indeces. Show only the entries that match the current filter type.

addDomain(domain, idx=-1, listType=None)[source]

add a new domain with an optional fixed index and list type

save()[source]

Save the current rule as UCR variables. If the rule already exists, only the changed properties will be saved. In case the rules are similar, no changes will be done.

ucsschool.lib.internetrules.findUCRVariables(filterName=None, userRule=False)[source]

Returns a dict of all UCR variables or all variables matching the specified rule name.

ucsschool.lib.internetrules.remove(name, userRule=False)[source]

Removes the UCR variables corresponding to the specified rule.

ucsschool.lib.internetrules.load(name, userRule=False)[source]

Wrapper for list(name).

ucsschool.lib.internetrules.list(filterName=None, userRule=False)[source]

Returns a list of all existing rules. If name is given, returns only the rule matching the specified name or None. userRule specifies whether all common rules (=False) or only user-specific rules (=True) are listed. If filterName is specified, only rule matching this name is returned as single object (not as list!).

ucsschool.lib.internetrules.getGroupRuleName(groupNames)[source]

Return the name of the filter rule for the specified group name. Usage:

getGroupRuleName([<groupName>, ...]) -> { <groupName>:<ruleName>, ... }
or
getGroupRuleName(<groupName) -> <ruleName>
ucsschool.lib.internetrules.unsetGroupRuleName(groupNames)[source]

Unset the default rule for the given group name. Usage:

setGroupRuleName(<groupName>)
or
setGroupRuleName([<groupName>, ... ])
ucsschool.lib.internetrules.setGroupRuleName(*args)[source]

Set the default rule for the given group name. Usage:

setGroupRuleName(<groupName>, <ruleName>)
or
setGroupRuleName({ <groupName>: <ruleName>, ... })

ucsschool.lib.roles module

exception ucsschool.lib.roles.UnknownRole[source]

Bases: exceptions.Exception

ucsschool.lib.roles.create_ucsschool_role_string(role, school)[source]

ucsschool.lib.roleshares module

ucsschool.lib.roleshares.roleshare_name(role, school_ou, ucr)[source]
ucsschool.lib.roleshares.roleshare_path(role, school_ou, ucr)[source]
ucsschool.lib.roleshares.roleshare_home_subdir(school_ou, roles, ucr=None)[source]
ucsschool.lib.roleshares.create_roleshare_on_server(*args, **kwargs)[source]
ucsschool.lib.roleshares.fqdn_from_serverdn(*args, **kwargs)[source]
ucsschool.lib.roleshares.fileservers_for_school(*args, **kwargs)[source]
ucsschool.lib.roleshares.create_roleshare_for_searchbase(*args, **kwargs)[source]
ucsschool.lib.roleshares.create_roleshares(*args, **kwargs)[source]

ucsschool.lib.school_umc_base module

class ucsschool.lib.school_umc_base.SchoolSanitizer(regex_pattern=None, re_flags=0, minimum=None, maximum=None, **kwargs)[source]

Bases: univention.management.console.modules.sanitizers.StringSanitizer

_sanitize(value, name, further_args)[source]
class ucsschool.lib.school_umc_base.SchoolBaseModule(domain='univention-management-console')[source]

Bases: univention.management.console.base.Base

This class serves as base class for UCS@school UMC modules that need LDAP access. It initiates the list of available OUs (self.availableSchools) and initiates the search bases (self.searchBase). set_bind_function() is called automatically to allow LDAP connections. In order to integrate this class into a module, use the following paradigm:

class Instance(SchoolBaseModule):
def __init__(self):
# initiate list of internal variables SchoolBaseModule.__init__(self) # ... custom code
def init(self):
SchoolBaseModule.init(self) # ... custom code
init()[source]
bind_user_connection(lo)[source]
schools(*args, **kwargs)[source]

Returns a list of all available school

_groups(ldap_connection, school, ldap_base, pattern=None, scope='sub')[source]

Returns a list of all groups of the given school

classes(request)[source]

Returns a list of all classes of the given school

workgroups(request)[source]

Returns a list of all working groups of the given school

groups(request)[source]

Returns a list of all groups (classes and workgroups) of the given school

rooms(request)[source]

Returns a list of all available school

_users(ldap_connection, school, group=None, user_type=None, pattern='')[source]

Returns a list of all users given ‘pattern’, ‘school’ (search base) and ‘group’

_users_ldap(ldap_connection, school, group=None, user_type=None, pattern='', attr=None)[source]

Returns a list of LDAP query result tuples (dn, attr) of all users given pattern, school (search base) and group.

class ucsschool.lib.school_umc_base.LDAP_Filter[source]
static forSchool(school)[source]
static forUsers(pattern)[source]
static forGroups(pattern, school=None)[source]
static forComputers(pattern)[source]
regWhiteSpaces = <_sre.SRE_Pattern object>
static forAll(pattern, subMatch=[], fullMatch=[], prefixes={})[source]
class ucsschool.lib.school_umc_base.Display[source]
static user(udm_object)[source]
static user_ldap(ldap_object)[source]

ucsschool.lib.school_umc_ldap_connection module

ucsschool.lib.school_umc_ldap_connection.set_bind_function(bind_callback)[source]
ucsschool.lib.school_umc_ldap_connection.set_credentials(dn, passwd)[source]
ucsschool.lib.school_umc_ldap_connection.LDAP_Connection(*connection_types)[source]

This decorator function provides access to internally cached LDAP connections that can be accessed via adding specific keyword arguments to the function.

The function which uses this decorator may specify the following additional keyword arguments: ldap_position: a univention.admin.uldap.position instance valid ldap position. ldap_user_read: a read only LDAP connection to the local LDAP server authenticated with the currently used user ldap_user_write: a read/write LDAP connection to the master LDAP server authenticated with the currently used user ldap_machine_read: a read only LDAP connection to the local LDAP server authenticated with the machine account ldap_machine_write: a read/write LDAP connection to the master LDAP server authenticated with the machine account ldap_admin_write: a read/write LDAP connection to the master LDAP server authenticated with cn=admin account (deprecated!) search_base: a SchoolSearchBase instance which is bound to the school of the user or machine.

This decorator can only be used after set_bind_function() has been executed.

example: @LDAP_Connection() def do_ldap_stuff(arg1, arg2, ldap_user_write=None, ldap_user_read=None, ldap_position=None):

... ldap_user_read.searchDn(..., position=ldap_position) ...

ucsschool.lib.schoolldap module

class ucsschool.lib.schoolldap.SchoolSearchBase(availableSchools, school=None, dn=None, ldapBase=None)[source]

Bases: object

Deprecated utility class that generates DNs of common school containers for a OU

ucr = None
classmethod _load_ucr()[source]
classmethod getOU(dn)[source]

Return the school OU for a given DN.

>>> SchoolSearchBase.getOU('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar')
'dc1'
classmethod getOUDN(dn)[source]

Return the School OU-DN part for a given DN.

>>> SchoolSearchBase.getOUDN('uid=a,fou=bar,Ou=dc1,oU=dc,dc=foo,dc=bar')
'Ou=dc1,oU=dc,dc=foo,dc=bar'
>>> SchoolSearchBase.getOUDN('ou=dc1,ou=dc,dc=foo,dc=bar')
'ou=dc1,ou=dc,dc=foo,dc=bar'
_RE_OUDN = <_sre.SRE_Pattern object>
dhcp
policies
networks
school
schoolDN
users
groups
workgroups
classes
rooms
students
teachers
teachersAndStaff
staff
admins
classShares
shares
printers
computers
examUsers
globalGroupContainer
educationalDCGroup
educationalMemberGroup
administrativeDCGroup
administrativeMemberGroup
examGroupName
examGroup
isWorkgroup(groupDN)[source]
isGroup(groupDN)[source]
isClass(groupDN)[source]
isRoom(groupDN)[source]

ucsschool.lib.schoollessons module

class ucsschool.lib.schoollessons.Lesson(name, begin, end)[source]

Bases: object

TIME_REGEX = <_sre.SRE_Pattern object>
_check_name(string)[source]
_parse_time(string)[source]
name
begin
end
intersect(lesson)[source]
class ucsschool.lib.schoollessons.SchoolLessons(filename='/var/lib/ucs-school-lib/lessons.ini')[source]

Bases: ConfigParser.ConfigParser

init()[source]
remove(lesson)[source]
add(lesson, begin=None, end=None)[source]
save()[source]
lessons
current
next
previous

ucsschool.lib.smbstatus module

class ucsschool.lib.smbstatus.SMB_LockedFile[source]

Bases: dict

filename
sharePath
class ucsschool.lib.smbstatus.SMB_Process(args)[source]

Bases: dict

username
pid
machine
lockedFiles
services
ipv4address
ipv6address
ipaddress
update(dictionary)[source]
class ucsschool.lib.smbstatus.SMB_Status(testdata=None)[source]

Bases: list

parse(testdata=None)[source]
update(service)[source]
ucsschool.lib.smbstatus.usage()[source]