Browse Source

dahdi_genconf: remove hard-coded E1 default

* The "spantypes" generator had E1 default if no 'line-mode' parameter
  was passed.

* As a result the new logic in "dahdi_span_types dumpconfig" had no
  effect when called from dahdi_genconf, as it was always called
  with "--line-mode=" argument.

* Now "dahdi_genconf spantype" behaves just like
  "dahdi_span_types dumpconfig":
  - The "--line-mode=" forces generation of provided line-mode (E1/J1/T1)
  - Without this option, the generated config matches the current spans
    state according to new dahd_span_types default logic:
    - Wildcard rule if all spans have same line-mode.
    - Uncommented specific matches if spans have different line-modes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
master
Oron Peled 7 years ago
committed by Tzafrir Cohen
parent
commit
1e6b2741db
  1. 17
      xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm

17
xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm

@ -30,16 +30,21 @@ sub generate($$$) {
return if $?;
my $line_mode = $genopts->{'line-mode'};
$line_mode = 'E1' unless defined $line_mode;
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
warn "Empty configuration -- no spans\n" unless @spans;
my $cmd;
if (defined $line_mode) {
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
$cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
printf("Generating $file (with default line-mode %s)\n", $line_mode)
if $genopts->{verbose};
} else {
$cmd = "dahdi_span_types dumpconfig > $file";
printf("Generating $file (no --line-mode override)\n")
if $genopts->{verbose};
}
rename "$file", "$file.bak"
or $! == 2 # ENOENT (No dependency on Errno.pm)
or die "Failed to backup old config: $!\n";
#$gconfig->dump;
printf("Generating $file (with default line-mode %s)\n", $line_mode)
if $genopts->{verbose};
my $cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
system $cmd;
die "Command failed (status=$?): '$cmd'" if $?;
}

Loading…
Cancel
Save