revers
This commit is contained in:
@@ -168,67 +168,33 @@ abstract class BaseController extends Controller
|
|||||||
$result = "Unhandled exception";
|
$result = "Unhandled exception";
|
||||||
$base_url = "http://172.16.4.90:3000";
|
$base_url = "http://172.16.4.90:3000";
|
||||||
$PROJECT_ID= 8;
|
$PROJECT_ID= 8;
|
||||||
|
$cookies = tempnam('/tmp','cookie.txt');
|
||||||
|
|
||||||
|
# 1. Login
|
||||||
$url = $base_url . "/api/project/$PROJECT_ID/tasks";
|
$url = $base_url . "/api/project/$PROJECT_ID/tasks";
|
||||||
$headers = [
|
log_message('critical', "***** ***** ansibleProvision CALL::URL ". $url);
|
||||||
'Content-Type:application/json',
|
|
||||||
'Accept: application/json',
|
|
||||||
'Authorization: Bearer ' . $ansibleToken
|
|
||||||
];
|
|
||||||
$ch = curl_init( $url );
|
$ch = curl_init( $url );
|
||||||
|
# Setup request to send json via POST.
|
||||||
$payload = json_encode( $params );
|
$payload = json_encode( $params );
|
||||||
//$payload = json_encode( array( "template_id"=> 1, "debug" => false, "dry_run" => false, "playbook" => "first-playbook.yml", "environment" => "{}" ) );
|
$authorization = "Authorization: Bearer ".$ansibleToken; // Prepare the authorisation token
|
||||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
|
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
|
||||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',$authorization));
|
||||||
|
# Return response instead of printing.
|
||||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
$res = curl_exec($ch);
|
# Fetch the headers, not the body content:
|
||||||
|
|
||||||
|
# Send request.
|
||||||
|
$result = curl_exec($ch);
|
||||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
$result .= "\n" . 'Launch task HTTP code: ' . $httpcode;
|
$result = 'HTTP code: ' . $httpcode;
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
# 4. Get tasks
|
|
||||||
$url = $base_url . "/api/project/$PROJECT_ID/tasks";
|
|
||||||
$ch = curl_init( $url );
|
|
||||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
|
||||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
|
||||||
$res = curl_exec($ch);
|
|
||||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
$result .= "\n" . 'Get tasks HTTP code: ' . $httpcode;
|
|
||||||
|
|
||||||
curl_close($ch);
|
|
||||||
log_message('critical', "***** ***** Provision :: ansibleProvision($httpcode) ".$httpcode);
|
log_message('critical', "***** ***** Provision :: ansibleProvision($httpcode) ".$httpcode);
|
||||||
ob_start();
|
|
||||||
var_dump($headers);
|
if ($httpcode != "204") {
|
||||||
var_dump($res);
|
return "Login failed! $result";
|
||||||
$result .= "\n" . ob_get_clean();
|
}
|
||||||
// $cookies = tempnam('/tmp','cookie.txt');
|
|
||||||
//
|
|
||||||
// # 1. Login
|
|
||||||
// $url = $base_url . "/api/project/$PROJECT_ID/tasks";
|
|
||||||
// log_message('critical', "***** ***** ansibleProvision CALL::URL ". $url);
|
|
||||||
// $ch = curl_init( $url );
|
|
||||||
// # Setup request to send json via POST.
|
|
||||||
// $payload = json_encode( $params );
|
|
||||||
// $authorization = "Authorization: Bearer ".$ansibleToken; // Prepare the authorisation token
|
|
||||||
// curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
|
|
||||||
// curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',$authorization));
|
|
||||||
// # Return response instead of printing.
|
|
||||||
// curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
|
||||||
// # Fetch the headers, not the body content:
|
|
||||||
//
|
|
||||||
// # Send request.
|
|
||||||
// $result = curl_exec($ch);
|
|
||||||
// $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
// $result = 'HTTP code: ' . $httpcode;
|
|
||||||
//
|
|
||||||
// curl_close($ch);
|
|
||||||
//
|
|
||||||
// log_message('critical', "***** ***** Provision :: ansibleProvision($httpcode) ".$httpcode);
|
|
||||||
//
|
|
||||||
// if ($httpcode != "204") {
|
|
||||||
// return "Login failed! $result";
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user