diff options
Diffstat (limited to 'xpp/utils/zt_registration')
-rwxr-xr-x | xpp/utils/zt_registration | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/xpp/utils/zt_registration b/xpp/utils/zt_registration new file mode 100755 index 0000000..6ed388f --- /dev/null +++ b/xpp/utils/zt_registration @@ -0,0 +1,77 @@ +#! /usr/bin/perl -w +# +# Written by Oron Peled <oron@actcom.co.il> +# Copyright (C) 2007, Xorcom +# This program is free software; you can redistribute and/or +# modify it under the same terms as Perl itself. +# +#use strict; +BEGIN { my $dir = $0; $dir =~ s:/[^/]+$::; unshift(@INC, "$dir", "$dir/zconf"); } + +use Zaptel; +use Zaptel::Span; +use Zaptel::Xpp; +use Zaptel::Xpp::Xbus; + +sub usage { + die "Usage: $0 [on|off|1|0]\n"; +} + +@ARGV == 0 or @ARGV == 1 or usage; +my $on = shift; + +if(defined($on)) { # Translate to booleans + $on = uc($on); + $on =~ /^(ON|OFF|1|0)$/ or usage; + $on = ($on eq 'ON') ? 1 : 0; +} + +sub state2str($) { + return (shift)?"on":"off"; +} + +my @spans = Zaptel::spans; + +foreach my $xbus (Zaptel::Xpp::xbuses('SORT_CONNECTOR')) { + printf "%-10s\t\t%s\n", $xbus->name, $xbus->connector; + next unless $xbus->status eq 'CONNECTED'; + foreach my $xpd ($xbus->xpds()) { + my $prev = $xpd->zt_registration($on); + printf "\t%-10s: ", $xpd->fqn; + if(!defined($on)) { # Query only + my ($span) = grep { $_->name eq $xpd->fqn } @spans; + my $spanstr = ($span) ? ("Span " . $span->num) : ""; + printf "%s %s\n", state2str($prev), $spanstr; + next; + } + if(!defined($prev)) { # Failure + printf "Failed %s\n", $!; + next; + } + printf("%3s ==> %3s\n", state2str($prev), state2str($on)); + } +} + +__END__ + +=head1 NAME + +zt_registration - Handle registration of Xorcom XPD modules in zaptel. + +=head1 SYNOPSIS + +zt_registration [on|off] + +=head1 DESCRIPTION + +Without parameters, show all connected XPD's sorted by physical connector order. +Each one is show to be unregistered (off), or registered to a specific zaptel span +(the span number is shown). + +All registerations/deregisterations are sorted by physical connector string. + +=head2 Parameters + +off -- deregisters all XPD's from zaptel. + +on -- registers all XPD's to zaptel. |