Skip to content

Commit

Permalink
add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-brun committed Jun 4, 2024
1 parent 33021e3 commit 3887029
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions adapters/vnfm_generic/polld/vnfm_generic_poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ function curl_json_output($raw_output)
function get_token($SIGNIN_REQ_PATH, $data, $auth_mode)
{
debug_dump($auth_mode, "get_token() auth_mode\n");
debug_dump($data, "get_token() data\n");
$http_data ="";
if($auth_mode == 'oauth_v2'){
if($auth_mode == 'oauth_v2') {
$http_data = http_build_query($data);
}else if($auth_mode =='keystone'){
}else if($auth_mode =='keystone') {
$http_data = $data;
}

debug_dump($http_data, "get_token() http_data\n");


$url = $SIGNIN_REQ_PATH;
debug_dump($url, "get_token() url\n");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
Expand Down Expand Up @@ -105,14 +105,14 @@ function get_token($SIGNIN_REQ_PATH, $data, $auth_mode)
return false;
}

if($auth_mode == 'oauth_v2'){
if ($auth_mode == 'oauth_v2') {
curl_close($ch);
return curl_json_output($ret)->access_token;
}else if($auth_mode == 'keystone'){
echo "===================================\n";
} else if ($auth_mode == 'keystone') {
echo "===================================\n";
curl_close($ch);
$nav=url_json_output($ret)->X-Subject-Token;
echo "papin: $nav \n";
$nav=url_json_output($ret)->X-Subject-Token;
echo "papin: $nav \n";
return $tok;
}

Expand Down Expand Up @@ -190,12 +190,7 @@ function get_health($PROTOCOL, $ME_IP, $HTTP_PORT, $BASE_URL_MS, $TOKEN, $auth_m

// the configuration vars
$SD_CONFIGVAR_list = $SD->SD_CONFIGVAR_list;
echo("SD_CONFIGVAR_list\n");
print_r($SD_CONFIGVAR_list);
foreach ($SD_CONFIGVAR_list as $var)
{
debug_dump($var, "VAR\n");
}

$missing_conf_vars = array();
$needed_conf_vars = array('PROTOCOL', 'HTTP_PORT', 'BASE_URL_MS', 'SIGNIN_REQ_PATH');

Expand All @@ -216,7 +211,6 @@ function get_health($PROTOCOL, $ME_IP, $HTTP_PORT, $BASE_URL_MS, $TOKEN, $auth_m

if (isset($SD_CONFIGVAR_list['PROTOCOL'])) {
$PROTOCOL = $SD_CONFIGVAR_list['PROTOCOL']->VAR_VALUE;
echo("PROTOCOL : ".$PROTOCOL."\n");
}
if (isset($SD->SD_CONFIGVAR_list['HTTP_PORT'])) {
$HTTP_PORT = $SD->SD_CONFIGVAR_list['HTTP_PORT']->VAR_VALUE;
Expand Down Expand Up @@ -245,10 +239,11 @@ function get_health($PROTOCOL, $ME_IP, $HTTP_PORT, $BASE_URL_MS, $TOKEN, $auth_m
$credentials = array('grant_type' => 'client_credentials',
'client_id' => $ME_USER_NAME,
'client_secret' => $ME_PASSWORD);
if($AUTH_TYPE == 'keystone'){

if($AUTH_TYPE == 'keystone') {
$credentials = "{\"auth\": {\"identity\": {\"methods\": [\"password\"], \"password\": {\"user\": {\"domain\": {\"name\":";
$credentials .= "\"{$user_domain_id}\"},\"name\": \"{$ME_USER_NAME}\",\"password\": \"{$ME_PASSWORD}\"}}},";
$credentials .= "\"scope\": {\"project\": {\"domain\": {\"name\": \"{$project_domain_id}\"}, \"id\": \"{$tenant_id}\"}}}}";
$credentials .= "\"{$user_domain_id}\"},\"name\": \"{$ME_USER_NAME}\",\"password\": \"{$ME_PASSWORD}\"}}},";
$credentials .= "\"scope\": {\"project\": {\"domain\": {\"name\": \"{$project_domain_id}\"}, \"id\": \"{$tenant_id}\"}}}}";
}

$token = get_token($SIGNIN_REQ_PATH, $credentials, $AUTH_TYPE);
Expand Down

0 comments on commit 3887029

Please sign in to comment.