[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 1aa2f26487209054ed82f38130c73015635b5705

Ivan ivan at 420.am
Fri Mar 21 11:39:19 PDT 2014


The branch, FREESIDE_2_3_BRANCH has been updated
       via  1aa2f26487209054ed82f38130c73015635b5705 (commit)
       via  00b3fa892f2fe5665fd6415a2806d706bff0e745 (commit)
      from  300c0d096df087565bedd4a1226af1cd0a71b962 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1aa2f26487209054ed82f38130c73015635b5705
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Mar 21 11:39:11 2014 -0700

    add back-office xmlrpc api and daemon, RT#27958

diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index df48802..7d0f10e 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -1,8 +1,9 @@
 package FS::API;
 
 use FS::Conf;
-use FS::Record qw( qsearchs );
+use FS::Record qw( qsearch qsearchs );
 use FS::cust_main;
+use FS::cust_location;
 
 =head1 NAME
 
@@ -40,34 +41,64 @@ Enter cash refund.
 
 #---
 
-#Customer data
-# pull customer info 
-# The fields needed are:
-#
-# cust_main.custnum
-# cust_main.first
-# cust_main.last
-# cust_main.company
-# cust_main.address1
-# cust_main.address2
-# cust_main.city
-# cust_main.state
-# cust_main.zip
-# cust_main.daytime
-# cust_main.night
-# cust_main_invoice.dest
-#
-# at minimum
-
-#Customer balances
-
-#Advertising sources?
-
 # "2 way syncing" ?  start with non-sync pulling info here, then if necessary
 # figure out how to trigger something when those things change
 
 # long-term: package changes?
 
+
+=item new_customer
+
+=cut
+
+#certainly false laziness w/ClientAPI::Signup new_customer/new_customer_minimal
+# but approaching this from a clean start / back-office perspective
+#  i.e. no package/service, no immediate credit card run, etc.
+
+sub new_customer {
+  my( $class, %opt ) = @_;
+  my $conf = new FS::Conf;
+  return { 'error' => 'Incorrect shared secret' }
+    unless $opt{secret} eq $conf->config('api_shared_secret');
+
+  #default agentnum like signup_server-default_agentnum?
+ 
+  #same for refnum like signup_server-default_refnum
+
+  my $cust_main = new FS::cust_main ( {
+      'agentnum'      => $agentnum,
+      'refnum'        => $opt{refnum}
+                         || $conf->config('signup_server-default_refnum'),
+      'payby'         => 'BILL',
+
+      map { $_ => $opt{$_} } qw(
+        agentnum refnum agent_custid referral_custnum
+        last first company 
+        address1 address2 city county state zip country
+        latitude longitude
+        geocode censustract censusyear
+        ship_address1 ship_address2 ship_city ship_county ship_state ship_zip ship_country
+        ship_latitude ship_longitude
+        daytime night fax mobile
+        payby payinfo paydate paycvv payname
+      ),
+
+  } );
+
+  my @invoicing_list = $opt{'invoicing_list'}
+                         ? split( /\s*\,\s*/, $opt{'invoicing_list'} )
+                         : ();
+  push @invoicing_list, 'POST' if $opt{'postal_invoicing'};
+
+  $error = $cust_main->insert( {}, \@invoicing_list );
+  return { 'error'   => $error } if $error;
+  
+  return { 'error'   => '',
+           'custnum' => $cust_main->custnum,
+         };
+
+}
+
 =item customer_info
 
 =cut
@@ -98,15 +129,51 @@ sub customer_info {
     'error'           => '',
     'display_custnum' => $cust_main->display_custnum,
     'name'            => $cust_main->first. ' '. $cust_main->get('last'),
+    'balance'         => $cust_main->balance,
+    'status'          => $cust_main->status,
+    'statuscolor'     => $cust_main->statuscolor,
   );
 
   $return{$_} = $cust_main->get($_)
-    foreach @cust_main_editable_fields;
+    foreach ( @cust_main_editable_fields,
+              @location_editable_fields,
+              map "ship_$_", @location_editable_fields,
+            );
+
+  my @invoicing_list = $cust_main->invoicing_list;
+  $return{'invoicing_list'} =
+    join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list );
+  $return{'postal_invoicing'} =
+    0 < ( grep { $_ eq 'POST' } @invoicing_list );
+
+  #generally, the more useful data from the cust_main record the better.
+  # well, tell me what you want
 
   return \%return;
 
 }
 
