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>
This commit is contained in:
Oron Peled 2014-04-06 13:01:32 -04:00 committed by Tzafrir Cohen
parent 794c8eb048
commit 1e6b2741db

View File

@ -30,16 +30,21 @@ sub generate($$$) {
return if $?;
my $line_mode = $genopts->{'line-mode'};
$line_mode = 'E1' unless defined $line_mode;
my $cmd;
if (defined $line_mode) {
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
warn "Empty configuration -- no spans\n" unless @spans;
$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 $?;
}