Added citycom manual service ordering script
This commit is contained in:
@@ -64,7 +64,7 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
|||||||
$data["services"] = CITYCOM_OAN_API_SERVICES_FOR_ORDER;
|
$data["services"] = CITYCOM_OAN_API_SERVICES_FOR_ORDER;
|
||||||
|
|
||||||
if($preorder->campaign->name == "Citycom - Graz") {
|
if($preorder->campaign->name == "Citycom - Graz") {
|
||||||
$data["product_name"] = "Estmk OAN $bb_down/$bb_up";
|
$data["product_name"] = "Estmk Greenstream OAN $bb_down/$bb_up";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class PreorderCtag extends mfBaseModel {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function configureNetwork() {
|
public function configureNetwork() {
|
||||||
if($this->network == "citycom-oan-api") {
|
if($this->network == "citycom-oan") {
|
||||||
return $this->configureNetworkCitycom();
|
return $this->configureNetworkCitycom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,15 +48,18 @@ class PreorderCtag extends mfBaseModel {
|
|||||||
if(!$oaid) {
|
if(!$oaid) {
|
||||||
$oaid = $preorder->adb_wohneinheit->oaid;
|
$oaid = $preorder->adb_wohneinheit->oaid;
|
||||||
}
|
}
|
||||||
if(!$oaid) {
|
|
||||||
$this->log->error(__METHOD__.": No OAID in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id);
|
if($oaid) {
|
||||||
return false;
|
$oaid = preg_replace('/[^a-z0-9._-]+/i', '', $oaid);
|
||||||
|
if (!$oaid) {
|
||||||
|
$oaid = "unit".$preorder->adb_wohneinheit_id;
|
||||||
|
$this->log->warn(__METHOD__ . ": OAID invalid after cleanup in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id.", using adb_wohneinheit_id '$oaid'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$oaid = preg_replace('/[^a-z0-9._-]+/i', '', $oaid);
|
|
||||||
if(!$oaid) {
|
if(!$oaid) {
|
||||||
$this->log->error(__METHOD__.": OAID invalid after cleanup in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id);
|
$oaid = "unit".$preorder->adb_wohneinheit_id;
|
||||||
return false;
|
$this->log->warn(__METHOD__.": No OAID in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id.", using adb_wohneinheit_id '$oaid'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$stag_name = "";
|
$stag_name = "";
|
||||||
@@ -78,7 +81,7 @@ class PreorderCtag extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$stag_name) {
|
if(!$stag_name) {
|
||||||
$this->log->error(__METHOD__.": Vlan for stag $stag not found");
|
$this->log->error(__METHOD__.": Vlan interface with stag $stag not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +103,12 @@ class PreorderCtag extends mfBaseModel {
|
|||||||
$this->log->error(__METHOD__." error creating vlan interface for ctag $ctag (ifname: ".$vlan_data["name"].") in stag $stag (ifname: $stag_name)");
|
$this->log->error(__METHOD__." error creating vlan interface for ctag $ctag (ifname: ".$vlan_data["name"].") in stag $stag (ifname: $stag_name)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$this->log->info(__METHOD__.": done => /interface vlan add: ".print_r($vlan_data, true));
|
||||||
|
|
||||||
// add to interface-list
|
// add to interface-list
|
||||||
|
|
||||||
$ros->add("/interface list member", ["interface" => $vlan_name, "list" => CITYCOM_OAN_API_NNI_IFLIST_NAME]);
|
$ros->add("/interface list member", ["interface" => $vlan_name, "list" => CITYCOM_OAN_API_NNI_IFLIST_NAME]);
|
||||||
|
$this->log->info(__METHOD__.": done => /interface list member add 'interface' => $vlan_name, 'list' => ".CITYCOM_OAN_API_NNI_IFLIST_NAME);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
@@ -296,12 +301,13 @@ class PreorderCtag extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(array_key_exists("oaid", $filter)) {
|
if(array_key_exists("network", $filter)) {
|
||||||
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
$network = FronkDB::singleton()->escape($filter['network']);
|
||||||
if($oaid) {
|
if($network) {
|
||||||
$where .= " AND PreorderCtag.oaid = '$oaid'";
|
$where .= " AND PreorderCtag.network = '$network'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Citycom_OanApiHelper {
|
|||||||
* @param $preorder Preorder
|
* @param $preorder Preorder
|
||||||
* @param $sublocation_id integer
|
* @param $sublocation_id integer
|
||||||
* @param $data Array
|
* @param $data Array
|
||||||
* @return boolean
|
* @return boolean|Array
|
||||||
*/
|
*/
|
||||||
public function orderServices($preorder, $sublocation_id, $data) {
|
public function orderServices($preorder, $sublocation_id, $data) {
|
||||||
if(!is_numeric($sublocation_id) || !$sublocation_id) {
|
if(!is_numeric($sublocation_id) || !$sublocation_id) {
|
||||||
@@ -117,19 +117,22 @@ class Citycom_OanApiHelper {
|
|||||||
|
|
||||||
if(!$ctags) {
|
if(!$ctags) {
|
||||||
$this->log->error(__METHOD__.": No New Free Ctags (Preorder ".$preorder->id.")");
|
$this->log->error(__METHOD__.": No New Free Ctags (Preorder ".$preorder->id.")");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($ctags) < count($want_services)) {
|
if(count($ctags) < count($want_services)) {
|
||||||
$this->log->error(__METHOD__.": Not enough New Free CTags for Preorder ".$preorder->id);
|
$this->log->error(__METHOD__.": Not enough New Free CTags for Preorder ".$preorder->id);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$preorder_ctag_data = [
|
$preorder_ctag_data = [
|
||||||
"preorder_id" => $preorder->id,
|
"preorder_id" => $preorder->id,
|
||||||
"network" => "citycom-oan-api",
|
"network" => "citycom-oan",
|
||||||
"stag" => $preorder->adb_hausnummer->vlan_stag,
|
"stag" => $preorder->adb_hausnummer->vlan_stag,
|
||||||
];
|
];
|
||||||
|
|
||||||
$service_count = 0;
|
$service_count = 0;
|
||||||
|
$service_return = [];
|
||||||
foreach($cc_service_types as $stype) {
|
foreach($cc_service_types as $stype) {
|
||||||
// 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;
|
||||||
@@ -138,6 +141,7 @@ class Citycom_OanApiHelper {
|
|||||||
$ctag_service_type = array_flip(CITYCOM_OAN_API_SERVICES_FOR_ORDER)[$stype->name];
|
$ctag_service_type = array_flip(CITYCOM_OAN_API_SERVICES_FOR_ORDER)[$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");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$service_data = [
|
$service_data = [
|
||||||
@@ -152,17 +156,30 @@ class Citycom_OanApiHelper {
|
|||||||
//continue;
|
//continue;
|
||||||
|
|
||||||
// register new Service with Citycom
|
// register new Service with Citycom
|
||||||
/*$new_service = $this->api->createService($service_data);
|
$new_service = $this->api->createService($service_data);
|
||||||
if(!$new_service) {
|
if(!$new_service) {
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
$service_return = [
|
$service_return[] = [
|
||||||
|
"sublocation_id" => $sublocation_id,
|
||||||
|
"service_type" => $ctag_service_type,
|
||||||
|
"ctag" => $ctag,
|
||||||
|
"ont" => [
|
||||||
|
"serial" => $new_service->ont->serial,
|
||||||
|
"fsan" => $new_service->ont->fsan,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*$service_return[] = [
|
||||||
|
"sublocation_id" => $sublocation_id,
|
||||||
|
"service_type" => $ctag_service_type,
|
||||||
|
"ctag" => $ctag,
|
||||||
"ont" => [
|
"ont" => [
|
||||||
"serial" => "ONT123456",
|
"serial" => "ONT123456",
|
||||||
"fsan" => "FSAN7890",
|
"fsan" => "FSAN7890",
|
||||||
],
|
],
|
||||||
];
|
];*/
|
||||||
|
|
||||||
// save ctag
|
// save ctag
|
||||||
$ctag_data = $preorder_ctag_data;
|
$ctag_data = $preorder_ctag_data;
|
||||||
@@ -181,13 +198,20 @@ class Citycom_OanApiHelper {
|
|||||||
$pct->configureNetwork();
|
$pct->configureNetwork();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$this->log->error(__METHOD__.": Error configuring network equipment (Preorder ".$preorder->id.")");
|
$this->log->error(__METHOD__.": Error configuring network equipment (Preorder ".$preorder->id.")");
|
||||||
|
|
||||||
|
$mail = new Emailnotification();
|
||||||
|
$mail->setFrom("office@xinon.at");
|
||||||
|
$mail->setTo("schubert@sknetworx.net");
|
||||||
|
$mail->setSubject("Fehler beim Konfigurieren von ctag auf Citycom NNI Router");
|
||||||
|
$mail->setBody("Preorder ID: ".$preorder->id);
|
||||||
|
$mail->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return $service_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//require 'vendor/autoload.php';
|
||||||
|
require("../../config/config.php");
|
||||||
|
|
||||||
|
define('FRONKDB_SQLDEBUG', false);
|
||||||
|
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||||
|
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
||||||
|
|
||||||
|
$me = new User(1);
|
||||||
|
define("INTERNAL_USER_ID", $me->id);
|
||||||
|
define("INTERNAL_USER_USERNAME", $me->username);
|
||||||
|
define("MFBASE_BYPASS_LOGIN", true);
|
||||||
|
|
||||||
|
$cc = new Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||||
|
$cc_helper = new Citycom_OanApiHelper($cc);
|
||||||
|
|
||||||
|
$default_data = [
|
||||||
|
"execution_date" => false,
|
||||||
|
"services" => CITYCOM_OAN_API_SERVICES_FOR_ORDER,
|
||||||
|
];
|
||||||
|
|
||||||
|
$services = [
|
||||||
|
[ // Max Haidvogl, Schillerstraße 11, Tür 1
|
||||||
|
"preorder" => new Preorder(22688),
|
||||||
|
"down" => 600,
|
||||||
|
"up" => 300,
|
||||||
|
"product_name" => "Estmk Greenstream OAN 600/300",
|
||||||
|
],
|
||||||
|
/*[ // Gerd Haidvogl, Schillerstraße 11, Tür 6
|
||||||
|
"preorder" => new Preorder(22682),
|
||||||
|
"down" => 300,
|
||||||
|
"up" => 150,
|
||||||
|
"product_name" => "Greenstream OAN 300/150",
|
||||||
|
],*/
|
||||||
|
/*[ // Robert Rottmann, Lange Gasse 7, Tür 1
|
||||||
|
"preorder" => new Preorder(22679),
|
||||||
|
"down" => 300,
|
||||||
|
"up" => 150,
|
||||||
|
"product_name" => "Greenstream OAN 300/150",
|
||||||
|
]*/
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($services as $service) {
|
||||||
|
$preorder = $service["preorder"];
|
||||||
|
|
||||||
|
$data = $default_data;
|
||||||
|
$data["down"] = $service["down"];
|
||||||
|
$data["up"] = $service["up"];
|
||||||
|
$data["product_name"] = $service["product_name"];
|
||||||
|
$sublocation_id = \Citycom_OanApiHelper::hausnummerExtrefToCitycomId($preorder->adb_wohneinheit->extref);
|
||||||
|
|
||||||
|
var_dump($cc_helper->orderServices($preorder, $sublocation_id, $data));
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user