+#I also monitor for changes to the additional locations that are applied to
+# packages, and would like for those to be exportable as well.  basically the
+# location data passed with the custnum.
+sub location_info {
+  my( $class, %opt ) = @_;
+  my $conf = new FS::Conf;
+  return { 'error' => 'Incorrect shared secret' }
+    unless $opt{secret} eq $conf->config('api_shared_secret');
+
+  my @cust_location = qsearch('cust_location', { 'custnum' => $opt{custnum} });
+
+  my %return = (
+    'error'           => '',
+    'locations'       => [ map $_->hashref, @cust_location ],
+  );
+
+  return \%return;
+}
+
+#Advertising sources?
+
 =back
 
 1;

commit 00b3fa892f2fe5665fd6415a2806d706bff0e745
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Mar 5 16:07:14 2014 -0800

    add back-office xmlrpc api and daemon, RT#27958
    
    Conflicts:
    	FS/FS/API.pm
    	FS/FS/Conf.pm
    	FS/MANIFEST
    	FS/bin/freeside-selfservice-xmlrpcd
    	FS/bin/freeside-xmlrpcd
    	init.d/freeside-init

diff --git a/FS/FS/API.pm b/FS/FS/API.pm
index 60efd1d..df48802 100644
--- a/FS/FS/API.pm
+++ b/FS/FS/API.pm
@@ -1,9 +1,8 @@
 package FS::API;
 
 use FS::Conf;
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearchs );
 use FS::cust_main;
-use FS::cust_location;
 
 =head1 NAME
 
@@ -41,64 +40,34 @@ Enter cash refund.
 
 #---
 
+#Customer data
+# pull customer info 
+# The fields needed are:
+#
+# cust_main.custnum
+# cust_main.first
+# cust_main.last
+# cust_main.company
+# cust_main.address1
+# cust_main.address2
+# cust_main.city
+# cust_main.state
+# cust_main.zip
+# cust_main.daytime
+# cust_main.night
+# cust_main_invoice.dest
+#
+# at minimum
+
+#Customer balances
+
+#Advertising sources?
+
 # "2 way syncing" ?  start with non-sync pulling info here, then if necessary
 # figure out how to trigger something when those things change
 
 # long-term: package changes?
 
-
-=item new_customer
-
-=cut
-
-#certainly false laziness w/ClientAPI::Signup new_customer/new_customer_minimal
-# but approaching this from a clean start / back-office perspective
-#  i.e. no package/service, no immediate credit card run, etc.
-
-sub new_customer {
-  my( $class, %opt ) = @_;
-  my $conf = new FS::Conf;
-  return { 'error' => 'Incorrect shared secret' }
-    unless $opt{secret} eq $conf->config('api_shared_secret');
-
-  #default agentnum like signup_server-default_agentnum?
- 
-  #same for refnum like signup_server-default_refnum
-
-  my $cust_main = new FS::cust_main ( {
-      'agentnum'      => $agentnum,
-      'refnum'        => $opt{refnum}
-                         || $conf->config('signup_server-default_refnum'),
-      'payby'         => 'BILL',
-
-      map { $_ => $opt{$_} } qw(
-        agentnum refnum agent_custid referral_custnum
-        last first company 
-        address1 address2 city county state zip country
-        latitude longitude
-        geocode censustract censusyear
-        ship_address1 ship_address2 ship_city ship_county ship_state ship_zip ship_country
-        ship_latitude ship_longitude
-        daytime night fax mobile
-        payby payinfo paydate paycvv payname
-      ),
-
-  } );
-
-  my @invoicing_list = $opt{'invoicing_list'}
-                         ? split( /\s*\,\s*/, $opt{'invoicing_list'} )
-                         : ();
-  push @invoicing_list, 'POST' if $opt{'postal_invoicing'};
-
-  $error = $cust_main->insert( {}, \@invoicing_list );
-  return { 'error'   => $error } if $error;
-  
-  return { 'error'   => '',
-           'custnum' => $cust_main->custnum,
-         };
-
-}
-
 =item customer_info
 
 =cut
@@ -129,52 +98,15 @@ sub customer_info {
     'error'           => '',
     'display_custnum' => $cust_main->display_custnum,
     'name'            => $cust_main->first. ' '. $cust_main->get('last'),
-    'balance'         => $cust_main->balance,
-    'status'          => $cust_main->status,
-    'statuscolor'     => $cust_main->statuscolor,
   );
 
   $return{$_} = $cust_main->get($_)
-    foreach ( @cust_main_editable_fields,
-              @location_editable_fields,
-              map "ship_$_", @location_editable_fields,
-            );
-
-  my @invoicing_list = $cust_main->invoicing_list;
-  $return{'invoicing_list'} =
-    join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list );
-  $return{'postal_invoicing'} =
-    0 < ( grep { $_ eq 'POST' } @invoicing_list );
-
-  #generally, the more useful data from the cust_main record the better.
-  # well, tell me what you want
+    foreach @cust_main_editable_fields;
 
   return \%return;
 
 }
 
-
-#I also monitor for changes to the additional locations that are applied to
-# packages, and would like for those to be exportable as well.  basically the
-# location data passed with the custnum.
-sub location_info {
-  my( $class, %opt ) = @_;
-  my $conf = new FS::Conf;
-  return { 'error' => 'Incorrect shared secret' }
-    unless $opt{secret} eq $conf->config('api_shared_secret');
-
-  my @cust_location = qsearch('cust_location', { 'custnum' => $opt{custnum} });
-
-  my %return = (
-    'error'           => '',
-    'locations'       => [ map $_->hashref, @cust_location ],
-  );
-
-  return \%return;
-}
-
-#Advertising sources?
-
 =back
 
 1;
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 1358215..392d426 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5317,6 +5317,27 @@ and customer address. Include units.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'api_shared_secret',
+    'section'     => 'API',
+    'description' => 'Shared secret for back-office API authentication',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'xmlrpc_api',
+    'section'     => 'API',
+    'description' => 'Enable the back-office API XML-RPC server (on port 8008).',
+    'type'        => 'checkbox',
+  },
+
+#  {
+#    'key'         => 'jsonrpc_api',
+#    'section'     => 'API',
+#    'description' => 'Enable the back-office API JSON-RPC server (on port 8081).',
+#    'type'        => 'checkbox',
+#  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 8c114fe..764639c 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -25,6 +25,7 @@ bin/freeside-sqlradius-reset
 bin/freeside-sqlradius-seconds
 bin/freeside-torrus-srvderive
 FS.pm
+FS/API.pm
 FS/AccessRight.pm
 FS/CGI.pm
 FS/InitHandler.pm
@@ -45,6 +46,7 @@ FS/Cron/backup.pm
 FS/Cron/bill.pm
 FS/Cron/vacuum.pm
 FS/Daemon.pm
+FS/Daemon/Preforking.pm
 FS/Maestro.pm
 FS/Misc.pm
 FS/Record.pm
diff --git a/Makefile b/Makefile
index 7ce3d44..4eb1754 100644
--- a/Makefile
+++ b/Makefile
@@ -79,6 +79,7 @@ INSTALLGROUP = root
 #edit the stuff below to have the daemons start
 
 QUEUED_USER=fs_queue
+API_USER = fs_api
 
 SELFSERVICE_USER = fs_selfservice
 #never run on the same machine in production!!!
@@ -215,6 +216,9 @@ perl-modules:
 	  s|%%%FREESIDE_CACHE%%%|${FREESIDE_CACHE}|g;\
 	" blib/lib/FS/cust_main/*.pm blib/lib/FS/cust_pkg/*.pm;\
 	perl -p -i -e "\
+	  s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
+	" blib/lib/FS/Daemon/*.pm;\
+	perl -p -i -e "\
 	  s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
 	  s|%%%FREESIDE_LOG%%%|${FREESIDE_LOG}|g;\
 	  s|%%%FREESIDE_LOCK%%%|${FREESIDE_LOCK}|g;\
@@ -254,6 +258,7 @@ install-init:
 	install -o root -g ${INSTALLGROUP} -m 711 init.d/freeside-init ${INIT_FILE}
 	perl -p -i -e "\
 	  s/%%%QUEUED_USER%%%/${QUEUED_USER}/g;\
+	  s/%%%API_USER%%%/${API_USER}/g;\
 	  s/%%%SELFSERVICE_USER%%%/${SELFSERVICE_USER}/g;\
 	  s/%%%SELFSERVICE_MACHINES%%%/${SELFSERVICE_MACHINES}/g;\
 	" ${INIT_FILE}
diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi
index 02a24ad..a52c1e9 100644
--- a/httemplate/config/config-view.cgi
+++ b/httemplate/config/config-view.cgi
@@ -415,8 +415,11 @@ my @config_items = grep { !defined($locale) or $_->per_locale }
 my @deleteable = qw( invoice_latexreturnaddress invoice_htmlreturnaddress );
 my %deleteable = map { $_ => 1 } @deleteable;
 
