Test Serialization Token Debut
This commit is contained in:
parent
7276d3f033
commit
6c4cdf62ac
3 changed files with 56 additions and 9 deletions
|
@ -12,15 +12,16 @@ class genTokenOptions
|
|||
private $optionsGlobal;
|
||||
|
||||
private $stack;
|
||||
private $backup = [];
|
||||
|
||||
public function __construct($options){
|
||||
echo "test";
|
||||
|
||||
$this->stack = HandlerStack::create();
|
||||
|
||||
$httpClient['Common'] = new Client([
|
||||
$httpClient = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||
'handler' => $stack,
|
||||
'handler' => $this->stack,
|
||||
]);
|
||||
|
||||
$options['identityService'] = Service::factory($httpClient);
|
||||
|
@ -45,27 +46,57 @@ class genTokenOptions
|
|||
}
|
||||
}
|
||||
|
||||
public genComputeToken(){
|
||||
public function genComputeToken(){
|
||||
$options = $this->optionsGlobal['Common'];
|
||||
$options['catalogName'] = 'nova';
|
||||
$options['catalogType'] = 'compute';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
list($token, $baseUrl) = $options['identityService']->authenticate($options);
|
||||
|
||||
var_dump($token);
|
||||
//$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,
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $this->stack,
|
||||
]);
|
||||
|
||||
$this->backup['Compute'] = array('token' => serialize($token), 'baseUrl' => $baseUrl );
|
||||
$this->optionsGlobal['Compute'] = $options;
|
||||
}
|
||||
|
||||
public function loadComputeBackup($opt){
|
||||
|
||||
$options = $this->optionsGlobal['Common'];
|
||||
$options['catalogName'] = 'nova';
|
||||
$options['catalogType'] = 'compute';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
//list($token, $baseUrl) = $options['identityService']->authenticate($options);
|
||||
$this->backup['Compute'] = unserialize($opt);
|
||||
$token = unserialize($this->backup['Compute'] ['token']);
|
||||
$baseUrl = $this->backup['Compute']['baseUrl'];
|
||||
|
||||
//$stack = HandlerStack::create();
|
||||
|
||||
$this->stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $this->stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $this->stack,
|
||||
]);
|
||||
$this->backup['Compute'] = array('token' => serialize($token), 'baseUrl' => $baseUrl );
|
||||
$this->optionsGlobal['Compute'] = $options;
|
||||
}
|
||||
|
||||
public function getBackup($service){
|
||||
return serialize($this->backup[$service]);
|
||||
}
|
||||
|
||||
public function getOptionsCompute(){
|
||||
return $this->optionsGlobal['Compute'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue