/** * Get the service Class given the name in parameter * * @param String $service Name of the service * * @return Core object */ public function getLibClass($service) { switch ($service) { case "Identity": if ($this->tokenPost == NULL) { $this->tokenClass->genIdentityToken(); } $opt = $this->tokenClass->getOptions($service); return $this->openstack->identityV3($opt); break; case "Image": if ($this->tokenPost == NULL) { $this->tokenClass->genImageToken(); } $opt = $this->tokenClass->getOptions($service); return $this->openstack->imagesV2($opt); break; case "Network": if ($this->tokenPost == NULL) { $this->tokenClass->genNetworkToken(); } $opt = $this->tokenClass->getOptions($service); return $this->openstack->networkingV2($opt); break; case "Compute": if ($this->tokenPost == NULL) { $this->tokenClass->genComputeToken(); } $opt = $this->tokenClass->getOptions($service); return $this->openstack->computeV2($opt); break; case "NetworkLayer3": if ($this->tokenPost == NULL) { $this->tokenClass->genNetworkToken(); } $opt = $this->tokenClass->getOptions('Network'); return $this->openstack->networkingV2ExtLayer3($opt); break; } }
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $identity = $openstack->identityV3(['region' => '{region}']); $service = $identity->createService(['name' => '{serviceName}', 'type' => '{serviceType}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $identity = $openstack->identityV3(); $user = $identity->getUser('{id}'); $user->retrieve();
$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); $networkTest = $openstack_api->networkingV2($optionsNetwork); $imageTest = $openstack_api->imagesV2($optionsImage); $domainsTest = $identityTest->listDomains(); echo "Identity Test, List Domains </br>"; foreach ($domainsTest as $domain) { echo $domain->id; echo "</br>"; } echo "</br>"; $imagesTest = $imageTest->listImages(); echo "Image Test, List Images </br>"; foreach ($imagesTest as $image) { echo $image->id; echo "</br>";