Suite Test Token Management
This commit is contained in:
parent
de1f302047
commit
7276d3f033
3 changed files with 38 additions and 37 deletions
|
@ -10,47 +10,26 @@ use OpenStack\Common\Transport\Utils;
|
||||||
class genTokenOptions
|
class genTokenOptions
|
||||||
{
|
{
|
||||||
private $optionsGlobal;
|
private $optionsGlobal;
|
||||||
|
|
||||||
|
private $stack;
|
||||||
|
|
||||||
public function __construct($options, $token){
|
public function __construct($options){
|
||||||
echo "test";
|
echo "test";
|
||||||
|
|
||||||
$stack = HandlerStack::create();
|
$this->stack = HandlerStack::create();
|
||||||
//IdentityService?
|
|
||||||
// $options['IdentityService'] pas oblige?...
|
|
||||||
// creer HttpClient authurl HandlerStack::create()
|
|
||||||
// $option['identityService'] = factory httpClient
|
|
||||||
//$httpClient = new Client([
|
|
||||||
// 'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
|
||||||
// 'handler' => HandlerStack::create(),
|
|
||||||
//]);
|
|
||||||
|
|
||||||
$httpClient = new Client([
|
$httpClient['Common'] = new Client([
|
||||||
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$options['identityService'] = Service::factory($httpClient);
|
$options['identityService'] = Service::factory($httpClient);
|
||||||
//AuthHadler?
|
|
||||||
//
|
|
||||||
$options['authHandler'] = function () use ($options) {
|
$options['authHandler'] = function () use ($options) {
|
||||||
return $options['identityService']->generateToken($options);
|
return $options['identityService']->generateToken($options);
|
||||||
};
|
};
|
||||||
//StockClient?
|
|
||||||
// creer $options['httpClient'] instance de ClientInterface
|
|
||||||
// token, baseUrl = identity->authenticate
|
|
||||||
// stack = getStack authhandler token
|
|
||||||
// addDebug??
|
|
||||||
// $options['httpClient'] = httpCLient baseurl stack
|
|
||||||
$baseUrl = $options['authUrl'];
|
|
||||||
|
|
||||||
//$stack = HandlerStack::create();
|
$this->optionsGlobal['Common'] = $options;
|
||||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
|
||||||
|
|
||||||
$this->addDebugMiddleware($options, $stack);
|
|
||||||
|
|
||||||
$options['httpClient'] = $httpClient;
|
|
||||||
|
|
||||||
$this->optionsGlobal = $options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +45,28 @@ class genTokenOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptions(){
|
public genComputeToken(){
|
||||||
return $this->optionsGlobal;
|
$options = $this->optionsGlobal['Common'];
|
||||||
|
$options['catalogName'] = 'nova';
|
||||||
|
$options['catalogType'] = 'compute';
|
||||||
|
$options['region'] = 'RegionOne';
|
||||||
|
|
||||||
|
list($token, $baseUrl) = $options['identityService']->authenticate($options);
|
||||||
|
|
||||||
|
//$stack = HandlerStack::create();
|
||||||
|
$this->stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||||
|
|
||||||
|
$this->addDebugMiddleware($options, $this->stack);
|
||||||
|
|
||||||
|
$options['httpClient'] = new Client([
|
||||||
|
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||||
|
'handler' => $stack,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->optionsGlobal['Compute'] = $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOptionsCompute(){
|
||||||
|
return $this->optionsGlobal['Compute'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
//$id = new identity($openstack_api, $pluginApi);
|
//$id = new identity($openstack_api, $pluginApi);
|
||||||
|
|
||||||
// var_dump($id->genToken());
|
// var_dump($id->genToken());
|
||||||
$compute = $openstack_api->computeV2(['region'=> 'RegionOne']);
|
$compute = $openstack_api->computeV2($array);
|
||||||
$servers = $compute->listServers(true);
|
$servers = $compute->listServers(true);
|
||||||
var_dump($servers);
|
var_dump($servers);
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,14 @@
|
||||||
|
|
||||||
$pluginApi = plugin_api::getInstance();
|
$pluginApi = plugin_api::getInstance();
|
||||||
|
|
||||||
$openstack_api = new OpenStack\OpenStack($Args);
|
//$openstack_api = new OpenStack\OpenStack($Args);
|
||||||
$id = new identity($openstack_api, $pluginApi);
|
//$id = new identity($openstack_api, $pluginApi);
|
||||||
|
|
||||||
$token = $id->genToken();
|
//$token = $id->genToken();
|
||||||
|
|
||||||
$tmp = new genTokenOptions($Args, $token);
|
$tmp = new genTokenOptions($Args);
|
||||||
$array = $tmp->getOptions();
|
$tmp->genComputeToken();
|
||||||
$openstack_api = new OpenStack\OpenStack($array);
|
$array = $tmp->getOptionsCompute();
|
||||||
|
$openstack_api = new OpenStack\OpenStack(new array());
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue