[freeside-commits] freeside/FS/FS Mason.pm, 1.1, 1.2 Tron.pm, NONE, 1.1 Conf.pm, 1.238, 1.239 cust_svc_option.pm, NONE, 1.1 cust_svc.pm, 1.75, 1.76 Schema.pm, 1.98, 1.99
Ivan,,,
ivan at wavetail.420.am
Thu Aug 21 20:01:07 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv7768/FS/FS
Modified Files:
Mason.pm Conf.pm cust_svc.pm Schema.pm
Added Files:
Tron.pm cust_svc_option.pm
Log Message:
the master control program has chosen YOU to serve your system on the game grid
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- Conf.pm 14 Aug 2008 01:58:30 -0000 1.238
+++ Conf.pm 22 Aug 2008 03:01:05 -0000 1.239
@@ -2357,6 +2357,13 @@
'type' => 'text',
},
+ {
+ 'key' => 'mcp_svcpart',
+ 'section' => '',
+ 'description' => 'Master Control Program svcpart. Leave this blank.',
+ 'type' => 'text',
+ },
+
);
1;
Index: Mason.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Mason.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Mason.pm 21 Jul 2008 18:58:45 -0000 1.1
+++ Mason.pm 22 Aug 2008 03:01:04 -0000 1.2
@@ -93,6 +93,7 @@
use FS::Misc qw( send_email send_fax states_hash counties state_label );
use FS::Report::Table::Monthly;
use FS::TicketSystem;
+ use FS::Tron qw( tron_lint );
use FS::agent;
use FS::agent_type;
Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- cust_svc.pm 5 Jun 2008 19:44:27 -0000 1.75
+++ cust_svc.pm 22 Aug 2008 03:01:05 -0000 1.76
@@ -3,6 +3,7 @@
use strict;
use vars qw( @ISA $DEBUG $me $ignore_quantity );
use Carp;
+#use Scalar::Util qw( blessed );
use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh str2time_sql );
use FS::cust_pkg;
@@ -16,7 +17,7 @@
#most FS::svc_ classes are autoloaded in svc_x emthod
use FS::svc_acct; #this one is used in the cache stuff
- at ISA = qw( FS::cust_main_Mixin FS::Record );
+ at ISA = qw( FS::cust_main_Mixin FS::option_Common ); #FS::Record );
$DEBUG = 0;
$me = '[cust_svc]';
@@ -220,7 +221,13 @@
=cut
sub replace {
+# my $new = shift;
+#
+# my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') )
+# ? shift
+# : $new->replace_old;
my ( $new, $old ) = ( shift, shift );
+ $old = $new->replace_old unless defined($old);
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
@@ -233,8 +240,6 @@
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- $old = $new->replace_old unless defined($old);
-
if ( $new->svcpart != $old->svcpart ) {
my $svc_x = $new->svc_x;
my $new_svc_x = ref($svc_x)->new({$svc_x->hash, svcpart=>$new->svcpart });
@@ -246,6 +251,7 @@
}
}
+ #my $error = $new->SUPER::replace($old, @_);
my $error = $new->SUPER::replace($old);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
--- NEW FILE: Tron.pm ---
package FS::Tron;
# a program to monitor outside systems
use strict;
use warnings;
use base 'Exporter';
use Net::SSH qw( sshopen2 ); #sshopen3 );
use FS::Record qw( qsearchs );
use FS::svc_external;
use FS::cust_svc_option;
our @EXPORT_OK = qw( tron_scan tron_lint);
our %desired = (
#lenient for now, so we can fix up important stuff
'freeside_version' => qr/^1\.(7\.3|9\.0)/,
'debian_version' => qr/^4/,
'apache_mpm' => qw/^(Prefork|$)/,
#stuff to add/replace later
#'pg_version' => qr/^8\.[1-9]/,
#'apache_version' => qr/^2/,
#'apache_mpm' => qw/^Prefork/,
);
sub tron_scan {
my $cust_svc = shift;
my $svc_external;
if ( ref($cust_svc) ) {
$svc_external = $cust_svc->svc_x;
} else {
$svc_external = qsearchs('svc_external', { 'svcnum' => $cust_svc } );
$cust_svc = $svc_external->cust_svc;
}
#don't scan again if things are okay
my $bad = 0;
foreach my $option ( keys %desired ) {
my $current = $cust_svc->option($option);
$bad++ unless $current =~ $desired{$option};
}
return '' unless $bad;
#do the scan
my %hash = ();
my $machine = $svc_external->title; # or better as a cust_svc_option??
sshopen2($machine, *READER, *WRITER, '/usr/local/bin/freeside-yori all');
while (<READER>) {
chomp;
my($option, $value) = split(/: ?/);
next unless defined($option) && exists($desired{$option});
$hash{$option} = $value;
}
close READER;
unless ( keys %hash ) {
return "error scanning $machine\n";
}
# store the results
foreach my $option ( keys %hash ) {
my %opthash = ( 'optionname' => $option,
'svcnum' => $cust_svc->svcnum,
);
my $cust_svc_option = qsearchs('cust_svc_option', \%opthash )
|| new FS::cust_svc_option \%opthash;
next if $cust_svc_option->optionvalue eq $hash{$option};
$cust_svc_option->optionvalue( $hash{$option} );
my $error = $cust_svc_option->optionnum
? $cust_svc_option->replace
: $cust_svc_option->insert;
return $error if $error;
}
'';
}
sub tron_lint {
my $cust_svc = shift;
my @lint;
foreach my $option ( keys %desired ) {
my $current = $cust_svc->option($option);
push @lint, "$option is $current" unless $current =~ $desired{$option};
}
@lint;
}
1;
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- Schema.pm 14 Aug 2008 11:53:40 -0000 1.98
+++ Schema.pm 22 Aug 2008 03:01:05 -0000 1.99
@@ -1003,6 +1003,18 @@
'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
},
+ 'cust_svc_option' => {
+ 'columns' => [
+ 'optionnum', 'serial', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'optionname', 'varchar', '', $char_d, '', '',
+ 'optionvalue', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'svcnum' ], [ 'optionname' ] ],
+ },
+
'part_pkg' => {
'columns' => [
'pkgpart', 'serial', '', '', '', '',
--- NEW FILE: cust_svc_option.pm ---
package FS::cust_svc_option;
use strict;
use vars qw( @ISA );
#use FS::Record qw( qsearch qsearchs );
@ISA = qw(FS::Record);
=head1 NAME
FS::cust_svc_option - Object methods for cust_svc_option records
=head1 SYNOPSIS
use FS::cust_svc_option;
$record = new FS::cust_svc_option \%hash;
$record = new FS::cust_svc_option { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::cust_svc_option object represents an customer service option.
FS::cust_svc_option inherits from FS::Record. The following fields are
currently supported:
=over 4
=item optionnum
primary key
=item svcnum
svcnum (see L<FS::cust_svc>)
=item optionname
Option Name
=item optionvalue
Option Value
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new option. To add the option to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'cust_svc_option'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid option. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $error =
$self->ut_numbern('optionnum')
|| $self->ut_foreign_key('svcnum', 'cust_svc', 'svcnum')
|| $self->ut_alpha('optionname')
|| $self->ut_anything('optionvalue')
;
return $error if $error;
$self->SUPER::check;
}
=back
=head1 BUGS
The author forgot to customize this manpage.
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
More information about the freeside-commits
mailing list