From aeb0373cf5bb2602709ff9d883648ce161a45fb1 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 26 Nov 2025 15:20:36 +0100 Subject: [PATCH] Citycom OAN: Always using last ctag for mgmt --- application/Preorder/Preorder.php | 17 +++++++++++++---- lib/Citycom/OanApiHelper.php | 15 ++++++++++++--- scripts/adb-rimo-import/importer/citycom.php | 3 ++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index ac8c92016..fffeb2fbe 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -734,15 +734,22 @@ class Preorder extends mfBaseModel { // get start of ctag range $first_ctag = $search_ctag - ($search_ctag % $ctags_per_home); + $last_ctag = $first_ctag + $ctags_per_home - 1; + $mgmt_ctag = null; $ctag_range = []; - for($i = $first_ctag; $i < $first_ctag + $ctags_per_home; $i++) { + for($i = $first_ctag; $i <= $last_ctag; $i++) { if(!PreorderCtag::getFirstActive(["stag" => $stag, "ctag" => $i, "network" => $network_name])) { + if($i == $last_ctag) { + // mgmt ctag should be the last in range + $mgmt_ctag = $i; + continue; + } $ctag_range[] = $i; - } + } } - return $ctag_range; + return [$ctag_range, $mgmt_ctag]; } public function getNextFreeCtags() { @@ -790,7 +797,9 @@ class Preorder extends mfBaseModel { $new_ctags[] = $i; } - return $new_ctags; + $mgmt_ctag = array_pop($new_ctags); + + return [$new_ctags, $mgmt_ctag]; } public function setOrCreateOaid($oaid_attributes = false) { diff --git a/lib/Citycom/OanApiHelper.php b/lib/Citycom/OanApiHelper.php index d6765c314..ccd3bacc7 100644 --- a/lib/Citycom/OanApiHelper.php +++ b/lib/Citycom/OanApiHelper.php @@ -94,6 +94,8 @@ class Citycom_OanApiHelper { $execution_date = date("Y-m-d"); } + + if(array_key_exists("ctag_range_search", $data) && $data["ctag_range_search"]) { $ctag_range_search = $data["ctag_range_search"]; } @@ -133,9 +135,9 @@ class Citycom_OanApiHelper { $new_services = []; if($ctag_range_search) { - $ctags = $preorder->getFreeCtagsInSet($ctag_range_search); + list($ctags, $mgmt_ctag) = $preorder->getFreeCtagsInSet($ctag_range_search); } else { - $ctags = $preorder->getNextFreeCtags(); + list($ctags, $mgmt_ctag) = $preorder->getNextFreeCtags(); } $this->log->debug(print_r($ctags, true)); @@ -150,6 +152,8 @@ class Citycom_OanApiHelper { return false; } + + $preorder_ctag_data = [ "preorder_id" => $preorder->id, "network" => "citycom-oan", @@ -161,7 +165,12 @@ class Citycom_OanApiHelper { // was this service type requested if(!in_array($stype->name, $want_services)) continue; - $ctag = $ctags[$service_count]; + // ensure mgmt_ctag is always known (currently last in range) + if($mgmt_ctag && $stype->name == $allowed_service_types["mgmt"]) { + $ctag = $mgmt_ctag; + } else { + $ctag = $ctags[$service_count]; + } $ctag_service_type = array_flip($allowed_service_types)[$stype->name]; if(!$ctag_service_type) { $this->log->error(__METHOD__.": Cannot create Service ".$stype->name." for preorder ".$preorder->id." because no ctag service type defined"); diff --git a/scripts/adb-rimo-import/importer/citycom.php b/scripts/adb-rimo-import/importer/citycom.php index 8f47cc36b..42c39f12c 100644 --- a/scripts/adb-rimo-import/importer/citycom.php +++ b/scripts/adb-rimo-import/importer/citycom.php @@ -246,7 +246,8 @@ class CitycomImporter { } // find ctag and update ext id and status if changed - $stypes = array_flip(CITYCOM_OAN_API_SERVICES_FOR_ORDER); + $valid_stypes = array_merge(CITYCOM_OAN_API_SERVICES_FOR_ORDER, CITYCOM_OAN_API_SERVICES_FOR_RESERVATION); + $stypes = array_flip($valid_stypes); $stag = $unit->hausnummer->vlan_stag; if(!$stag) continue;