Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

Asterisk4UCS ermöglicht zentrale Administration der gesamten Asterisk-Konfiguration mit allen Telefonen, Benutzerzuordnungen und weiteren IP-Telefonie-Peripheriegeräten/ -merkmalen und ist als App für den Univention Corporate Server (UCS) erhältlich. Der UCS stellt ein zentrales Identity- und Infrastruktur-Management basierend auf OpenLDAP zur Verfügung, in dem alle Teilnehmer mit ihren Login-Daten an einer Stelle im Netzwerk gehalten werden. Asterisk4UCS stellt die IP-Telefonie-Informationen dort bereit, wo sie benötigt werden: auf dem zentralen Anmeldesystemserver.

Asterisk4UCS erweitert eines der führenden LDAP-Verwaltungssysteme, den Univention Corporate Server (UCS) [1], um IP-Telefonie-Verwaltungsmöglichkeiten über eine web-basierte Oberfläche mit Hilfe eines dafür entwickelten UDM-Moduls (Univention Directory Management).
Ab UCS Version 4.3 wird Asterisk4UCS nicht mehr von uns gepflegt (end-of-life) und wird im Univention App Katalog deaktiviert. Als Hersteller der Lösung stehen wir Ihnen bei Fragen gerne zur Seite. Asterisk4UCS wurde zu unserer IP-Telefonanlage KITOMA weiterentwickelt. KITOMA ist statt reinen Administrationsmanagements nunmehr eine komplette IP-Telefonanlage, auf die durch die KITOMA-Oberfläche direkt zugegriffen werden kann.

Mehr Informationen unter http://www.asterisk4ucs.de oder https://www.decoit.de
Zwar ist KITOMA nicht direkt über den App-Katalog herunterladbar, aber trotzdem kompatibel zu UCS, so dass wir als Univention Premium Partner gerne Ihre UCS-Infrastruktur durch unsere IP-Telefonanlage erweitern. Weitere Informationen finden Sie unter www.kito.ma oder unter www.decoit.de/voip.html

Viele Grüße vom DECOIT®-Team

## Repository-Struktur
Der Master enthält die neuste Release-Version. Daneben gibt es noch spezifische Branches für die einzelnen UCS-Versionen, wie z.B. 4.1 oder 4.2.
Expand Down
6 changes: 6 additions & 0 deletions asterisk4ucs-testasterisk/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
asterisk4ucs-testasterisk (2.0.1) unstable; urgency=medium

* Add UCS 5.0 support. Migrate to Python 3

-- Florian Best <best@univention.de> Sun, 03 Apr 2022 20:56:35 +0200

asterisk4ucs-testasterisk (1.0.1) unstable; urgency=low

* Nichtinteraktive Installation repariert
Expand Down
1 change: 0 additions & 1 deletion asterisk4ucs-udm/42asterisk4ucs-udm.inst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ umc_policy_append "default-umc-all" "udm-asterisk"
joinscript_save_current_version

exit 0

6 changes: 2 additions & 4 deletions asterisk4ucs-udm/conffiles/etc/ldap/slapd.conf.d/80asterisk
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@%@UCRWARNING=# @%@
@!@
if baseConfig['server/role'] == "domaincontroller_master":
print "include /usr/share/univention-ldap/schema/asterisk4ucs.schema"
if configRegistry['server/role'] == "domaincontroller_master":
print("include /usr/share/univention-ldap/schema/asterisk4ucs.schema")
@!@


4 changes: 2 additions & 2 deletions asterisk4ucs-udm/debian/asterisk4ucs-udm.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ udm container/cn create \
/usr/lib/asterisk4ucs/user-phone-extension/install

# this is madness! - no, this is pkiiiiiiiiilllll!!!!
pkill -f '/usr/bin/python /usr/sbin/univention-management-console-module -m udm .*'
pkill -f '/usr/bin/python /usr/share/univention-directory-manager-tools/univention-cli-server'
pkill -f '/usr/bin/python3 /usr/sbin/univention-management-console-module -m udm .*'
pkill -f '/usr/bin/python3 /usr/share/univention-directory-manager-tools/univention-cli-server'
/etc/init.d/univention-management-console-web-server stop
/etc/init.d/univention-management-console-server restart
/etc/init.d/univention-management-console-web-server start
Expand Down
6 changes: 6 additions & 0 deletions asterisk4ucs-udm/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
asterisk4ucs-udm (2.0.1) unstable; urgency=medium

