Wednesday, February 15, 2012

Extension Mobility Login/Logout

Here is some information about what I did for Extension Mobility during an upgrade from 4.x to 7.x, and then a Python script I used for maintenance afterwards. I don't have a CUCM cluster to validate this all on, but this should get you started :)

As part of the upgrade it was indicated that the users should be logged out of EM before the upgrade, and then logged back in after the upgrade. I think I did a report from CUCM that included the logged in user's name, and MAC Address of the phone. I then used Excel and Notepad++ to manipulate the file until I had a file with the following format that I could run as a shell script:

#!/bin/sh

curl -v "http://CUCM/emapp/EMAppServlet?device=SEPDDDDCCCCAAAA&doLogout=true"
sleep .5
curl -v "http://CUCM/emapp/EMAppServlet?device=SEPBBBBCCCCDDDD&doLogout=true"
sleep .5

I then ran that as a shell script to logout the phones, and piped the results into a text file. It was a few years ago, so what I did from here looks a little sketchy, but it looks like I for some reason had run the logout script against all phones (maybe I couldn't get a report in 4.x that included logged in user) and then I worked through the output results to get the phones that had actually been logged into, and determined who's they were based on their description.

Here is the script I used to log them in to the phones in version 7.x - I made sure to set all the PINs to the same value.

#!/bin/sh

curl -v "http://CUCM/emapp/EMAppServlet?device=SEPDDDDCCCCAAAA&userid=jdoe&seq=12345"
sleep 5
curl -v "http://CUCM/emapp/EMAppServlet?device=SEPBBBBCCCCDDDD&userid=jsmith&seq=12345"
sleep 5

I then ran that shell script, and piped the results into an output file for review... Let me know if you have any problems, because I did this several years ago, and like I said I couldn't test it against a CUCM.

After the upgrade I knew there were times that I would need to swap a user's phone, and being able to log them out, and log them in without interaction was going to be useful, so I created these two Python scripts... You will need to modify the IP Address, and the PIN (set to 12345 in the example). Again, I pulled these out of my Dropbox and wrote them at my previous employer, so couldn't test them. BTW - I believe these were setup for Python version 2, but I will try to validate that...

emlogout.py

#! /usr/bin/env python
import urllib2

mac_addr = raw_input("Enter the Mac Address of the Phone: ")
print "You entered: ", mac_addr

emlogout_url = 'http://CUCM/emapp/EMAppServlet?device=SEP' + mac_addr + '&doLogout=true'

print emlogout_url

urllib2.urlopen(emlogout_url)


emlogin.py

#! /usr/bin/env python
import urllib2

mac_addr = raw_input("Enter the Mac Address of the Phone: ")
print "You entered: ", mac_addr
username = raw_input("Enter the User Name in all lowercase: ")
print "You entered: ", username

emlogin_url = 'http://CUCM/emapp/EMAppServlet?device=SEP' + mac_addr + '&userid=' + username + '&seq=12345'

print emlogin_url

urllib2.urlopen(emlogin_url)


Again, let me know if you have any problems, and I will do what I can to help :)

No comments: