[freeside-commits] branch master updated. 68cdfc7f046ac2496ed880d93e07f0eae34a5366

Christopher Burger burgerc at freeside.biz
Mon Sep 10 11:28:01 PDT 2018


The branch, master has been updated
       via  68cdfc7f046ac2496ed880d93e07f0eae34a5366 (commit)
       via  28a945ff8daa67036c73ac2287a3f4ebdea6d822 (commit)
      from  3c1586b6d7ae963d7ead013ac84ad5d063741eed (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 68cdfc7f046ac2496ed880d93e07f0eae34a5366
Merge: 28a945ff8 3c1586b6d
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Sep 10 14:26:24 2018 -0400

    Merge branch 'master' of ssh://git.freeside.biz/home/git/freeside


commit 28a945ff8daa67036c73ac2287a3f4ebdea6d822
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon Sep 10 14:25:44 2018 -0400

    RT# 81131 - updated Saisei export to create a virtual ap for multiple ips per customer

diff --git a/FS/FS/part_export/saisei.pm b/FS/FS/part_export/saisei.pm
index 1b7295d04..6db43c11d 100644
--- a/FS/FS/part_export/saisei.pm
+++ b/FS/FS/part_export/saisei.pm
@@ -201,12 +201,28 @@ sub _export_insert {
     my $accesspoint = process_sector($self, $sector_opt);
     return $self->api_error if $self->{'__saisei_error'};
 
+## get custnum and pkgpart from cust_pkg for virtual access point
+    my $cust_pkg = FS::Record::qsearchs({
+      'table'     => 'cust_pkg',
+      'hashref'   => { 'pkgnum' => $svc_broadband->{Hash}->{pkgnum}, },
+    });
+    my $virtual_ap_name = $cust_pkg->{Hash}->{custnum}.'_'.$cust_pkg->{Hash}->{pkgpart}.'_'.$svc_broadband->{Hash}->{speed_down}.'_'.$svc_broadband->{Hash}->{speed_up};
+
+    my $virtual_ap_opt = {
+      'virtual_name'           => $virtual_ap_name,
+      'sector_name'            => $sector_name,
+      'virtual_uprate_limit'   => $svc_broadband->{Hash}->{speed_up},
+      'virtual_downrate_limit' => $svc_broadband->{Hash}->{speed_down},
+    };
+    my $virtual_ap = process_virtual_ap($self, $virtual_ap_opt);
+    return $self->api_error if $self->{'__saisei_error'};
+
     ## tie host to user add sector name as access point.
     $self->api_add_host_to_user(
       $user->{collection}->[0]->{name},
       $rateplan->{collection}->[0]->{name},
       $svc_broadband->{Hash}->{ip_addr},
-      $accesspoint->{collection}->[0]->{name},
+      $virtual_ap->{collection}->[0]->{name},
     ) unless $self->{'__saisei_error'};
   }
 
@@ -216,8 +232,8 @@ sub _export_insert {
 
 sub _export_replace {
   my ($self, $svc_broadband) = @_;
-  $self->_export_insert($svc_broadband);
-  return '';
+  my $error = $self->_export_insert($svc_broadband);
+  return $error;
 }
 
 sub _export_delete {
@@ -817,6 +833,44 @@ sub process_sector {
   return $accesspoint;
 }
 
+sub process_virtual_ap {
+  my ($self, $opt) = @_;
+
+  my $existing_virtual_ap;
+  my $virtual_name = $opt->{virtual_name};
+
+  #check if sector has been set up as an access point.
+  $existing_virtual_ap = $self->api_get_accesspoint($virtual_name);
+
+  # modify the existing virtual accesspoint if changing it. this should never happen
+  $self->api_modify_existing_accesspoint (
+    $virtual_name,
+    $opt->{sector_name},
+    $opt->{virtual_uprate_limit},
+    $opt->{virtual_downrate_limit},
+  ) if $existing_virtual_ap && $opt->{modify_existing};
+
+  #if virtual ap does not exist as an access point create it.
+  $self->api_create_accesspoint(
+    $virtual_name,
+    $opt->{virtual_uprate_limit},
+    $opt->{virtual_downrate_limit},
+  ) unless $existing_virtual_ap;
+
+my $update_sector;
+if ($existing_virtual_ap && ($existing_virtual_ap->{collection}->[0]->{uplink}->{link}->{name} ne $opt->{sector_name})) {
+  $update_sector = 1;
+}
+
+  # Attach newly created virtual ap to tower sector ap or if sector has changed.
+  $self->api_modify_accesspoint($virtual_name, $opt->{sector_name}) unless ($self->{'__saisei_error'} || ($existing_virtual_ap && !$update_sector));
+
+  # set access point to existing one or newly created one.
+  my $accesspoint = $existing_virtual_ap ? $existing_virtual_ap : $self->api_get_accesspoint($virtual_name);
+
+  return $accesspoint;
+}
+
 sub export_provisioned_services {
   my $job = shift;
   my $param = shift;

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

Summary of changes:
 FS/FS/part_export/saisei.pm | 60 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list