cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9379
Views
5
Helpful
15
Comments
szelenka
Cisco Employee
Cisco Employee

I threw together a basic Python script to automate a lot of the mundane configuration requirements between CUP and CUCM for end-user provisioning.  This script takes data from CUCM Bulk Administration tool, then correlates the data and produces a handful of CSV files which can then be uploaded into CUCM/CUP Bulk Administration to configure the system for you.  While the video mentions CUPC, you can use the same CUPC files to configure Jabber softphone devices.

There is a short (13 minute) recording displaying the script in action.  You'll need Python version 2.6.1 or later for the script to run.

For details on how to use the script, you can execute it with the --help flag to display the usage information.  Then after the script is complete, a _LOGFILE_ will be printed with instructions on where to upload and execute the CSV files it created.

This is a 1.0 script supported by myself for the time being.  If you have any comments or questions, please direct them to this discussion post.

Comments
cmcinally
Level 1
Level 1

Where is the video mentioned above?

szelenka
Cisco Employee
Cisco Employee

Not sure what happened.  I re-uploaded it to this document, and the video should now be showing.

t.s.davis
Level 1
Level 1

I was able to run the script and generate the csv files but they are all blank. In the log it shows the following for all users.

"2012-06-04 12:05:49.731000 [ERROR] No match found for user:[userID} with DN:[XXXXXXXX], cannot provision anything for this user"

From your document it looks like the script is taking the TELEPHONE NUMBER field in the user file and matching it to the Directory Number field in the Phones file. In my case, the Telephone Number matches Directory Number 1. However, it's still unable to make a match.

Any ideas?

Thanks!

szelenka
Cisco Employee
Cisco Employee

It's looking at the 'Directory Number' in the --phoneFile then it attempts to match that 'Directory Number' with the 'TELEPHONE NUMBER' of the user as specified in the --userFile after it converts the 'TELEPHONE NUMBER' to a valid E.164 string.

It's fairly strict in how it determines if there's a match.  If you want to PM me the --phoneFile and --userFile, I could test it out in my lab to see why it's not working for you.

t.s.davis
Level 1
Level 1

I had multiple Directory Numbers listed in phone file. (Directory Number 1, Directory Number 2, etc.) I deleted all but the first directory number and it seems to have worked. If I run into another snag, I'll let you tet it out for me. Thanks for your response.

GarrettSkj
Level 1
Level 1

I deleted all columns, but the ones that looked as indicated in the python file, and we are still getting the same errors, Is there a way for it to be more verbose about the error handling, perhaps the rows/fields with invalid data?

In your zip file, it would be nice to include an example of what the output would show as an example, as I could easily write something similiar in perl... Is there another way to see what an example output would be?

I was hoping that there would be something that included the necessary fields in:

http://www.cisco.com/en/US/docs/voice_ip_comm/cucm/bat/8_6_1/t21csvap.html

but alas.

Thanks!

szelenka
Cisco Employee
Cisco Employee

The output of this script should conform to the input specified by the CUCM BAT.  The BAT input examples for each type (Line Apperance, Users, Phones, etc.) are in the Help section for that BAT of the CUCM Administration pages.  You could also look in the Python file and the "new_files" variable around line 110, which is simply an array of objects.  For each object in the array, there will be a "fields" attribute which lists the column names in order they should appear (which was taken directly from the BAT help in CUCM Admin) and a "destination" attribute which denotes where that file is to be uploaded to.  You could copy that format and write your own script in Perl that better suits your environment.

For the Python script, there should be a file in the output folder with the text "cup_user_LOGFILE_<timestamp>.log", if there was any problem parsing the input files to the Python script it should print out verbose information in here.  But as Tim discovered, if there are multiple Directory Number fields in the "userFile" input it will fail; a simple workaround is to remove all the Directory Number fields except for the one you wish to associate with the user then use that CSV file as your "userFile" when executing the Python script.  Then the Python script should be able to identify and match the user with the DN specified and create the associated CSV files to upload back into CUCM.

As for the error messages from CUCM BAT when you try to upload a malformed file, I agree that the errors could be better. 

Tim Smith
Level 4
Level 4

Thank you! fantastic script, thanks for publishing it.

Cheers,

Tim.

Tony_paparazzo
Level 1
Level 1

i really was hoping to get this to work as i have a 1100 user jabber install im doing and i exported like the video states. when i run i get

C:\Python26>python cup_user.py --userFile=Users.txt --phoneFile=PhonesEdit.txt

Traceback (most recent call last):

  File "cup_user.py", line 597, in <module>

    main(sys.argv[1:])

  File "cup_user.py", line 228, in main

    mapped_obj['dn_list'] = get_dn_list(get_file('phone'),dn_cnt)

  File "cup_user.py", line 463, in get_dn_list

    if p['Device Name'] == 'Device Name':

KeyError: 'Device Name'

C:\Python26>python cup_user.py --userFile=Bainusers.txt --phoneFile=HKPhonesEdit

.txt

Traceback (most recent call last):

  File "cup_user.py", line 597, in <module>

    main(sys.argv[1:])

  File "cup_user.py", line 228, in main

    mapped_obj['dn_list'] = get_dn_list(get_file('phone'),dn_cnt)

  File "cup_user.py", line 463, in get_dn_list

    if p['Device Name'] == 'Device Name':

KeyError: 'Device Name'

I deleted all the other info excpet for the Directory Number 1 info. Directory Number 2 and up are gone. Do you know what this error is?

Any help is appreciated


Thanks


Tony

szelenka
Cisco Employee
Cisco Employee

The traceback seems to imply that it cannot find a column named 'Device Name' inside the "HKPhonesEdit.txt" file.

The way this should happen, is at startup it should call "open_file" where it will open "HKPhonesEdit.txt" and then pass its content to "csv.reader" with the delimiter set to ",".  Which it then dumps all that data into an object called "csv" by using "csv.DictReader".  This happens around line 266 in the script.

With that information, "get_dn_list" is called with what should be the "csv" object returned from "open_file". 

If you can PM me the input files you're trying to use, I can try to reproduce and find a fix to this issue.

Marco Torrez
Level 1
Level 1

Hi,

I received the following traceback:

Traceback (most recent call last):

  File "cup_user.py", line 597, in <module>

    main(sys.argv[1:])

  File "cup_user.py", line 228, in main

    mapped_obj['dn_list'] = get_dn_list(get_file('phone'),dn_cnt)

  File "cup_user.py", line 470, in get_dn_list

    o['Directory Number'] = p['Directory Number '+str(dnc)]

KeyError: 'Directory Number 3'

Any help is appreciated


Thanks

matthewosborne
Level 1
Level 1

I am getting the same thing but KeyError: 'Directory Number 2'  Was there ever a fix for it?

mdury
Level 1
Level 1

Hello,

is there a youtube link to the script video? I can;t see it here. 

Thanks

nguzman
Level 1
Level 1

Hello, I can't see the video. Do you have a youtube link for that? Thanks.

benjamind
Level 1
Level 1

Can't see the video, is this outdated anyways or can the script still be usefull for UC Manager 12.5 or 14?

I'd like to provision 2 users to test the Basic Jabber Chat Demo sample code with a DevNet sandbox.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: