From e641c02ceaf636f80491370523250a2a06086d82 Mon Sep 17 00:00:00 2001 From: Ignacio Bravo Date: Thu, 29 Dec 2022 14:01:29 -0500 Subject: [PATCH 1/3] Added Cisco 797X settings --- .../version_sql/6_2.5.0-3_2.5.0-4.sql | 24 ++ .../class/issabel/vendor/Cisco797X.py | 118 ++++++++++ .../endpoint-classes/tpl/Cisco_local_797X.tpl | 219 ++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py create mode 100644 setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_797X.tpl diff --git a/setup/db/update/endpointconfig/version_sql/6_2.5.0-3_2.5.0-4.sql b/setup/db/update/endpointconfig/version_sql/6_2.5.0-3_2.5.0-4.sql index f6c37ba..47a73ce 100755 --- a/setup/db/update/endpointconfig/version_sql/6_2.5.0-3_2.5.0-4.sql +++ b/setup/db/update/endpointconfig/version_sql/6_2.5.0-3_2.5.0-4.sql @@ -110,3 +110,27 @@ INSERT INTO `model_properties` (`id_model`, `property_key`, `property_value`) VA ((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "CiscoSPA" AND model.name = "SPA303G"), 'max_iax2_accounts', '0'), ((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "CiscoSPA" AND model.name = "SPA303G"), 'http_username', 'admin'), ((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "CiscoSPA" AND model.name = "SPA303G"), 'http_password', '22222'); + +/* Creación del fabricante Cisco 797X */ +INSERT INTO `manufacturer` (`name`, `description`) VALUES ('Cisco797X', 'Cisco797X'); + +INSERT INTO `mac_prefix` (`id_manufacturer`, `mac_prefix`, `description`) VALUES +((SELECT `id` FROM manufacturer WHERE `name` = "Cisco797X"), '00:1F:6C', 'Cisco SPA7961G'), +((SELECT `id` FROM manufacturer WHERE `name` = "Cisco797X"), '00:1F:9E', 'Cisco SPA7961G'), +((SELECT `id` FROM manufacturer WHERE `name` = "Cisco797X"), '00:E1:6D', 'Cisco SPA9951'); + +/* Modelos asociados a Cisco797X */ +INSERT INTO `model` (`id_manufacturer`, `name`, `description`, `max_accounts`, `static_ip_supported`, `dynamic_ip_supported`, `static_prov_supported`) VALUES +((SELECT `id` FROM manufacturer WHERE `name` = "Cisco797X"), 'SPA7961G', 'SPA7961G', '3', '1', '1', '0'), +((SELECT `id` FROM manufacturer WHERE `name` = "Cisco797X"), 'SPA9951', 'SPA9951', '3', '1', '1', '0'); + +/* Propiedades de los modelos Cisco 797X */ +INSERT INTO `model_properties` (`id_model`, `property_key`, `property_value`) VALUES +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA7961G"), 'max_sip_accounts', '3'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA7961G"), 'max_iax2_accounts', '0'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA7961G"), 'http_username', 'admin'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA7961G"), 'http_password', 'cisco'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA9951"), 'max_sip_accounts', '3'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA9951"), 'max_iax2_accounts', '0'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA9951"), 'http_username', 'admin'), +((SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco797X" AND model.name = "SPA9951"), 'http_password', 'cisco'); \ No newline at end of file diff --git a/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py new file mode 100644 index 0000000..63b2af0 --- /dev/null +++ b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py @@ -0,0 +1,118 @@ +# vim: set fileencoding=utf-8 : +# vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: +# Codificación: UTF-8 +# +----------------------------------------------------------------------+ +# | Issabel version 4.0.4 | +# | http://www.issabel.org | +# +----------------------------------------------------------------------+ +# | Copyright (c) 2006 Palosanto Solutions S. A. | +# +----------------------------------------------------------------------+ +# | Cdla. Nueva Kennedy Calle E 222 y 9na. Este | +# | Telfs. 2283-268, 2294-440, 2284-356 | +# | Guayaquil - Ecuador | +# | http://www.palosanto.com | +# +----------------------------------------------------------------------+ +# | The contents of this file are subject to the General Public License | +# | (GPL) Version 2 (the "License"); you may not use this file except in | +# | compliance with the License. You may obtain a copy of the License at | +# | http://www.opensource.org/licenses/gpl-license.php | +# | | +# | Software distributed under the License is distributed on an "AS IS" | +# | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | +# | the License for the specific language governing rights and | +# | limitations under the License. | +# +----------------------------------------------------------------------+ +# | The Initial Developer of the Original Code is PaloSanto Solutions | +# | CiscoSPA.py file forked from Linksys.py by Bob Fryer 07/06/2015 | +# | Other modifications made : | +# | * Added code to convert GMT Offsite into format for Cisco SPA Phones | +# | * added timezone as a parameter that can be set in the Endpoint GUI | +# | * made modifications to utilse the CiscoSPA replacing Linksys name | +# | * added published variables daylightrule and daylightenable | +# | * Created Cisco_local_spa.tpl file from Linksys template file | +# +----------------------------------------------------------------------+ +# $Id: dialerd,v 1.2 2008/09/08 18:29:36 alex Exp $ +import logging +from issabel.BaseEndpoint import BaseEndpoint +from eventlet.green import urllib2, socket + +class Endpoint(BaseEndpoint): + def __init__(self, amipool, dbpool, sServerIP, sIP, mac): + BaseEndpoint.__init__(self, 'Cisco797X', amipool, dbpool, sServerIP, sIP, mac) + + # Convert Signed Decimal TimeZone Offset to Signed HH:MM offset formated for Cisco SPA Phones + tzoffset = BaseEndpoint.getTimezoneOffset() / 60 + self._timeZone = '' + if tzoffset < 0: + self._timeZone = 'GMT-' + else: + self._timeZone = 'GMT+' + self._timeZone = self._timeZone + ('%02d:%02d' % (abs(tzoffset) / 60, abs(tzoffset) % 60)) + self._daylightrule = '' + self._daylightenable = '' + + + def setExtraParameters(self, param): + if not BaseEndpoint.setExtraParameters(self, param): return False + if 'timezone' in param: self._timeZone = param['timezone'] + if 'daylightrule' in param: self._daylightrule = param['daylightrule'] + if 'daylightenable' in param: self._daylightenable = param['daylightenable'] + return True + + def updateLocalConfig(self): + '''Configuration for Cisco797X endpoints (local): + + A file called SPAXXXXXXXXXXXX.cnf.xml should be created with the XML + configuration for the endpoint. The XXXXXXXXXXXX should be replaced with + the uppercase version of the MAC address of the endpoint. To reboot and + refresh the configuration, an HTTP GET request is performed to the URL: + http://{$IP}/admin/resync?{$SERVER_IP}/spaXXXXXXXXXXXX.cfg, again + replacing XXXXXXXXXXXX with the MAC address. + ''' + # Check that there is at least one account to configure + if len(self._accounts) <= 0: + logging.error('Endpoint %s@%s has no accounts to configure' % + (self._vendorname, self._ip)) + return False + + # Need to calculate lowercase version of MAC address without colons + sConfigFile = 'SPA' + (self._mac.replace(':', '').upper()) + '.cnf.xml' + sConfigPath = self._tftpdir + '/' + sConfigFile + vars = self._prepareVarList() + vars['config_filename'] = sConfigFile + vars.update({ + 'time_zone' : self._timeZone, + 'daylight_rule' : self._daylightrule, + 'daylight_enable' : self._daylightenable, + }) + + try: + self._writeTemplate('Cisco_local_797X.tpl', vars, sConfigPath) + except IOError, e: + logging.error('Endpoint %s@%s failed to write configuration file - %s' % + (self._vendorname, self._ip, str(e))) + return False + + # Reboot the phone. + try: + # Open connection to execute resync. + # TODO: what, no authentication? + r = urllib2.urlopen('http://' + self._ip + '/admin/resync?' + self._serverip + '/' + sConfigFile) + r.read() + except urllib2.HTTPError, e: + logging.error('Endpoint %s@%s got HTTP Error - %s' % + (self._vendorname, self._ip, str(e))) + return False + except urllib2.URLError, e: + logging.error('Endpoint %s@%s failed to connect - %s' % + (self._vendorname, self._ip, str(e))) + return False + except socket.error, e: + logging.error('Endpoint %s@%s failed to connect - %s' % + (self._vendorname, self._ip, str(e))) + return False + + self._unregister() + self._setConfigured() + return True + diff --git a/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_797X.tpl b/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_797X.tpl new file mode 100644 index 0000000..659475e --- /dev/null +++ b/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_797X.tpl @@ -0,0 +1,219 @@ + + +true +SIP + +cisco +cisco + + + + M-D-YYYYA + Eastern Standard/Daylight Time + + + {{server_ip}} + Unicast + + + + + + + + + + 2000 + 5060 + 5061 + + {{server_ip}} + + + + + + + + + + + + + + + true + + + + true + x-cisco-serviceuri-cfwdall + x-cisco-serviceuri-pickup + x-cisco-serviceuri-opickup + x-cisco-serviceuri-gpickup + x-cisco-serviceuri-meetme + x-cisco-serviceuri-abbrdial + false + 1 + true + true + 0 + 0 + false + 0 + true + + + + 6 + 10 + 180 + 3600 + 5 + 120 + 120 + 5 + 500 + 4000 + 70 + true + Phone + + + 1 + false + true + false + false + none + 101 + 3 + avt + false + false + 0 + + false + false + + + CentroNia MD + 0 + true + 15000 + 10 + false + + 16384 + 20000 + + + {{py:n = 1}}{{for extension in sip}} + + 9 + {{extension.extension}} + USECALLMANAGER + 5060 + {{extension.extension}} + {{extension.description}} + + 0 + + 1 + {{extension.account}} + {{extension.secret}} + false + 3 + 0 + *97 + 4 + 5 + + + true + false + false + true + + + {{py:n += 1}}{{endfor}} + + + 5060 + 184 + 0 + dialplan.xml + + + + + + true + 2 + + + + IMAGE2.png + false + false + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 22 + 0 + 1,7 + 08:00 + 10:00 + 00:15 + 1 + 1 + + + + + America/Sao_Paulo + 1 + pt_BR + 1.0.0.0-1 + UTF-8 + + +America/Sao_Paulo + + + America/Sao_Paulo + 5.0(2) + + +1 + + + + + + + + + + +96 +0 +96 + +2 + +0 + + + 3804 + + + + +false + + \ No newline at end of file From 7ac9096701994965858aa50076315a6c54fe5260 Mon Sep 17 00:00:00 2001 From: Ignacio Bravo Date: Thu, 29 Dec 2022 14:41:26 -0500 Subject: [PATCH 2/3] Updated typo on filename --- .../issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py index 63b2af0..7e13f95 100644 --- a/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py +++ b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco797X.py @@ -76,7 +76,7 @@ def updateLocalConfig(self): return False # Need to calculate lowercase version of MAC address without colons - sConfigFile = 'SPA' + (self._mac.replace(':', '').upper()) + '.cnf.xml' + sConfigFile = 'SEP' + (self._mac.replace(':', '').upper()) + '.cnf.xml' sConfigPath = self._tftpdir + '/' + sConfigFile vars = self._prepareVarList() vars['config_filename'] = sConfigFile From c3a9e12b2d348e1c9c8a13cc25aa715b75a38d3c Mon Sep 17 00:00:00 2001 From: Ignacio Bravo Date: Fri, 30 Dec 2022 08:01:58 -0500 Subject: [PATCH 3/3] Allows the passage of custom fields to the Template. To use the template add {{extension.property_key}} to it. --- .../share/issabel/endpoint-classes/class/issabel/Extension.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/usr/share/issabel/endpoint-classes/class/issabel/Extension.py b/setup/usr/share/issabel/endpoint-classes/class/issabel/Extension.py index 088eea6..2fdc77a 100755 --- a/setup/usr/share/issabel/endpoint-classes/class/issabel/Extension.py +++ b/setup/usr/share/issabel/endpoint-classes/class/issabel/Extension.py @@ -89,8 +89,8 @@ def __init__(self, dbconn, tech, exten): setattr(self, 'server_port', row[0]) sth.execute( 'SELECT property_key, property_value ' + - 'FROM endpoint_account_properties, endpoint_account ' + - 'WHERE endpoint_account_properties.id_endpoint_account = endpoint_account.id ' + + 'FROM endpoint_properties, endpoint_account ' + + 'WHERE endpoint_properties.id_endpoint = endpoint_account.id_endpoint ' + 'AND endpoint_account.account = %s', (exten,)) for row in sth.fetchall():