From: ivan Date: Sat, 8 Jan 2011 00:56:06 +0000 (+0000) Subject: torrus, RT#10574 X-Git-Tag: freeside_2_3_0~784 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=f7e5e7625b04164ce2e0aac77a85bc03a7d48a6f torrus, RT#10574 --- diff --git a/FS/FS/part_pkg/torrus_Common.pm b/FS/FS/part_pkg/torrus_Common.pm index 229a0c32b..d34f72471 100644 --- a/FS/FS/part_pkg/torrus_Common.pm +++ b/FS/FS/part_pkg/torrus_Common.pm @@ -28,13 +28,13 @@ sub calc_usage { my $self = shift; my($cust_pkg, $sdate, $details, $param ) = @_; - my $serviceid = 'TESTING_1'; #XXX from svc_port (loop?) - my $rep_id = 2; #XXX find the one matching the timeframe #SELECT id FROM WHERE reportname = 'MonthlyUsage' AND rep_date = '' #XXX abort if ! iscomplete? + my $serviceid = 'TESTING_1'; #XXX from svc_port (loop?) + my $sql = " SELECT value FROM reportfields WHERE rep_id = $rep_id diff --git a/FS/FS/part_pkg/torrus_bw_percentile.pm b/FS/FS/part_pkg/torrus_bw_percentile.pm new file mode 100644 index 000000000..7cf254ad1 --- /dev/null +++ b/FS/FS/part_pkg/torrus_bw_percentile.pm @@ -0,0 +1,32 @@ +package FS::part_pkg::torrus_bw_percentile; + +use strict; +use base qw( FS::part_pkg::torrus_Common ); +use List::Util qw(max); + +our %info = ( + 'name' => '95th percentile billing based on the integrated Torrus NMS', + 'shortname' => 'Bandwidth (95th percentile)', + 'weight' => 54.5, #:/ + 'inherit_fields' => [ 'flat', 'global_Mixin' ], + 'fields' => { + #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do + 'recur_temporality' => { 'disabled' => 1 }, + 'sync_bill_date' => { 'disabled' => 1 }, + 'cutoff_day' => { 'disabled' => 1 }, + 'base_mbps' => { 'name' => 'Included megabytes/sec (95th percentile)', + 'default' => 0, + }, + 'mbps_rate' => { 'name' => 'Charge per megabyte/sec (95th percentile)', + 'default' => 0, + }, + }, + 'fieldorder' => [ qw( base_mbps mbps_rate ) ], + 'freq' => 'm', +); + +sub _torrus_name { '95TH_PERCENTILE'; } +sub _torrus_base { 'base_mbps'; } +sub _torrus_rate { 'mbps_rate'; } + +1; diff --git a/FS/FS/part_pkg/torrus_bw_usage.pm b/FS/FS/part_pkg/torrus_bw_usage.pm new file mode 100644 index 000000000..5ce2005e8 --- /dev/null +++ b/FS/FS/part_pkg/torrus_bw_usage.pm @@ -0,0 +1,32 @@ +package FS::part_pkg::torrus_bw_usage; + +use strict; +use base qw( FS::part_pkg::torrus_Common ); +use List::Util qw(max); + +our %info = ( + 'name' => 'Volume billing based on the integrated Torrus NMS', + 'shortname' => 'Bandwidth (volume)', + 'weight' => 54.7, #:/ + 'inherit_fields' => [ 'flat', 'global_Mixin' ], + 'fields' => { + #'recur_temporality' => { 'hidden' => 1, 'value' => 'preceding' }, #XXX do + 'recur_temporality' => { 'disabled' => 1 }, + 'sync_bill_date' => { 'disabled' => 1 }, + 'cutoff_day' => { 'disabled' => 1 }, + 'base_gb' => { 'name' => 'Included gigabytes', + 'default' => 0, + }, + 'gb_rate' => { 'name' => 'Charge per gigabyte', + 'default' => 0, + }, + }, + 'fieldorder' => [ qw( base_gb gb_rate ) ], + 'freq' => 'm', +); + +sub _torrus_name { 'VOLUME'; } +sub _torrus_base { 'base_gb'; } +sub _torrus_rate { 'gb_rate'; } + +1; diff --git a/FS/FS/svc_port.pm b/FS/FS/svc_port.pm new file mode 100644 index 000000000..931880e55 --- /dev/null +++ b/FS/FS/svc_port.pm @@ -0,0 +1,212 @@ +package FS::svc_port; + +use strict; +use base qw( FS::svc_Common ); +#use FS::Record qw( qsearch qsearchs ); +use FS::cust_svc; + +=head1 NAME + +FS::svc_port - Object methods for svc_port records + +=head1 SYNOPSIS + + use FS::svc_port; + + $record = new FS::svc_port \%hash; + $record = new FS::svc_port { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + + $error = $record->suspend; + + $error = $record->unsuspend; + + $error = $record->cancel; + +=head1 DESCRIPTION + +An FS::svc_port object represents a router port. FS::table_name inherits from +FS::svc_Common. The following fields are currently supported: + +=over 4 + +=item svcnum - + +=item serviceid - Torrus serviceid (in srvexport and reportfields tables) + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new port. To add the port 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 method. + +=cut + +sub table { 'svc_port'; } + +sub table_info { + { + 'name' => 'Port', + #'name_plural' => 'Ports', #optional, + #'longname_plural' => 'Ports', #optional + 'sorts' => [ 'svcnum', 'serviceid' ], # optional sort field (or arrayref of sort fields, main first) + 'display_weight' => 75, + 'cancel_weight' => 10, + 'fields' => { + 'serviceid' => 'Torrus serviceid', + }, + }; +} + +=item search_sql STRING + +Class method which returns an SQL fragment to search for the given string. + +=cut + +#or something more complicated if necessary +sub search_sql { + my($class, $string) = @_; + $class->search_sql_field('serviceid', $string); +} + +=item label + +Returns a meaningful identifier for this port + +=cut + +sub label { + my $self = shift; + $self->serviceid; #or something more complicated if necessary +} + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +The additional fields pkgnum and svcpart (see L) should be +defined. An FS::cust_svc record will be created and inserted. + +=cut + +sub insert { + my $self = shift; + my $error; + + $error = $self->SUPER::insert; + return $error if $error; + + ''; +} + +=item delete + +Delete this record from the database. + +=cut + +sub delete { + my $self = shift; + my $error; + + $error = $self->SUPER::delete; + return $error if $error; + + ''; +} + + +=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 + +sub replace { + my ( $new, $old ) = ( shift, shift ); + my $error; + + $error = $new->SUPER::replace($old); + return $error if $error; + + ''; +} + +=item suspend + +Called by the suspend method of FS::cust_pkg (see L). + +=item unsuspend + +Called by the unsuspend method of FS::cust_pkg (see L). + +=item cancel + +Called by the cancel method of FS::cust_pkg (see L). + +=item check + +Checks all fields to make sure this is a valid port. If there is +an error, returns the error, otherwise returns false. Called by the insert +and repalce methods. + +=cut + +sub check { + my $self = shift; + + my $x = $self->setfixed; + return $x unless ref($x); + my $part_svc = $x; + + my $error = $self->ut_textn('serviceid'); #too lenient? + return $error if $error; + + $self->SUPER::check; +} + +=item + +Returns a PNG graph for this port. + +XXX Options + +=cut + +sub graph_png { + my $self = shift; + my $serviceid = $self->serviceid; + + +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, +L, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/MANIFEST b/FS/MANIFEST index f6d660228..cdb2851b9 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -552,3 +552,7 @@ FS/part_pkg_vendor.pm t/part_pkg_vendor.t FS/cust_note_class.pm t/cust_note_class.t +FS/svc_port.pm +t/svc_port.t +FS/h_svc_port.pm +t/h_svc_port.t diff --git a/FS/t/h_svc_port.t b/FS/t/h_svc_port.t new file mode 100644 index 000000000..c75d203df --- /dev/null +++ b/FS/t/h_svc_port.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::h_svc_port; +$loaded=1; +print "ok 1\n"; diff --git a/FS/t/svc_port.t b/FS/t/svc_port.t new file mode 100644 index 000000000..d6f269146 --- /dev/null +++ b/FS/t/svc_port.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::svc_port; +$loaded=1; +print "ok 1\n"; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 437f7e850..d608657dc 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -11,27 +11,9 @@ Service
Disable new orders {disabled} eq 'Y' ? ' CHECKED' : '' %>>
+
-Service definitions are the templates for items you offer to your customers. -
  • svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.) -
  • svc_domain - Domains -
  • svc_cert - Certificates -
  • svc_dsl - DSL -
  • svc_forward - Mail forwarding -
  • svc_mailinglist - Mailing list -
  • svc_www - Virtual domain website -
  • svc_broadband - Broadband/High-speed Internet service (always-on) -
  • svc_phone - Customer phone numbers -
  • svc_pbx - Customer PBXs -
  • svc_external - Externally-tracked service - -