-my @sections = qw(required billing invoicing notification UI self-service ticketing network_monitoring username password session shell BIND telephony );
-push @sections, '', 'deprecated';
+my @sections = (qw(
+    required billing invoicing notification UI API self-service ticketing
+    network_monitoring username password session shell BIND telephony
+  ), '', 'deprecated'
+);
 
 my %section_items = ();
 foreach my $section (@sections) {
diff --git a/init.d/freeside-init b/init.d/freeside-init
index 0589ceb..92e3fdf 100644
--- a/init.d/freeside-init
+++ b/init.d/freeside-init
@@ -16,6 +16,7 @@
 ### END INIT INFO
 
 QUEUED_USER=%%%QUEUED_USER%%%
+API_USER=%%%API_USER%%%
 
 SELFSERVICE_USER=%%%SELFSERVICE_USER%%%
 SELFSERVICE_MACHINES="%%%SELFSERVICE_MACHINES%%%"
@@ -31,6 +32,25 @@ export PATH
 case "$1" in
   start)
         # Start daemons.
+
+        for MACHINE in $SELFSERVICE_MACHINES; do
+          echo -n "Starting freeside-selfservice-server to $MACHINE: "
+          freeside-selfservice-server $SELFSERVICE_USER $MACHINE
+          echo "done."
+        done
+
+        echo -n "Starting freeside-selfservice-xmlrpcd: "
+        freeside-selfservice-xmlrpcd $SELFSERVICE_USER
+        echo "done."
+
+        echo -n "Starting freeside-xmlrpcd: "
+        freeside-xmlrpcd $API_USER
+        echo "done."
+
+#        echo -n "Starting freeside-jsonrpcd: "
+#        freeside-jsonrpcd $API_USER
+#        echo "done."
+
         echo -n "Starting freeside-queued: "
         #perl -MDBIx::Profile /usr/local/bin/freeside-queued $QUEUED_USER
         freeside-queued $QUEUED_USER
@@ -54,14 +74,8 @@ case "$1" in
         freeside-cdrd $QUEUED_USER
         echo "done."
 
-        for MACHINE in $SELFSERVICE_MACHINES; do
-          echo -n "Starting freeside-selfservice-server to $MACHINE: "
-          freeside-selfservice-server $SELFSERVICE_USER $MACHINE
-          echo "done."
-        done
-
-        echo -n "Starting freeside-selfservice-xmlrpcd: "
-        freeside-selfservice-xmlrpcd $SELFSERVICE_USER
+        echo -n "Starting freeside-cdrrated: "
+        freeside-cdrrated $QUEUED_USER
         echo "done."
 
         if [ -e /usr/local/bin/torrus ]; then
@@ -112,6 +126,36 @@ case "$1" in
           echo "done."
         fi
 
+        if [ -e /var/run/freeside-cdrrated.pid ]; then
+          echo -n "Stopping freeside-cdrrated: "
+          kill `cat /var/run/freeside-cdrrated.pid`
+          echo "done."
+        fi
+
+        if [ -e /var/run/freeside/torrus-srvderive.pid ]; then
+          echo -n "Stopping freeside-torrus-srvderive: "
+          kill `cat /var/run/freeside/torrus-srvderive.pid`
+          echo "done."
+        fi
+
+        if [ -e /var/run/torrus/collector.main_?.pid ]; then
+          echo -n "Stopping torrus collector: "
+          kill `cat /var/run/torrus/collector.main_?.pid`
+          echo "done."
+        fi
+
+        if [ -e /var/run/freeside/xmlrpcd.pid ]; then
+          echo -n "Stopping freeside-xmlrpcd: "
+          kill `cat /var/run/freeside/xmlrpcd.pid`
+          echo "done."
+        fi
+
+#        if [ -e /var/run/freeside/jsonrpcd.pid ]; then
+#          echo -n "Stopping freeside-jsonrpcd: "
+#          kill `cat /var/run/freeside/jsonrpcd.pid`
+#          echo "done."
+#        fi
+
         if [ -e /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid ]
         then
           echo -n "Stopping (old) freeside-selfservice-server: "
@@ -136,18 +180,6 @@ case "$1" in
           echo "done."
         fi
 
-        if [ -e /var/run/freeside/torrus-srvderive.pid ]; then
-          echo -n "Stopping freeside-torrus-srvderive: "
-          kill `cat /var/run/freeside/torrus-srvderive.pid`
-          echo "done."
-        fi
-
-        if [ -e /var/run/torrus/collector.main_?.pid ]; then
-          echo -n "Stopping torrus collector: "
-          kill `cat /var/run/torrus/collector.main_?.pid`
-          echo "done."
-        fi
-
         ;;
 
   restart)

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/API.pm                      |    1 -
 FS/FS/Conf.pm                     |   21 +++++++++++
 FS/MANIFEST                       |    2 +
 Makefile                          |    5 +++
 httemplate/config/config-view.cgi |    7 +++-
 init.d/freeside-init              |   72 ++++++++++++++++++++++++++----------
 6 files changed, 85 insertions(+), 23 deletions(-)




More information about the freeside-commits mailing list