[Pkg-voip-commits] [dahdi-tools] 113/285: add new dahdi_genconf generators

tzafrir at debian.org tzafrir at debian.org
Thu Jul 7 19:18:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

tzafrir pushed a commit to branch master
in repository dahdi-tools.

commit 44a5285454166ad798eccf67f120d545a394b2ea
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Mon Sep 23 17:08:49 2013 +0200

    add new dahdi_genconf generators
    
    * pinnedspas: For /etc/dahdi/pinned-spans.conf
    * spantypes: For /etc/dahdi/span-types.conf
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
---
 xpp/perl_modules/Dahdi/Config/Gen/Pinnedspans.pm | 57 ++++++++++++++++++++++++
 xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm   | 57 ++++++++++++++++++++++++
 2 files changed, 114 insertions(+)

diff --git a/xpp/perl_modules/Dahdi/Config/Gen/Pinnedspans.pm b/xpp/perl_modules/Dahdi/Config/Gen/Pinnedspans.pm
new file mode 100644
index 0000000..8eaf72d
--- /dev/null
+++ b/xpp/perl_modules/Dahdi/Config/Gen/Pinnedspans.pm
@@ -0,0 +1,57 @@
+package Dahdi::Config::Gen::Pinnedspans;
+use strict;
+
+use Dahdi::Config::Gen qw(is_true);
+
+sub new($$$) {
+	my $pack = shift || die;
+	my $gconfig = shift || die;
+	my $genopts = shift || die;
+	my $file = $ENV{PINNED_SPANS_CONF_FILE} || "/etc/dahdi/pinned-spans.conf";
+	my $self = {
+			FILE	=> $file,
+			GCONFIG	=> $gconfig,
+			GENOPTS	=> $genopts,
+		};
+	bless $self, $pack;
+	return $self;
+}
+
+sub generate($$$) {
+	my $self = shift || die;
+	my $file = $self->{FILE};
+	my $gconfig = $self->{GCONFIG};
+	my $genopts = $self->{GENOPTS};
+	my @spans = @_;
+	warn "Empty configuration -- no spans\n" unless @spans;
+	rename "$file", "$file.bak"
+		or $! == 2	# ENOENT (No dependency on Errno.pm)
+		or die "Failed to backup old config: $!\n";
+	#$gconfig->dump;
+	print "Generating $file\n" if $genopts->{verbose};
+	my $cmd = "span_assignments dumpconfig > $file";
+	system $cmd;
+	die "Command failed (status=$?): '$cmd'" if $?;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+dahdi - Generate configuration for dahdi drivers.
+
+=head1 SYNOPSIS
+
+ use Dahdi::Config::Gen::Dahdi;
+
+ my $cfg = new Dahdi::Config::Gen::Dahdi(\%global_config, \%genopts);
+ $cfg->generate(@span_list);
+
+=head1 DESCRIPTION
+
+Generate the F</etc/dahdi/pinned-spans.conf>.
+This is the configuration for span_assignments.
+
+Its location may be overriden via the environment variable F<PINNED_SPANS_CONF_FILE>.
diff --git a/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm b/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm
new file mode 100644
index 0000000..1a31a62
--- /dev/null
+++ b/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm
@@ -0,0 +1,57 @@
+package Dahdi::Config::Gen::Spantypes;
+use strict;
+
+use Dahdi::Config::Gen qw(is_true);
+
+sub new($$$) {
+	my $pack = shift || die;
+	my $gconfig = shift || die;
+	my $genopts = shift || die;
+	my $file = $ENV{SPAN_TYPES_CONF_FILE} || "/etc/dahdi/span-types.conf";
+	my $self = {
+			FILE	=> $file,
+			GCONFIG	=> $gconfig,
+			GENOPTS	=> $genopts,
+		};
+	bless $self, $pack;
+	return $self;
+}
+
+sub generate($$$) {
+	my $self = shift || die;
+	my $file = $self->{FILE};
+	my $gconfig = $self->{GCONFIG};
+	my $genopts = $self->{GENOPTS};
+	my @spans = @_;
+	warn "Empty configuration -- no spans\n" unless @spans;
+	rename "$file", "$file.bak"
+		or $! == 2	# ENOENT (No dependency on Errno.pm)
+		or die "Failed to backup old config: $!\n";
+	#$gconfig->dump;
+	print "Generating $file\n" if $genopts->{verbose};
+	my $cmd = "span_types dumpconfig > $file";
+	system $cmd;
+	die "Command failed (status=$?): '$cmd'" if $?;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+dahdi - Generate configuration for dahdi drivers.
+
+=head1 SYNOPSIS
+
+ use Dahdi::Config::Gen::Dahdi;
+
+ my $cfg = new Dahdi::Config::Gen::Dahdi(\%global_config, \%genopts);
+ $cfg->generate(@span_list);
+
+=head1 DESCRIPTION
+
+Generate the F</etc/dahdi/span-types.conf>.
+This is the configuration for span_types.
+
+Its location may be overriden via the environment variable F<SPAN_TYPES_CONF_FILE>.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/dahdi-tools.git



More information about the Pkg-voip-commits mailing list