Merge branch 'fronkdev' into 'master'
Added citycom manual service ordering script See merge request fronk/thetool!1598
This commit is contained in:
@@ -64,7 +64,7 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
||||
$data["services"] = CITYCOM_OAN_API_SERVICES_FOR_ORDER;
|
||||
|
||||
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
|
||||
*/
|
||||
public function configureNetwork() {
|
||||
if($this->network == "citycom-oan-api") {
|
||||
if($this->network == "citycom-oan") {
|
||||
return $this->configureNetworkCitycom();
|
||||
}
|
||||
|
||||
@@ -48,15 +48,18 @@ class PreorderCtag extends mfBaseModel {
|
||||
if(!$oaid) {
|
||||
$oaid = $preorder->adb_wohneinheit->oaid;
|
||||
}
|
||||
if(!$oaid) {
|
||||
$this->log->error(__METHOD__.": No OAID in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id);
|
||||
return false;
|
||||
|
||||
if($oaid) {
|
||||
$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) {
|
||||
$this->log->error(__METHOD__.": OAID invalid after cleanup in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id);
|
||||
return false;
|
||||
$oaid = "unit".$preorder->adb_wohneinheit_id;
|
||||
$this->log->warn(__METHOD__.": No OAID in Preorder ".$preorder->id." or Wohneinheit ".$preorder->adb_wohneinheit->id.", using adb_wohneinheit_id '$oaid'");
|
||||
}
|
||||
|
||||
$stag_name = "";
|
||||
@@ -78,7 +81,7 @@ class PreorderCtag extends mfBaseModel {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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)");
|
||||
return false;
|
||||
}
|
||||
$this->log->info(__METHOD__.": done => /interface vlan add: ".print_r($vlan_data, true));
|
||||
|
||||
// add to interface-list
|
||||
|
||||
$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;
|
||||
|
||||
} catch(Exception $e) {
|
||||
@@ -296,12 +301,13 @@ class PreorderCtag extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("oaid", $filter)) {
|
||||
$oaid = FronkDB::singleton()->escape($filter['oaid']);
|
||||
if($oaid) {
|
||||
$where .= " AND PreorderCtag.oaid = '$oaid'";
|
||||
if(array_key_exists("network", $filter)) {
|
||||
$network = FronkDB::singleton()->escape($filter['network']);
|
||||
if($network) {
|
||||
$where .= " AND PreorderCtag.network = '$network'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class Citycom_OanApiHelper {
|
||||
* @param $preorder Preorder
|
||||
* @param $sublocation_id integer
|
||||
* @param $data Array
|
||||
* @return boolean
|
||||
* @return boolean|Array
|
||||
*/
|
||||
public function orderServices($preorder, $sublocation_id, $data) {
|
||||
if(!is_numeric($sublocation_id) || !$sublocation_id) {
|
||||
@@ -117,19 +117,22 @@ class Citycom_OanApiHelper {
|
||||
|
||||
if(!$ctags) {
|
||||
$this->log->error(__METHOD__.": No New Free Ctags (Preorder ".$preorder->id.")");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(count($ctags) < count($want_services)) {
|
||||
$this->log->error(__METHOD__.": Not enough New Free CTags for Preorder ".$preorder->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
$preorder_ctag_data = [
|
||||
"preorder_id" => $preorder->id,
|
||||
"network" => "citycom-oan-api",
|
||||
"network" => "citycom-oan",
|
||||
"stag" => $preorder->adb_hausnummer->vlan_stag,
|
||||
];
|
||||
|
||||
$service_count = 0;
|
||||
$service_return = [];
|
||||
foreach($cc_service_types as $stype) {
|
||||
// was this service type requested
|
||||
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];
|
||||
if(!$ctag_service_type) {
|
||||
$this->log->error(__METHOD__.": Cannot create Service ".$stype->name." for preorder ".$preorder->id." because no ctag service type defined");
|
||||
return false;
|
||||
}
|
||||
|
||||
$service_data = [
|
||||
@@ -152,17 +156,30 @@ class Citycom_OanApiHelper {
|
||||
//continue;
|
||||
|
||||
// register new Service with Citycom
|
||||
/*$new_service = $this->api->createService($service_data);
|
||||
$new_service = $this->api->createService($service_data);
|
||||
if(!$new_service) {
|
||||
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" => [
|
||||
"serial" => "ONT123456",
|
||||
"fsan" => "FSAN7890",
|
||||
],
|
||||
];
|
||||
];*/
|
||||
|
||||
// save ctag
|
||||
$ctag_data = $preorder_ctag_data;
|
||||
@@ -181,13 +198,20 @@ class Citycom_OanApiHelper {
|
||||
$pct->configureNetwork();
|
||||
} catch(Exception $e) {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
59
scripts/citycom/order-service.php
Normal file
59
scripts/citycom/order-service.php
Normal file
@@ -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