* Add UCS 5.0 support. Migrate to Python 3

-- Florian Best <best@univention.de> Sun, 03 Apr 2022 20:58:30 +0200

asterisk4ucs-udm (1.0.0) unstable; urgency=low

* Einige Bugfixes, Vorbereitung auf Release
Expand Down
2 changes: 1 addition & 1 deletion asterisk4ucs-udm/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Maintainer: Tristan Bruns (Decoit GmbH) <bruns@decoit.de>
Build-Depends:
debhelper (>= 7.0.50~),
univention-config-dev,
python-univention
python3-univention
Standards-Version: 3.5.2

Package: asterisk4ucs-udm
Expand Down
2 changes: 1 addition & 1 deletion asterisk4ucs-udm/devscripts/hardrestart
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

kill -9 `ps aux | grep management-console | cut -d\ -f 7` ; /etc/init.d/univention-management-console-server start && /etc/init.d/univention-management-console-web-server start
systemctl restart univention-management-console-server
36 changes: 11 additions & 25 deletions asterisk4ucs-udm/modules/asterisk4ucs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# coding=utf-8

"""
Expand All @@ -20,10 +20,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""

import re
import sys

import univention.admin.config
import univention.admin.uldap
import univention.admin.modules

Expand All @@ -38,24 +34,18 @@ def __init__(self, pbdn):
pbdn ist der DN des Telefonbuches im LDAP. (Kann z.B. per
"udm asterisk/phoneBook list" ermittelt werden)"""

self.co = univention.admin.config.config()
self.lo, self.pos = univention.admin.uldap.getAdminConnection()

univention.admin.modules.update()
self.udmPhonebook = univention.admin.modules.get(
"asterisk/phoneBook")
self.udmContact = univention.admin.modules.get(
"asterisk/contact")
univention.admin.modules.init(self.lo, self.pos,
self.udmPhonebook)
univention.admin.modules.init(self.lo, self.pos,
self.udmContact)

self.pb = self.udmPhonebook.object(self.co, self.lo,
None, pbdn)
self.udmPhonebook = univention.admin.modules.get("asterisk/phoneBook")
univention.admin.modules.init(self.lo, self.pos, self.udmPhonebook)
self.udmContact = univention.admin.modules.get("asterisk/contact")
univention.admin.modules.init(self.lo, self.pos, self.udmContact)

self.pb = self.udmPhonebook.object(None, self.lo, None, pbdn)
self.pb.open()
if not self.pb.exists():
raise Exception, "DN does not exist."
raise Exception("DN does not exist.")

def getName(self):
"""Gibt den Namen des Telefonbuchs zurück"""
Expand All @@ -65,17 +55,14 @@ def getName(self):
def empty(self):
"""Löscht alle Kontakte im Telefonbuch"""

contacts = self.udmContact.lookup(self.co, self.lo, None,
superordinate=self.pb)
contacts = self.udmContact.lookup(None, self.lo, None, superordinate=self.pb)

for contact in contacts:
contact.remove()

return len(contacts)

def addContact(self, title=None, firstname=None, lastname=None,
organisation=None,
phones=None, mobiles=None, faxes=None):
def addContact(self, title=None, firstname=None, lastname=None, organisation=None, phones=None, mobiles=None, faxes=None):
"""Fügt einen Kontakt hinzu

Die Argumente sollten unbedingt als Keyword-Argumente
Expand All @@ -87,8 +74,7 @@ def addContact(self, title=None, firstname=None, lastname=None,
Strings.
Der Rückgabewert ist der DN des neuen Kontakts."""

contact = self.udmContact.object(self.co, self.lo,
self.pb.position, None, self.pb)
contact = self.udmContact.object(None, self.lo, self.pb.position, None, self.pb)
contact.open()

