Saturday, 26 November 2016

List TelePresence devices Existing in CUCM using Python

I recently programmed a python script that shows all of the telepresence devices in my CUCM using AXLAPI. it's easy and fast to know the codec login IPs and registration status.

python 3 keeps lots of potential troubles from you and install library as below. I am sure it's not a difficulty if you had a Linux and python experience before.
#!/usr/bin/python3.4
import ssl
import urllib
import sys, getopt, re, requests
from suds.transport.https import HttpAuthenticated
from suds.client import Client
from suds.sax.element import Element
from xml.etree import ElementTree
from suds.xsd.doctor import Import
from suds.xsd.doctor import ImportDocto
import pickle
import pandas as pd
import numpy as np
next, you need to download AXLAPI.wsdl from CUCM. where it is? see here:

ris_data = []

def pk():
    pickle_in = open("/home/credential/pwds","rb")
    dict = pickle.load(pickle_in)
    return dict

def createClient():
        cmserver = 'YOUR CUCM IP'
        cmport = '8443'
        username = 'AXL ADMIN USERNAME'
        pwd = pk()
        password = pwd[1]
        location = 'https://' + cmserver + ':' + cmport + '/realtimeservice/services/RisPort70?wsdl'
        t = HttpAuthenticated(username=username, password=password)
        t.handler=urllib.request.HTTPBasicAuthHandler(t.pm)
        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE
        t1=urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler,t1)
        wsdl ='file:///opt/tempfile/axlsqltoolkit/schema/current/AXLAPI.wsdl'
        imp = Import('http://schemas.xmlsoap.org/soap/encoding/')
        doctor = ImportDoctor(imp)
        client=Client(url=location, transport=t, doctor=doctor)
        return client
ris_data list stores all results

in pk(), I put all of the AD password in a file and serialised them into a file

createClient() create a session to CUCM with credenticals 

def parse(tp):
        for node in tp['SelectCmDeviceResult'].CmNodes:
            for dev in node.CmDevices:
                name = dev.Name
                desc = dev.Description
                dirn = dev.DirNumber
                ip = "http://" + dev.IPAddress[0][0] + "/web/signin"
                global ris_data
                ris_data.append([desc,name,dirn,ip])

def tpIPsx10(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                                'NodeName':'sampleName.acme.com','Model':'682'})
        parse(tp)
 
def tpIPsx80(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                                'NodeName':'sampleName.acme.com','Model':'688'})
        parse(tp)

def tpIPmx300(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                               'NodeName':'sampleName.acme.com','Model':'690'})
        parse(tp)
      
def tpIPmx800branch(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                                   'NodeName':'sampleName.acme2.com','Model':'36208'})
        parse(tp)

def tpIPmx800(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                                   'NodeName':'sampleName.acme.com','Model':'36208'})
        parse(tp)
   
def tpIPmx700branch(client): 
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any', 
                                                   'NodeName':'sampleName.acme2.com','Model':'36207'})            
        parse(tp)

def tpIPmx800dual(client):
        tp = client.service.SelectCmDevice("", {'SelectBy':'Name', 'Status':'Any', 'Class':'Any',
                                                'NodeName':'sampleName.acme.com','Model':'36227'})
        parse(tp)    
parse() parses results from a client object and puts desired data into ris_data list. the client objects are with each different of telepresence models I have in CUCM.

it's important to know all of the model numbers. issuing the SQL in SSH of CUCM will get them all:

