/** * Generate the token for the different services in OpenStack * * @return void */ public function authenticate() { try { $this->tokenClass->genIdentityToken(); $this->tokenClass->genComputeToken(); $this->tokenClass->genImageToken(); $this->tokenClass->genNetworkToken(); $this->setOutput("token", $this->tokenClass->getBackup()); } catch (BadResponseError $e) { $this->errorClass->BadResponseHandler($e); } catch (UserInputError $e) { $this->errorClass->UserInputHandler($e); } catch (BaseError $e) { $this->errorClass->BaseErrorHandler($e); } catch (NotImplementedError $e) { $this->errorClass->NotImplementedHandler($e); } }
<?php include_once "config.inc.php"; require "../vendor/autoload.php"; include_once "core/Plugin_Api.php"; include_once "core/LibOverride/genTokenOptions.php"; $user = "******"; $password = "******"; $project = "admin"; $Args = array("user" => array("name" => $user, "password" => $password, "domain" => array("name" => "Default")), "scope" => array("project" => array("name" => $project, "domain" => array("name" => "Default"))), "authUrl" => $config["urlAuth"]); $genOptions = new genTokenOptions($Args); $genOptions->genIdentityToken(); $genOptions->genComputeToken(); $genOptions->genNetworkToken(); $genOptions->genImageToken(); $backCompute = $genOptions->getBackup("Compute"); $backIdentity = $genOptions->getBackup("Identity"); $backNetwork = $genOptions->getBackup("Network"); $backImage = $genOptions->getBackup("Image"); $openstack_api = new OpenStack\OpenStack([]); $newGenOptions = new genTokenOptions($Args); $newGenOptions->loadIdentityBackup($backIdentity); $newGenOptions->loadComputeBackup($backCompute); $newGenOptions->loadImageBackup($backImage); $newGenOptions->loadNetworkBackup($backNetwork); $optionsCompute = $newGenOptions->getOptions("Compute"); $optionsIdentity = $newGenOptions->getOptions("Identity"); $optionsNetwork = $newGenOptions->getOptions("Network"); $optionsImage = $newGenOptions->getOptions("Image"); $identityTest = $openstack_api->identityV3($optionsIdentity); $computeTest = $openstack_api->computeV2($optionsCompute);