if title:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""

from univention.management.console.log import MODULE
import univention.config_registry
import univention.admin.filter
Expand Down Expand Up @@ -71,8 +72,7 @@ def genSipconfEntry(co, lo, phone):
phone = phone.info

if phoneUser.get("mailbox"):
phoneMailbox = mailbox.object(co, lo, None,
phoneUser["mailbox"]).info
phoneMailbox = mailbox.object(co, lo, None, phoneUser["mailbox"]).info

callgroups = []
for group in phone.get("callgroups", []):
Expand All @@ -84,18 +84,15 @@ def genSipconfEntry(co, lo, phone):
group = phoneGroup.object(co, lo, None, group).info
pickupgroups.append(group["id"])

res = "[%s](template-%s)\n" % (
phone["extension"],
phone.get("profile", "default"))
res = "[%s](template-%s)\n" % (phone["extension"], phone.get("profile", "default"))
res += "secret=%s\n" % (phone["password"])

if phoneUser.get("extmode") == "normal":
res += "callerid=\"%s\" <%s>\n" % (
getNameFromUser(phoneUser),
phone["extension"])
elif phoneUser.get("extmode") == "first":
firstPhone = sipPhone.object(co, lo, None,
llist(phoneUser["phones"])[0]).info
firstPhone = sipPhone.object(co, lo, None, llist(phoneUser["phones"])[0]).info
res += "callerid=\"%s\" <%s>\n" % (
getNameFromUser(phoneUser),
firstPhone["extension"])
Expand All @@ -113,10 +110,10 @@ def genSipconfEntry(co, lo, phone):


def genSipconfFaxEntry(co, lo, phone):
res = "[%s]\n" % (phone["extension"])
res = "[%s]\n" % (phone["extension"],)
res += "type=friend\n"
res += "host=dynamic\n"
res += "secret=%s\n" % (phone["password"])
res += "secret=%s\n" % (phone["password"],)
return res


Expand All @@ -143,19 +140,17 @@ def genSipconf(co, lo, srv):
conf += "; dn: %s\n" % (phone.dn)
try:
conf += genSipconfEntry(co, lo, phone)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

conf += "\n\n; ===== Fax machines =====\n\n"
for phone in fax.lookup(co, lo, False):
conf += "; dn: %s\n" % (phone.dn)
try:
conf += genSipconfFaxEntry(co, lo, phone)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

return conf
Expand All @@ -164,7 +159,7 @@ def genSipconf(co, lo, srv):
def genVoicemailconfEntry(co, lo, box):
from univention.admin.handlers.users import user
boxUser = user.lookup(co, lo, filter_format("(ast4ucsUserMailbox=%s)", (box.dn,)))
if len(boxUser) == 0:
if not boxUser:
return ";; Mailbox %s has no user.\n" % box["id"]
if len(boxUser) > 1:
msg = ";; Mailbox %s has multiple users:\n" % box["id"]
Expand Down Expand Up @@ -211,9 +206,8 @@ def genVoicemailconf(co, lo, srv):
conf += "; dn: %s\n" % (box.dn)
try:
conf += genVoicemailconfEntry(co, lo, box)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

return conf
Expand Down Expand Up @@ -246,9 +240,8 @@ def genQueuesconf(co, lo, srv):
conf += "; dn: %s\n" % (queue.dn)
try:
conf += genQueuesconfEntry(co, lo, queue)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

return conf
Expand Down Expand Up @@ -277,9 +270,8 @@ def genMusiconholdconf(co, lo, srv):
conf += "; dn: %s\n" % (moh.dn)
try:
conf += genMusiconholdconfEntry(co, lo, srv, moh)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

return conf
Expand All @@ -290,8 +282,7 @@ def genExtSIPPhoneEntry(co, lo, agis, extenPhone):

# check if this phone is managed manually (not by ast4ucs)
if extenPhone.get("skipExtension") == "1":
return ";; Extension %s is managed manually.\n" % (
extenPhone["extension"])
return ";; Extension %s is managed manually.\n" % (extenPhone["extension"],)