-For the selected table, you can give fields default or fixed (unchangable) -values, or select an inventory class to manually or automatically fill in -that field. -

+ % #YUCK. false laziness w/part_svc.pm. go away virtual fields, please % my %vfields; @@ -100,6 +82,8 @@ that field. % % my $html = qq!!; % +% $html .= $svcdb_info; +% % my $columns = 3; % my $count = 0; % my $communigate = 0; @@ -126,7 +110,7 @@ that field. % $count++; % $html .= '' unless $count % $columns; % } -% $html .= '

'; +% $html .= '

'. $mod_info; % % $html .= include('/elements/table-grid.html', 'cellpadding' => 4 ). % ''. @@ -454,6 +438,70 @@ my %communigate_fields = ( #'svc_cert' => { map { $_=>1 } qw( ) }, ); +my $svcdb_info = ' + + + + + + + + + + + + +
GenericAccessTelephony
+
    +
  • svc_acct: Accounts - anything with a username (mailbox, shell, RADIUS, etc.) +
  • svc_external: Externally-tracked service +
+
+
    +
  • svc_dsl: DSL +
  • svc_broadband: Wireless broadband +
+
+
    +
  • svc_phone: Customer phone number +
  • svc_pbx: Customer PBX +
+
+
+ + + + + + + + +
HostingColocation
+
    +
  • svc_domain: Domain +
  • svc_cert: Certificate +
  • svc_forward: Mail forwarding +
  • svc_mailinglist: Mailing list +
  • svc_www: Virtual domain website +
