diff --git a/setup/db/update/endpointconfig/version_sql/10_4.0.0-3_4.0.0-4.sql b/setup/db/update/endpointconfig/version_sql/10_4.0.0-3_4.0.0-4.sql
new file mode 100644
index 0000000..0e7b4dd
--- /dev/null
+++ b/setup/db/update/endpointconfig/version_sql/10_4.0.0-3_4.0.0-4.sql
@@ -0,0 +1,71 @@
+
+INSERT INTO `mac_prefix` (`mac_prefix`, `description`, `id_manufacturer`) VALUES
+("00:07:0E", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:17:0E", "Cisco - 7970", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:17:59", "Cisco - 7970", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:19:30", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:1C:58", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:1E:4A", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:1E:F7", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:1D:70", "Cisco - 7942", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:1D:A2", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:21:A0", "Cisco - 7975G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:22:90", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:23:04", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:24:14", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:26:0B", "Cisco - 79XX", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:27:90", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:76:86", "Cisco - 7821", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("00:B0:E1", "Cisco - 7821", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("1C:E6:C7", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("3C:41:0E", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("40:F4:EC", "Cisco - 7975G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("50:F7:22", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("58:97:1E", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("64:A0:E7", "Cisco - 7962", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("64:D9:89", "Cisco - 7942", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("B8:62:1F", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("C0:62:6B", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("CC:5A:53", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("D0:57:4C", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("D0:C2:82", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("D4:2C:44", "Cisco - 7821", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("DC:7B:94", "Cisco - 7942", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("E8:04:62", "Cisco - 7975G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("F8:B7:E2", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+("F8:7B:20", "Cisco - 8851", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco"))
+;
+
+INSERT INTO `model` (`max_accounts`, `static_ip_supported`, `dynamic_ip_supported`, `static_prov_supported`, `name`, `description`, `id_manufacturer`) VALUES
+(2, 0, 1, 0, "79XX", "Cisco - 79XX", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(2, 0, 1, 0, "7821", "Cisco - 7821", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(2, 0, 1, 0, "7941G", "Cisco - 7941G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(2, 0, 1, 0, "7942", "Cisco - 7942", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(2, 0, 1, 0, "7945G", "Cisco - 7945G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(2, 0, 1, 0, "7962", "Cisco - 7962", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(8, 0, 1, 0, "7970", "Cisco - 7970", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(8, 0, 1, 0, "7975G", "Cisco - 7975G", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(5, 0, 1, 0, "8851", "Cisco - 8851", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco")),
+(5, 0, 1, 0, "8865", "Cisco - 8865", (SELECT `id` FROM manufacturer WHERE `name` = "Cisco"))
+;
+
+INSERT INTO `model_properties` (`property_key`, `property_value`, `id_model`) VALUES
+("max_sip_accounts", "2", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7821")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7821")),
+("max_sip_accounts", "2", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7941G")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7941G")),
+("max_sip_accounts", "2", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7942")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7942")),
+("max_sip_accounts", "2", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7945")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7945")),
+("max_sip_accounts", "2", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7962")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7962")),
+("max_sip_accounts", "8", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7970")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7970")),
+("max_sip_accounts", "8", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7975G")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "7975G")),
+("max_sip_accounts", "5", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "8851")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "8851")),
+("max_sip_accounts", "5", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "8865")),
+("max_iax2_accounts", "0", (SELECT model.id FROM manufacturer, model WHERE manufacturer.id = model.id_manufacturer AND manufacturer.name = "Cisco" AND model.name = "8865"))
+;
\ No newline at end of file
diff --git a/setup/tftpboot/DialTemplate.xml b/setup/tftpboot/DialTemplate.xml
new file mode 100644
index 0000000..4104d2e
--- /dev/null
+++ b/setup/tftpboot/DialTemplate.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco.py b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco.py
index 0fe150d..90fdbd7 100755
--- a/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco.py
+++ b/setup/usr/share/issabel/endpoint-classes/class/issabel/vendor/Cisco.py
@@ -40,6 +40,9 @@ class Endpoint(BaseEndpoint):
def __init__(self, amipool, dbpool, sServerIP, sIP, mac):
BaseEndpoint.__init__(self, 'Cisco', amipool, dbpool, sServerIP, sIP, mac)
+
+ self._timeZone = "SA Eastern Standard Time"
+
if Endpoint._global_serverip == None:
Endpoint._global_serverip = sServerIP
elif Endpoint._global_serverip != sServerIP:
@@ -49,50 +52,80 @@ def __init__(self, amipool, dbpool, sServerIP, sIP, mac):
# TODO: might be possible to derive model from MAC range, requires database change
+
+ def setExtraParameters(self, param):
+ if not BaseEndpoint.setExtraParameters(self, param): return False
+ if 'timeZone' in param: self._timeZone = param['timeZone']
+ return True
+
+
def probeModel(self):
''' Probe specific model of the Cisco phone
- This probe only works if the phone has access to a configuration that
- enables telnet.
+ This probe first tries to get the model using telnet. If that fails,
+ it falls back to extracting the model from the web page.
'''
+ sModel = None
+
+ sModel = self._probeModelTelnet()
+
+ if not sModel:
+ sModel = self._probeModelWeb()
+
+ if sModel:
+ self._saveModel(sModel)
+
+
+ def _probeModelTelnet(self):
+ '''Probe specific model of the Cisco phone using telnet'''
+ sModel = None
try:
telnet = telnetlib.Telnet()
telnet.open(self._ip)
telnet.get_socket().settimeout(10)
- except socket.timeout, e:
- logging.error('Endpoint %s@%s failed to telnet - timeout (%s)' %
- (self._vendorname, self._ip, str(e)))
- return
- except socket.error, e:
- logging.error('Endpoint %s@%s failed to telnet - %s' %
- (self._vendorname, self._ip, str(e)))
- return
-
- sModel = None
-
- try:
+
# Attempt login with default credentials
telnet.read_until('Password :', 10)
telnet.write('cisco\r\n') # Password
idx, m, text = telnet.expect([r'Password :', r'> '], 10)
if idx == 0:
- # Login failed
- telnet.close()
- return
+ raise Exception('Telnet login failed.')
+
telnet.write('show config\r\n')
text = telnet.read_until('> ', 10)
telnet.write('exit\r\n')
- telnet.close()
m = re.search(r'IP Phone CP-(\w+)', text)
- if m != None: sModel = m.group(1)
- except socket.error, e:
+ if m:
+ sModel = m.group(1)
+
+ except Exception, e:
logging.error('Endpoint %s@%s connection failure - %s' %
(self._vendorname, self._ip, str(e)))
- return False
+ finally:
+ telnet.close()
+
+ return sModel
+
+
+ def _probeModelWeb(self):
+ '''Probe specific model of the Cisco phone from its web page'''
+ sModel = None
+ try:
+ response = urllib2.urlopen('http://' + self._ip + '/')
+ htmlbody = response.read()
+
+ # Search for the text that contains the Cisco phone model
+ model_match = re.search(r'IP Phone CP-(\w+)', htmlbody, re.IGNORECASE)
+
+ if model_match:
+ sModel = model_match.group(1)
+ except Exception, e:
+ logging.error('Endpoint %s@%s web connection failure - %s' %
+ (self._vendorname, self._ip, str(e)))
- if sModel != None: self._saveModel(sModel)
+ return sModel
@staticmethod
@@ -125,28 +158,47 @@ def updateGlobalConfig(serveriplist, amipool, endpoints):
logging.error('Failed to write global config for Cisco - %s' % (str(e),))
return False
+
def updateLocalConfig(self):
- '''Configuration for Cisco endpoints (local)
+ '''Update local configuration for Cisco endpoints
+
+ The function generates the configuration file for Cisco endpoints based on the phone's MAC address.
- The file SIPXXXXXXXXXXXX.cnf contains the SIP configuration. Here
- XXXXXXXXXXXX is replaced by the UPPERCASE MAC address of the phone.
+ For XML compatible models, the configuration file is named SEPXXXXXXXXXXXX.cnf.xml,
+ where XXXXXXXXXXXX is the UPPERCASE MAC address of the phone.
+ For XML incompatible models, the configuration file is named SIPXXXXXXXXXXXX.cnf,
+ following the same MAC address format.
+
To reboot the phone, it is necessary to issue the AMI command:
sip notify cisco-check-cfg {$EXTENSION}. Verified with Cisco 7960.
'''
- # 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 UPPERCASE version of MAC address without colons
- sConfigFile = 'SIP' + (self._mac.replace(':', '').upper()) + '.cnf'
- sConfigPath = self._tftpdir + '/' + sConfigFile
- vars = self._prepareVarList()
try:
- self._writeTemplate('Cisco_local_SIP.tpl', vars, sConfigPath)
-
+ # Check that there is at least one account to configure
+ if not self._accounts:
+ raise ValueError('Endpoint %s@%s has no accounts to configure' %
+ (self._vendorname, self._ip))
+
+ # Need to calculate UPPERCASE version of MAC address without colons
+ uppercase_mac = self._mac.replace(':', '').upper()
+ config_file_name ='SEP' + uppercase_mac + '.cnf.xml'
+ config_file_template = 'Cisco_local_SEP.tpl'
+
+ if self._is_xml_incompatible():
+ config_file_name = 'SIP' + uppercase_mac + '.cnf'
+ config_file_template = 'Cisco_local_SIP.tpl'
+
+ config_file_path = self._tftpdir + '/' + config_file_name
+
+ vars = self._prepareVarList()
+ vars.update({
+ 'timeZone':self._timeZone,
+ 'server_port':5060
+ })
+
+
+ self._writeTemplate(config_file_template, vars, config_file_path)
+
# Must execute cisco-check-cfg with extension, not IP
if self._hasRegisteredExtension():
self._amireboot('cisco-check-cfg')
@@ -160,6 +212,18 @@ def updateLocalConfig(self):
logging.error('Endpoint %s@%s failed to write configuration file - %s' %
(self._vendorname, self._ip, str(e)))
return False
+ except Exception, e:
+ logging.error('Endpoint %s@%s failed to update local configuration - %s' %
+ (self._vendorname, self._ip, str(e)))
+ return False
+
+ def _is_xml_incompatible(self):
+ # Implement logic to determine if the model is XML incompatible
+ # For example, check the model name or model number
+ # Return True for Cisco models that are XML incompatible, False otherwise
+ # For demonstration purposes, assuming models 7960 and 7940 are XML incompatible
+ # return self._model in ['7960', '7940']
+ return False
def _rebootbytelnet(self):
'''Start reboot of Cisco phone by telnet'''
@@ -196,4 +260,4 @@ def _rebootbytelnet(self):
logging.error('Endpoint %s@%s connection failure - %s' %
(self._vendorname, self._ip, str(e)))
return False
-
\ No newline at end of file
+
diff --git a/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_SEP.tpl b/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_SEP.tpl
new file mode 100644
index 0000000..cb28bde
--- /dev/null
+++ b/setup/usr/share/issabel/endpoint-classes/tpl/Cisco_local_SEP.tpl
@@ -0,0 +1,403 @@
+
+
+
+ true
+ SIP
+
+ 0
+ true
+ true
+ false
+ false
+
+ 0
+ 0
+
+
+ D/M/Y
+
+ {{time_zone}}
+
+
+ {{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
+ 0
+ true
+ false
+ 1
+
+
+ 6
+ 10
+ 180
+ 3600
+ 5
+ 120
+ 120
+ 5
+ 500
+ 4000
+ 70
+ true
+ Phone
+
+ 1
+ false
+ true
+ true
+ false
+ none
+ 101
+ 3
+ avt
+ false
+ false
+ 0
+
+ 0
+ true
+ 15000
+ 10
+ false
+ 13000
+ 18000
+ false
+ false
+
+
+
+
+ 9
+ {{extension.extension}}
+ USECALLMANAGER
+ {{server_port}}
+ {{extension.extension}}
+ {{extension.extension}}
+
+ 0
+
+ Auto Answer with Speakerphone
+
+ 3
+ {{extension.account}}
+ {{extension.secret}}
+ {{extension.account}}
+ false
+ 3
+ 0
+ *97
+ 4
+ 5
+
+ true
+ true
+ true
+ true
+
+ {{max_sip_accounts}}
+ {{max_sip_accounts}}
+ enable
+
+
+
+
+ 5060
+ 184
+ 136
+ 0
+ DialTemplate.xml
+
+
+ 1
+
+
+
+ true
+ 0
+
+
+
+ false
+ false
+ true
+ true
+ 0
+ 1
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ 1
+ 1
+ 1
+ 0,1,2
+ 1
+ 1
+ 1
+ 0,1
+ 0
+ 0
+ 0
+ 1
+ 1
+ 5
+ 0
+ 0
+
+
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ admin
+ 0
+ 0
+ 1
+ 2
+ 2
+ 1
+ 1
+ 1,7
+ 08:00
+ 10:00
+ 00:10
+ 1
+ 0
+ 1,7
+ 08:00
+ 10:00
+ 00:10
+ 1
+ 0
+ 100
+ 50
+
+ 5
+ 0
+
+
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 2
+
+ 0
+ 0
+
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+
+ d902ed5a-c1e5-4233-b1d6-a960d53d1c3a
+
+
+
+
+
+
+
+
+
+ 1
+
+
+ utf-8
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+
+ 1
+ 3600
+ 1
+ true
+ 0
+ 0
+ 1
+ 5
+ 1
+ 0
+ 0
+ 0
+
+
+ false
+
+
+
+
+
\ No newline at end of file