from univention.admin.handlers.users import user
from univention.admin.handlers.asterisk import sipPhone, mailbox
Expand All @@ -311,22 +302,21 @@ def genExtSIPPhoneEntry(co, lo, agis, extenPhone):
try:
timeout = int(phoneUser["timeout"])
if timeout < 1 or timeout > 120:
raise Exception
except:
raise ValueError()
except ValueError:
timeout = 10

try:
ringdelay = int(phoneUser["ringdelay"])
if ringdelay < 1 or ringdelay > 120:
raise Exception
except:
raise ValueError()
except ValueError:
ringdelay = 0

channels = []
hints = []
for dn in phoneUser.get("phones", []):
phone = sipPhone.object(co, lo, extenPhone.position, dn,
extenPhone.superordinate)
phone = sipPhone.object(co, lo, extenPhone.position, dn, extenPhone.superordinate)
hints.append("SIP/%s" % phone["extension"])
if phone.get("forwarding"):
channels.append("Local/%s" % phone["forwarding"])
Expand All @@ -342,8 +332,7 @@ def genExtSIPPhoneEntry(co, lo, agis, extenPhone):
if channels:
if ringdelay:
for channel in channels[:-1]:
res.append("Dial(%s,%i,tT)" % (channel,
ringdelay))
res.append("Dial(%s,%i,tT)" % (channel, ringdelay))
res.append("Wait(0.5)")
res.append("Dial(%s,%i,tT)" % (channels[-1], timeout))
else:
Expand All @@ -360,10 +349,9 @@ def genExtSIPPhoneEntry(co, lo, agis, extenPhone):

resStr = ""
if hints:
resStr += "exten => %s,hint,%s\n" % (extension,
'&'.join(hints))
resStr += "exten => %s,hint,%s\n" % (extension, '&'.join(hints))
for i, data in enumerate(res):
resStr += "exten => %s,%i,%s\n" % (extension, i+1, data)
resStr += "exten => %s,%i,%s\n" % (extension, i + 1, data)

return resStr

Expand Down Expand Up @@ -463,8 +451,7 @@ def genExtensionsconf(co, lo, srv):
int(agi["priority"]),
"AGI(ast4ucs-%s)" % agi["name"]
))
sortkey = lambda x: x[0]
agis.sort(key=sortkey, reverse=True)
agis.sort(key=lambda x: x[0], reverse=True)
agis = [x[1] for x in agis]

conf = "; Automatisch generiert von Asterisk4UCS\n"
Expand All @@ -476,29 +463,26 @@ def genExtensionsconf(co, lo, srv):
conf += "; dn: %s\n" % (phone.dn)
try:
conf += genExtSIPPhoneEntry(co, lo, agis, phone)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

conf += "\n\n; ===== Konferenzräume =====\n\n"
for room in conferenceRoom.lookup(co, lo, False):
conf += "; dn: %s\n" % (room.dn)
try:
conf += genExtRoomEntry(co, lo, agis, room)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

conf += "\n\n; ===== Warteschleifen =====\n\n"
for queue in waitingLoop.lookup(co, lo, False):
conf += "; dn: %s\n" % (queue.dn)
try:
conf += genExtQueueEntry(co, lo, agis, queue)
except:
conf += re.sub("(?m)^", ";",
traceback.format_exc()[:-1])
except Exception:
conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1])
conf += "\n"

conf += "\n\n; ===== Blockierte Vorwahlen =====\n\n"
Expand Down Expand Up @@ -580,11 +564,3 @@ def reverseFieldsSave(self):
obj.open()
obj.info.setdefault(foreignField, []).append(self.dn)
obj.modify()


class AsteriskBase(univention.admin.handlers.simpleLdap):

def __init__(self, co, lo, position, dn='', superordinate=None, attributes=None):
if not superordinate and (dn or position):
superordinate = univention.admin.objects.get_superordinate(self.module, co, lo, dn or position.getDn())
super(AsteriskBase, self).__init__(co, lo, position, dn, superordinate, attributes)
Loading