stack = HandlerStack::create(); $httpClient['Common'] = new Client([ 'base_uri' => Utils::normalizeUrl($options['authUrl']), 'handler' => $stack, ]); $options['identityService'] = Service::factory($httpClient); $options['authHandler'] = function () use ($options) { return $options['identityService']->generateToken($options); }; $this->optionsGlobal['Common'] = $options; } /** * @codeCoverageIgnore */ private function addDebugMiddleware(array $options, HandlerStack &$stack) { if (!empty($options['debugLog']) && !empty($options['logger']) && !empty($options['messageFormatter']) ) { $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); } } public genComputeToken(){ $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']; } }