Clean up logs
This commit is contained in:
@@ -24,4 +24,4 @@ ini_set('display_errors', '0');
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||
|
||||
$_ENV['CONFIG_NAME']='<h1>I beleive you are doing CI envrionment handling wrong. You should define CI_ENVIRONMENT environment variable and utilize the respective app/Config/Boot/...php file</h1><br/>';
|
||||
//$_ENV['CONFIG_NAME']='<h1>I beleive you are doing CI envrionment handling wrong. You should define CI_ENVIRONMENT environment variable and utilize the respective app/Config/Boot/...php file</h1><br/>';
|
||||
|
||||
@@ -5,20 +5,21 @@ namespace App\Controllers;
|
||||
|
||||
class Provision extends BaseController
|
||||
{
|
||||
|
||||
|
||||
public function prepareProvision(): string
|
||||
{
|
||||
|
||||
//http://10.10.10.13:5006/broadcast/provisioning?product_uid=bea86662-adb3-4c09-816b-014f450d9713&provision_action=Auto%20Configuration%20Started
|
||||
|
||||
private function testSocket(): void{
|
||||
// TELL THE SOCKET TO REFRESH PAGE
|
||||
$data["product_uid"] = "bea86662-adb3-4c09-816b-014f450d9713";
|
||||
$data["provision_action"] = "Auto%20Configuration%20Started";
|
||||
$SOCKET_SERVER_LOCATION = $_ENV['SOCKET_SERVER_LOCATION'];
|
||||
log_message('critical', "TEST TEST ***** ***** Provision :: Action To :: " . $SOCKET_SERVER_LOCATION . '/broadcast/provisioning');
|
||||
$this->APIcall("GET", $SOCKET_SERVER_LOCATION . '/broadcast/provisioning', $data);
|
||||
}
|
||||
|
||||
public function prepareProvision(): string
|
||||
{
|
||||
|
||||
//$this->testSocket();
|
||||
$current_database = $_ENV['MAIN_DATABASE_IP'];
|
||||
log_message('critical', "***** ***** prepareProvision :: Working Database ".$current_database );
|
||||
|
||||
log_message('critical', "***** ***** prepareProvision :: Starting Port Allocation ");
|
||||
$this->allocatePortNo(); // allocte port for the conyainer use
|
||||
@@ -93,8 +94,7 @@ class Provision extends BaseController
|
||||
|
||||
$mysql = "UPDATE members_products SET updated=now(), db_status = db_status + 1 WHERE uid::TEXT = '" . $provisionUID . "'";
|
||||
$query = $this->db->query($mysql);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
// echo 'Message: ' .$e->getMessage();
|
||||
log_message('critical', "***** ***** prepareDataBase Error:: () " . $e->getMessage());
|
||||
}
|
||||
@@ -107,9 +107,12 @@ class Provision extends BaseController
|
||||
mysqli_close($conn);
|
||||
return '';
|
||||
}
|
||||
private function generatedContainerName($productId, $provID){
|
||||
|
||||
private function generatedContainerName($productId, $provID)
|
||||
{
|
||||
return $productId . "-SVR-" . str_pad($provID, 10, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function updateProvision(): string
|
||||
{
|
||||
$list_limit = 1; // for noow
|
||||
@@ -181,7 +184,6 @@ class Provision extends BaseController
|
||||
$composer_template_contents = str_replace("TEMPLATE_NAME_REPLACE", $templateRandom, $composer_template_contents);
|
||||
|
||||
|
||||
|
||||
//Save to the specific path
|
||||
$destination_composer_path = $ansible_folder . "/parts/" . $provisionUID . "/docker-compose.yml";
|
||||
$composerFile = fopen($destination_composer_path, "w") or die("Unable to open file!");
|
||||
@@ -204,7 +206,8 @@ class Provision extends BaseController
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function scheduleRefreshAction(){
|
||||
private function scheduleRefreshAction()
|
||||
{
|
||||
$mysql = "SELECT * FROM member_product_refresh WHERE product_id IN ('A000001','A000002') AND status =0 LIMIT 1";
|
||||
$query = $this->db->query($mysql);
|
||||
// $num = $query->num_rows();
|
||||
@@ -217,7 +220,8 @@ class Provision extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function refreshProvision($subscriptionUId){
|
||||
private function refreshProvision($subscriptionUId)
|
||||
{
|
||||
log_message('critical', "***** ***** refreshProvision :: Execute Refresh Provisioning() ");
|
||||
$rsyncPass = "******noNEDD****";
|
||||
// $remote_composer_path = "chiefsoft@10.0.0.32:/home/chiefsoft/MermsProvision/ANSIBLE/parts/";
|
||||
@@ -311,8 +315,7 @@ class Provision extends BaseController
|
||||
if ($ansibleReturn === 200) {
|
||||
log_message('critical', "Calling update_To_Completed ***** " . $ansibleReturn);
|
||||
$this->update_To_Completed($productUid);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
log_message('critical', "Calling WHY PATH update_To_Completed ***** " . $ansibleReturn);
|
||||
$this->update_To_Completed($productUid);
|
||||
}
|
||||
@@ -327,7 +330,8 @@ class Provision extends BaseController
|
||||
$member_product_uid,
|
||||
$member_id,
|
||||
$internal_url
|
||||
){
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
$public_path = FCPATH;
|
||||
@@ -349,7 +353,6 @@ class Provision extends BaseController
|
||||
$destination_composer_path = $ansible_folder . "/parts/" . $provisionUID . "/docker-compose.yml";
|
||||
|
||||
|
||||
|
||||
$allocatedPort = $provisionPort;
|
||||
$this->updateToNow($provisionUID);
|
||||
|
||||
@@ -393,7 +396,9 @@ class Provision extends BaseController
|
||||
fwrite($myfile, $template_content_processed);
|
||||
fclose($myfile);
|
||||
}
|
||||
private function registerProvision($subscriptionId,$prov_name){
|
||||
|
||||
private function registerProvision($subscriptionId, $prov_name)
|
||||
{
|
||||
|
||||
/*
|
||||
CREATE TABLE provision_plans (
|
||||
@@ -417,7 +422,9 @@ class Provision extends BaseController
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private function allocatePortNo(){
|
||||
|
||||
private function allocatePortNo()
|
||||
{
|
||||
$list_limit = 2;
|
||||
$mysql = "SELECT id, member_id, uid, internal_url,product_id,status,provision_port,updated
|
||||
FROM members_products
|
||||
@@ -440,7 +447,8 @@ class Provision extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function allocatePortNumber($productId){
|
||||
private function allocatePortNumber($productId)
|
||||
{
|
||||
$portF = 0;
|
||||
try {
|
||||
$mysql = "SELECT max(provision_port) AS max_port FROM members_products WHERE product_id = '" . $productId . "'";
|
||||
@@ -465,8 +473,7 @@ class Provision extends BaseController
|
||||
$maxItem = 6600;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$maxItem = $maxItem + 1;
|
||||
}
|
||||
$portF = $maxItem;
|
||||
@@ -476,7 +483,8 @@ class Provision extends BaseController
|
||||
return $portF;
|
||||
}
|
||||
|
||||
private function provisionServer($productId){
|
||||
private function provisionServer($productId)
|
||||
{
|
||||
switch ($productId) {
|
||||
case "A000001":
|
||||
case "A000002":
|
||||
@@ -510,7 +518,8 @@ class Provision extends BaseController
|
||||
[A000005_SERVER]
|
||||
172.16.4.95
|
||||
*/
|
||||
private function updateToNow($provisionUID){
|
||||
private function updateToNow($provisionUID)
|
||||
{
|
||||
try {
|
||||
$mysql = "UPDATE members_products SET updated=now(),
|
||||
provision_status=provision_status+1
|
||||
@@ -523,7 +532,8 @@ class Provision extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function provisionActions($memberID, $provisionUID,$actionText){
|
||||
private function provisionActions($memberID, $provisionUID, $actionText)
|
||||
{
|
||||
log_message('critical', "***** ***** Provision :: provisionActions($memberID, $provisionUID,$actionText) ");
|
||||
try {
|
||||
$mysql = "INSERT INTO provision_actions (member_id,product_uid,action) VALUES ($memberID,'$provisionUID', '$actionText')";
|
||||
@@ -545,7 +555,8 @@ class Provision extends BaseController
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function releaseProvision(){
|
||||
public function releaseProvision()
|
||||
{
|
||||
log_message('critical', "***** ***** ReleaseProvision :: Execute Actual Provisioning() ");
|
||||
$PROCESS_LIMIT = 2;
|
||||
$rsyncPass = "******noNEDD****";
|
||||
@@ -640,8 +651,7 @@ class Provision extends BaseController
|
||||
if ($ansibleReturn === 200) {
|
||||
log_message('critical', "Calling update_To_Completed ***** " . $ansibleReturn);
|
||||
$this->update_To_Completed($productUid);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
log_message('critical', "Calling WHY PATH update_To_Completed ***** " . $ansibleReturn);
|
||||
$this->update_To_Completed($productUid);
|
||||
}
|
||||
@@ -649,7 +659,8 @@ class Provision extends BaseController
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function update_To_Completed($provisionUID){
|
||||
private function update_To_Completed($provisionUID)
|
||||
{
|
||||
log_message('critical', "update_To_Completed ******** ***** " . $provisionUID);
|
||||
try {
|
||||
$mysql = "UPDATE members_products SET updated=now(),
|
||||
@@ -685,7 +696,8 @@ class Provision extends BaseController
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
public function directProvision(){
|
||||
public function directProvision()
|
||||
{
|
||||
|
||||
$mysql = "SELECT id AS plan_id, uid, provision_id, play_file from provision_plans ORDER BY updated ASC LIMIT 1 ";
|
||||
$query = $this->db->query($mysql);
|
||||
@@ -711,12 +723,12 @@ class Provision extends BaseController
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public function demo():string {
|
||||
public function demo(): string
|
||||
{
|
||||
|
||||
$PROJECT_ID = 8;
|
||||
$result = "Unhandled exception";
|
||||
@@ -811,7 +823,8 @@ class Provision extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function configureURL(){
|
||||
public function configureURL()
|
||||
{
|
||||
log_message('critical', "***** ***** Configure URL :: Set up URL access for product ");
|
||||
$limit = 1;
|
||||
$mysql = "SELECT id, uid, internal_url,primary_server,provision_port,url_status FROM members_products WHERE url_status = 0 LIMIT $limit";
|
||||
@@ -835,7 +848,8 @@ class Provision extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function haproxy():string {
|
||||
public function haproxy(): string
|
||||
{
|
||||
// $limit = 1;
|
||||
// $mysql = "SELECT
|
||||
// internal_url,
|
||||
@@ -865,7 +879,8 @@ class Provision extends BaseController
|
||||
return "Message:<br/>" . $message;
|
||||
}
|
||||
|
||||
public function configureHaproxyURL($provisionURL, $provisionServer, $provisionPort) {
|
||||
public function configureHaproxyURL($provisionURL, $provisionServer, $provisionPort)
|
||||
{
|
||||
$message = "";
|
||||
$base_url = $_ENV['HAPROXY_SERVER_URL']; //'http://172.16.4.99:5555';
|
||||
$username = $_ENV['HAPROXY_SERVER_USER']; //'admin';
|
||||
@@ -1019,7 +1034,8 @@ curl -X POST --user admin:Hapr0xy001 \
|
||||
return [$status_code[7], "<pre>FIRST CFGVER=$cfgver0\n\n--- CODES: ----$codes\n\nLAST CFGVER=$cfgver</pre>"];
|
||||
}
|
||||
|
||||
private function getHaproxyPost($base_url,$username,$password,$uri,$data) {
|
||||
private function getHaproxyPost($base_url, $username, $password, $uri, $data)
|
||||
{
|
||||
$url = $base_url . $uri;
|
||||
$payload = json_encode($data);
|
||||
$headers = array(
|
||||
@@ -1053,7 +1069,8 @@ curl -X POST --user admin:Hapr0xy001 \
|
||||
return [$status_code, $result];
|
||||
}
|
||||
|
||||
private function getHaproxyGet($base_url,$username,$password,$uri) {
|
||||
private function getHaproxyGet($base_url, $username, $password, $uri)
|
||||
{
|
||||
$url = $base_url . $uri;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@@ -1067,7 +1084,8 @@ curl -X POST --user admin:Hapr0xy001 \
|
||||
return [$status_code, $result];
|
||||
}
|
||||
|
||||
private function getHaproxyCfgVer($base_url,$username,$password) {
|
||||
private function getHaproxyCfgVer($base_url, $username, $password)
|
||||
{
|
||||
return $this->getHaproxyGet($base_url, $username, $password, '/v3/services/haproxy/configuration/version');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user