+
+
    +
  • svc_port: Customer router/switch port +
+
+ +'; + +my $mod_info = ' +For the selected table, you can give fields default or fixed (unchangable) +values, or select an inventory class to manually or automatically fill in +that field. +'; + diff --git a/torrus/FREESIDE_INSTALL b/torrus/FREESIDE_INSTALL index 7432c0048..130168b60 100644 --- a/torrus/FREESIDE_INSTALL +++ b/torrus/FREESIDE_INSTALL @@ -1,11 +1,13 @@ i should move to the wiki once this is further along -aptitude install rrdtool librrds-perl libxml-libxml-perl libberkeleydb-perl libtemplate-perl libproc-daemon-perl libnet-snmp-perl libapache-session-perl libjson-perl +aptitude install rrdtool librrds-perl libxml-libxml-perl libberkeleydb-perl libtemplate-perl libproc-daemon-perl libnet-snmp-perl libapache-session-perl libjson-perl libdbix-abstract-perl libdbix-sequence-perl # in Makefile, set TORRUS_ENABLED = 1 make configure-torrus make deploy +set network_monitoring_system config setting to Torrus_Internal + #a little more one-offy from here so far http://torrus.org/install.pod.html#configuring_torrus : @@ -44,5 +46,27 @@ but do go from http://torrus.org/install.pod.html#cron_job on #--- -this seems to be required on restarts during dev (upgrades?) -rm /var/torrus/cache/* /var/torrus/db/render_cache.db +http://torrus.org/reporting_setup.pod.html + +cd /usr/local/etc/torrus/discovery +vi routers.ddx + + + + TESTING_1:TenGigabitEthernet2_1:Both:main, + TESTING_2:TenGigabitEthernet2_2:Both:main, + + +torrus devdiscover --in=routers.ddx +torrus compile --tree=main --verbose + +#kill collector, then restart +torrus collector --tree=main + +#--- + +add serviceids + +in freeside, setup svc_port service defs, packages with torrus billing types +order the package, provision an svc_port with a valid serviceid + diff --git a/torrus/FREESIDE_MODIFIED b/torrus/FREESIDE_MODIFIED new file mode 100644 index 000000000..34c361a73 --- /dev/null +++ b/torrus/FREESIDE_MODIFIED @@ -0,0 +1,12 @@ +configs/torrus-siteconfig.pl #turn of torrus auth, set URLs +perllib/Torrus/CGI.pm # header/footer +perllib/Torrus/Freeside.pm # header/footer +perllib/Torrus/Renderer.pm # header/footer + perllib/Torrus/Renderer/Freeside.pm # header/footer +perllib/Torrus/Renderer/Frontpage.pm # header/footer +perllib/Torrus/Renderer/HTML.pm # header/footer + perllib/Torrus/ReportOutput/Freeside.pm # header/footer +perllib/Torrus/ReportOutput/HTML.pm # header/footer +templates/html-incblocks.txt # header/footer +tempaltes/default-rrd.html # title beautification +sup/webplain/torrus.css #skinning