admin:run sql select enum, name from typemodel
enum  name                                              
===== ==================================================
15    EMCC Base Phone                                   
20    SCCP Phone                                        
30    Analog Access                                     
40    Digital Access                                    
42    Digital Access+                                   
43    Digital Access WS-X6608                           
47    Analog Access WS-X6624                            
50    Conference Bridge                                 
51    Conference Bridge WS-X6608                        
62    H.323 Gateway                                     
70    Music On Hold                                     
71    Device Pilot                                      
73    CTI Route Point                                   
80    Voice Mail Port                                   
90    Route List                                        
100   Load Simulator                                    
110   Media Termination Point                           
111   Media Termination Point Hardware                  
120   MGCP Station                                      
121   MGCP Trunk                                        
122   GateKeeper                                        
125   Trunk                                             
126   Tone Announcement Player                          
254   Unknown MGCP Gateway                              
255   Unknown                                           
52    Cisco IOS Conference Bridge (HDV2)                
53    Cisco Conference Bridge (WS-SVC-CMM)              
83    Cisco IOS Software Media Termination Point (HDV2) 
84    Cisco Media Server (WS-SVC-CMM-MS)                
112   Cisco IOS Media Termination Point (HDV2)          
113   Cisco Media Termination Point (WS-SVC-CMM)        
131   SIP Trunk                                         
132   SIP Gateway                                       
133   WSM Trunk                                         
85    Cisco Video Conference Bridge (IPVC-35xx)         
522   BlackBerry MVS VoWifi                             
640   Usage Profile                                     
598   Ascom IP-DECT Device                              
599   Cisco TelePresence Exchange System                
36041 Cisco TelePresence Conductor                      
61    H.323 Phone                                       
72    CTI Port                                          
134   Remote Destination Profile                        
30027 Analog Phone                                      
30028 ISDN BRI Phone                                    
2     Cisco 12 SP+                                      
3     Cisco 12 SP                                       
4     Cisco 12 S                                        
1     Cisco 30 SP+                                      
5     Cisco 30 VIP                                      
9     Cisco 7935                                        
6     Cisco 7910                                        
7     Cisco 7960                                        
8     Cisco 7940                                        
10    Cisco VGC Phone                                   
11    Cisco VGC Virtual Phone                           
48    VGC Gateway                                       
12    Cisco ATA 186                                     
124   7914 14-Button Line Expansion Module              
336   Third-party SIP Device (Basic)                    
374   Third-party SIP Device (Advanced)                 
115   Cisco 7941                                        
119   Cisco 7971                                        
20000 Cisco 7905                                        
302   Cisco 7985                                        
307   Cisco 7911                                        
308   Cisco 7961G-GE                                    
309   Cisco 7941G-GE                                    
335   Motorola CN622                                    
348   Cisco 7931                                        
358   Cisco Unified Personal Communicator               
365   Cisco 7921                                        
369   Cisco 7906                                        
375   Cisco TelePresence                                
376   Nokia S60                                         
30002 Cisco 7920                                        
30006 Cisco 7970                                        
30007 Cisco 7912                                        
30008 Cisco 7902                                        
30016 Cisco IP Communicator                             
30018 Cisco 7961                                        
30019 Cisco 7936                                        
30032 SCCP gateway virtual phone                        
30035 IP-STE                                            
404   Cisco 7962                                        
412   Cisco 3951                                        
431   Cisco 7937                                        
434   Cisco 7942                                        
435   Cisco 7945                                        
436   Cisco 7965                                        
437   Cisco 7975                                        
446   Cisco 3911                                        
550   Cisco ATA 187                                     
631   Third-party AS-SIP Endpoint                       
36049 BEKEM 36-Button Line Expansion Module             
484   Cisco 7925                                        
586   Cisco 8941                                        
645   Universal Device Template                         
688   Cisco TelePresence SX80                           
609   Cisco TelePresence Quick Set C20                  
585   Cisco 8945                                        
228   7915 24-Button Line Expansion Module              
36042 Cisco DX80                                        
620   Cisco TelePresence TX9200                         
86    Cisco IOS Heterogeneous Video Conference Bridge   
642   Carrier-integrated Mobile                         
468   Cisco Unified Mobile Communicator                 
36208 Cisco TelePresence MX800                          
611   Cisco TelePresence Profile 42 (C60)               
557   Cisco TelePresence 200                            
36207 Cisco TelePresence MX700                          
613   Cisco TelePresence Profile 52 (C60)               
608   Cisco TelePresence Codec C40                      
564   Cisco 6945                                        
547   Cisco 6901                                        
562   Cisco Dual Mode for iPhone                        
690   Cisco TelePresence MX300 G2                       
606   Cisco TelePresence Codec C90                      
652   Cisco Jabber for Tablet                           
597   Cisco TelePresence MCU                            
594   VKEM 36-Button Line Expansion Module              
497   Cisco 6961                                        
496   Cisco 6941                                        
520   Cisco TelePresence 1100                           
592   Cisco 3905                                        
36213 Cisco 7811                                        
36043 Cisco DX70                                        
558   Cisco TelePresence 400                            
503   Cisco Unified Client Services Framework           
612   Cisco TelePresence Profile 52 (C40)               
36217 Cisco 8811                                        
577   Cisco 7926                                        
521   Transnova S3                                      
590   Cisco TelePresence 500-32                         
493   Cisco 9971                                        
689   Cisco TelePresence MX200 G2                       
227   7915 12-Button Line Expansion Module              
683   Cisco 8841                                        
682   Cisco TelePresence SX10                           
540   Cisco 8961                                        
604   Cisco TelePresence EX60                           
633   Cisco TelePresence Profile 42 (C40)               
230   7916 24-Button Line Expansion Module              
647   Cisco DX650                                       
229   7916 12-Button Line Expansion Module              
610   Cisco TelePresence Profile 42 (C20)               
616   Cisco TelePresence Profile 65 Dual (C90)          
253   SPA8800                                           
584   Cisco TelePresence EX90                           
588   Generic Desktop Video Endpoint                    
614   Cisco TelePresence Profile 52 Dual (C60)          
681   Cisco ATA 190                                     
617   Cisco TelePresence MX200                          
615   Cisco TelePresence Profile 65 (C60)               
478   Cisco TelePresence 1000                           
623   Cisco 7861                                        
580   Cisco E20                                         
685   Cisco 8861                                        
481   Cisco TelePresence 500-37                         
622   Cisco 7841                                        
634   Cisco VXC 6215                                    
575   Cisco Dual Mode for Android                       
87    Cisco IOS Guaranteed Audio Video Conference Bridge
648   Cisco Unified Communications for RTX              
635   CTI Remote Device                                 
480   Cisco TelePresence 3200                           
582   Generic Single Screen Room System                 
36210 Cisco TelePresence IX5000                         
659   Cisco 8831                                        
505   Cisco TelePresence 1300-65                        
626   Cisco TelePresence SX20                           
548   Cisco 6911                                        
537   Cisco 9951                                        
627   Cisco TelePresence MX300                          
232   CKEM 36-Button Line Expansion Module              
684   Cisco 8851                                        
36232 Cisco 8851NR                                      
36227 Cisco TelePresence MX800 Dual                     
621   Cisco 7821                                        
583   Generic Multiple Screen Room System               
628   IMS-integrated Mobile (Basic)                     
607   Cisco TelePresence Codec C60                      
596   Cisco TelePresence TX1310-65                      
88    Cisco IOS Homogeneous Video Conference Bridge     
479   Cisco TelePresence 3000                           
495   Cisco 6921                                        
619   Cisco TelePresence TX9000                         
591   Cisco TelePresence 1300-47                        
632   Cisco Cius SP                                     
593   Cisco Cius                                        
36224 Cisco 8845                                        
36225 Cisco 8865  
My version of CUCM is 10.5, you may get a difference.
def main(argv):
    CLIENT1 = createClient()
    CLIENT2 = createClient()
    CLIENT3 = createClient()
    CLIENT4 = createClient()
    CLIENT5 = createClient()
    CLIENT6 = createClient()
    CLIENT7 = createClient()
    tpIPsx10(CLIENT1)    
    tpIPmx300(CLIENT2)
    tpIPmx800branch(CLIENT3)
    tpIPmx800(CLIENT4)
    tpIPmx700branch(CLIENT5)
    tpIPmx800dual(CLIENT6)
    tpIPsx80(CLIENT7)
    print(len(ris_data), " Found:")
    pd.set_option('display.max_rows', 500)
    pd.set_option('display.max_columns', 500)
    pd.set_option('display.width', 1000)
    df = pd.DataFrame(ris_data)
    df.index = np.arange(1, len(df) + 1)
    df.columns = ['Room Name', 'Device Name', 'Number-Status', 'Codec Login']
    print (df)
main() function here is to run all of searching methods and panda shows them all in a nice format.

if __name__=='__main__':
        main(sys.argv[1:])
Run my code. if you have any question feel free to leave your comments below.

Cisco AP operational status shows down

Cisco AP operational status shows down in: Cisco Aironet Access Point

Uncheck “Power Injector State” and click apply then reboot AP (Under Wireless > Access Points > All AP’s > Advanced)

Reboot AP by clicking on “reset AP Now” (Under Wireless > Access Points > All AP’s > General)








Then once AP is back up after reboot. Select Power Injector State box and select “Installed” in drop down box and click apply. Which set it to Foreign and but in the MAC address automatically. (Under Wireless > Access Points > All AP’s > Advanced)