Citycom OAN: Always using last ctag for mgmt
This commit is contained in:
@@ -734,15 +734,22 @@ class Preorder extends mfBaseModel {
|
|||||||
|
|
||||||
// get start of ctag range
|
// get start of ctag range
|
||||||
$first_ctag = $search_ctag - ($search_ctag % $ctags_per_home);
|
$first_ctag = $search_ctag - ($search_ctag % $ctags_per_home);
|
||||||
|
$last_ctag = $first_ctag + $ctags_per_home - 1;
|
||||||
|
|
||||||
|
$mgmt_ctag = null;
|
||||||
$ctag_range = [];
|
$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(!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;
|
$ctag_range[] = $i;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $ctag_range;
|
return [$ctag_range, $mgmt_ctag];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextFreeCtags() {
|
public function getNextFreeCtags() {
|
||||||
@@ -790,7 +797,9 @@ class Preorder extends mfBaseModel {
|
|||||||
$new_ctags[] = $i;
|
$new_ctags[] = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $new_ctags;
|
$mgmt_ctag = array_pop($new_ctags);
|
||||||
|
|
||||||
|
return [$new_ctags, $mgmt_ctag];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOrCreateOaid($oaid_attributes = false) {
|
public function setOrCreateOaid($oaid_attributes = false) {
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ class Citycom_OanApiHelper {
|
|||||||
$execution_date = date("Y-m-d");
|
$execution_date = date("Y-m-d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists("ctag_range_search", $data) && $data["ctag_range_search"]) {
|
if(array_key_exists("ctag_range_search", $data) && $data["ctag_range_search"]) {
|
||||||
$ctag_range_search = $data["ctag_range_search"];
|
$ctag_range_search = $data["ctag_range_search"];
|
||||||
}
|
}
|
||||||
@@ -133,9 +135,9 @@ class Citycom_OanApiHelper {
|
|||||||
$new_services = [];
|
$new_services = [];
|
||||||
|
|
||||||
if($ctag_range_search) {
|
if($ctag_range_search) {
|
||||||
$ctags = $preorder->getFreeCtagsInSet($ctag_range_search);
|
list($ctags, $mgmt_ctag) = $preorder->getFreeCtagsInSet($ctag_range_search);
|
||||||
} else {
|
} else {
|
||||||
$ctags = $preorder->getNextFreeCtags();
|
list($ctags, $mgmt_ctag) = $preorder->getNextFreeCtags();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->log->debug(print_r($ctags, true));
|
$this->log->debug(print_r($ctags, true));
|
||||||
@@ -150,6 +152,8 @@ class Citycom_OanApiHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$preorder_ctag_data = [
|
$preorder_ctag_data = [
|
||||||
"preorder_id" => $preorder->id,
|
"preorder_id" => $preorder->id,
|
||||||
"network" => "citycom-oan",
|
"network" => "citycom-oan",
|
||||||
@@ -161,7 +165,12 @@ class Citycom_OanApiHelper {
|
|||||||
// was this service type requested
|
// was this service type requested
|
||||||
if(!in_array($stype->name, $want_services)) continue;
|
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];
|
$ctag_service_type = array_flip($allowed_service_types)[$stype->name];
|
||||||
if(!$ctag_service_type) {
|
if(!$ctag_service_type) {
|
||||||
$this->log->error(__METHOD__.": Cannot create Service ".$stype->name." for preorder ".$preorder->id." because no ctag service type defined");
|
$this->log->error(__METHOD__.": Cannot create Service ".$stype->name." for preorder ".$preorder->id." because no ctag service type defined");
|
||||||
|
|||||||
@@ -246,7 +246,8 @@ class CitycomImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find ctag and update ext id and status if changed
|
// 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;
|
$stag = $unit->hausnummer->vlan_stag;
|
||||||
if(!$stag) continue;
|
if(!$stag) continue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user