cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
976
Views
0
Helpful
0
Replies

UC500 automation and scripting

What's happenin forum?

Anyway, I just wanted to share some scripts I managed to get together with the help of others and the interwebz.  I manage a large infrastructure of  UC520's and UC560's where we have enabled users to dial four digit extensions to reach another user in another office.  The way it works is, since most of the offices are on SIP, they have their own DID numbers.  An ephone-dn is created in each office for that one user (each user in the infrastructure must have a unique extension). For example, where John Smith belongs to the New York office, he also has an entry in the Los Angeles office:

ephone-dn  222

number 1001 no-reg primary (the no-reg is important is you're running SIP!)

name John Smith

call-forward all 912125551234

Now imagine this exact entry in all the other UC500's.  The trouble comes when John Smith is terminated or leaves the company.  So procedure calls for the removal of John Smith from each of the UCs, regardless if there is a replacement or not.  Of course, this can be a disaster to manage.

This is where the script comes in.  Using Perl, it will telnet to each office (other than the originating office; in this example, the New York office) and make the appropriate changes. I made two scripts, one script to remove an ephone-dn, and another add a new user.

The other important thing is keeping track of all the users in each office.  A simple Excel spreadsheet will keep this in check. Since my department is responsible with the removal of the user from the computer and phone systems, I need to have a way to account for each user in each office, along with their ephone-dn number and extension number.

Below is an example of the Perl script. I used Strawberry Perl for Windows, but I'm sure it would work anywhere you can install Perl (Linux, etc). You must have net::telnet::Cisco::IOS installed. (http://search.cpan.org/~kraken/Net-Telnet-Cisco-IOS-0.6beta/lib/Net/Telnet/Cisco/IOS.pm)

Remove_ephonedn.pl


#!/usr/bin/perl
use strict;
use warnings;
use Net::Telnet::Cisco::IOS;
my $username = "username";
my $password = "password";
my %offices = (
ny => '192.168.10.1',
la => '192.168.11.1',
nsh => '192.168.12.1',
chi => '192.168.13.1',
);
print
"Enter the ephone-dn to be removed: ";
chomp (my $ephone_dn = <>);
print "\nAvailable entries:
ny = New York  la = Los Angeles
nsh = Nashville  chi = Chicago

Enter the originating office: ";
chomp (my $office = <>);
foreach my $host ( keys %offices )  {
  
    next if lc($office) eq lc($host);
  
    my $conn = Net::Telnet::Cisco::IOS->new( HOST => $offices{$host} );
    $conn->login( Name => $username, Password => $password);
    $conn->cmd("conf t\n");
$conn->cmd("no ephone-dn  $ephone_dn\n");

    $conn->close;
  
    print "Ephone-dn $ephone_dn removed from $host\n";
}
print "
Press ENTER to exit...";
getc(STDIN);

#USE AT YOUR OWN RISK!!!

Add_ephoneDN.pl

#!/usr/bin/perl
use strict;
use warnings;
use Net::Telnet::Cisco::IOS;
my $username = "username";
my $password = "password";
my %offices = (

ny => '192.168.10.1',
la => '192.168.11.1',
nsh => '192.168.12.1',
chi => '192.168.13.1',
);
print "\nAvailable entries:

ny = New York  la = Los Angeles
nsh = Nashville  chi = Chicago
Enter the originating office: ";
chomp (my $office = <>);
print
"Enter the ephone-dn to be added: ";
chomp (my $ephone_dn = <>);
print "
Enter the first name: ";
chomp (my $firstname = <>);
print "
Enter the last name: ";
chomp (my $lastname = <>);
print "
Enter the new extension number: ";
chomp (my $extension = <>);
print "
Enter the call-forward number: ";
chomp (my $cfwd = <>);
print "
Please review your entries:\n
Originating office: $office
Ephone-dn: $ephone_dn
First name: $firstname
Last name: $lastname
Extension: $extension
Call-forward number: $cfwd
";
print "
Press CTRL+C to quit or press the ENTER key to continue...";
getc(STDIN);
foreach my $host ( keys %offices )  {
  
    next if lc($office) eq lc($host);
  
    my $conn = Net::Telnet::Cisco::IOS->new( HOST => $offices{$host} );
    $conn->login( Name => $username, Password => $password);
    $conn->cmd("conf t\n");
$conn->cmd("ephone-dn  $ephone_dn\n");
$conn->cmd("nu $extension n b\n");
$conn->cmd("na $firstname $lastname\n");
$conn->cmd("call-f a $cfwd\n");
   
    $conn->close;
  
    print "Ephone-dn $ephone_dn entered in $host\n";
}
print "
Press ENTER to exit...";
getc(STDIN);
#USE AT YOUR OWN RISK!!!

As the last line of the script says: (Disclaimer) PLEASE USE THESE SCRIPTS AT YOUR OWN RISK!!! I'm not responsible for anything that happens if you screw this up.

You shouldn't have any problems but, just to "cover my a$$"

Keep in mind that when you build your UC's, you have to make sure that it uses its users' ephone-dns with a high or low number; This way it will not conflict with the ephone-dn number scheme for this purpose.

In my Excel spreadsheet, I have the following example:

NY Office - EphoneDN numberNameExtensionDID
50Main number10002125551000
51George Burns10012125551001
52Steve Wright10022125551002
53John Smith10032125551003

LA Office - EphoneDN numberNameExtensionDID
60Main number11002135559000
61Home Simpson11012135559001
62Ranger Joe11022135559002

If any of you have any questions or suggestions, please let me know. My next project will be to try to get a script to get into the CUE CLI to automate something else.

Good luck,

Renato

0 Replies 0