/** * 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'; use Guzzle\Stream\Stream; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $options = ['name' => 'object_name.txt', 'stream' => new Stream(fopen('/path/to/large_object.mov', 'r'))]; // optional: specify the size of each segment in bytes $options['segmentSize'] = 1073741824; // optional: specify the container where the segments live. This does not necessarily have to be the // same as the container which holds the manifest file $options['segmentContainer'] = 'test_segments'; /** @var \OpenStack\ObjectStore\v1\Models\Object $object */ $object = $openstack->objectStoreV1()->getContainer('test')->createLargeObject($options);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); /** @var \OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroupRule $rule */ $rule = $openstack->networkingV2ExtSecGroups()->getSecurityGroupRule('{id}'); $rule->delete();
<?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();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $networking = $openstack->networkingV2ExtSecGroups(); /** @var \OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup $secGroup */ $secGroup = $networking->getSecurityGroup('{id}'); $secGroup->retrieve();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $openstack->imagesV2()->getImage('{imageId}')->delete();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); /** @var bool $exists */ $exists = $openstack->objectStoreV1()->getContainer('{containerName}')->objectExists('{objectName}');
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $image = $openstack->imagesV2()->getImage('{imageId}'); foreach ($image->listMembers() as $member) { }
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $openstack->objectStoreV1()->getContainer('{containerName}')->getObject('{objectName}')->copy(['destination' => '{newContainerName}/{newObjectName}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $images = $openstack->imagesV2()->listImages(); foreach ($images as $image) { }
<?php ini_set('display_errors', 1); date_default_timezone_set("Europe/Paris"); require 'vendor/autoload.php'; $options = array(); $options["user"] = array("name" => "admin", "password" => "ae5or6cn", "domain" => ["id" => "Default"]); $options["scope"] = array("project" => array("name" => "admin", "domain" => ["id" => "Default"])); $options["authUrl"] = "http://148.60.11.31:5000/v3"; $openstack = new OpenStack\OpenStack($options); $networking = $openstack->networkingV2(["region" => "RegionOne"]); $ls = $networking->getNetwork('5f78d3c1-1f53-4be7-897b-cf3c797961e0'); try { $ls->retrieve(); echo "oui"; } catch (OpenStack\Common\Error\BadResponseError $e) { echo "non"; }
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $member = $openstack->imagesV2()->getImage('{imageId}')->getMember('{tenantId}');
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); $networkTest = $openstack_api->networkingV2($optionsNetwork); $imageTest = $openstack_api->imagesV2($optionsImage); $domainsTest = $identityTest->listDomains(); echo "Identity Test, List Domains </br>";
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $floatingIps = $openstack->networkingV2ExtLayer3()->listFloatingIps(); foreach ($floatingIps as $floatingIp) { /** @var \OpenStack\Networking\v2\Extensions\Layer3\Models\FloatingIp $floatingIp */ }
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $networking = $openstack->networkingV2ExtLayer3(); /** @var \OpenStack\Networking\v2\Extensions\Layer3\Models\FloatingIp $ip */ $ip = $networking->createFloatingIp(["floatingNetworkId" => "{networkId}", "portId" => "{portId}", 'fixedIpAddress' => '{fixedIpAddress}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $openstack->imagesV2()->getImage('{imageId}')->getMember('{tenantId}')->delete();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $service = $openstack->objectStoreV1(); $account = $service->getAccount(); $account->resetMetadata(['{key_1}' => '{val_1}', '{key_2}' => '{val_2}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $container = $openstack->objectStoreV1()->getContainer('{containerName}');
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $openstack->networkingV2ExtLayer3()->getFloatingIp('{id}')->delete();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); /** @var \GuzzleHttp\Stream\Stream $stream */ $stream = $openstack->objectStoreV1()->getContainer('{containerName}')->getObject('{objectName}')->download();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $service = $openstack->blockStorageV2(); $volumeType = $service->createVolumeType(['name' => '{name}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); /** @var array $metadata */ $metadata = $openstack->objectStoreV1()->getContainer('{containerName}')->getMetadata();
<?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}']]]); $openstack->objectStoreV1()->getContainer('{containerName}')->getObject('{objectName}')->mergeMetadata(['{key_1}' => '{val_1}', '{key_2}' => '{val_2}']);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $networking = $openstack->networkingV2(); $options = ['name' => 'My subnet', 'networkId' => '{networkId}', 'ipVersion' => 4, 'cidr' => '192.168.199.0/25', 'gatewayIp' => '192.168.199.128']; // Create the subnet $subnet = $networking->createSubnet($options);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $options = ['name' => '{objectName}', 'content' => '{objectContent}']; /** @var \OpenStack\ObjectStore\v1\Models\Object $object */ $object = $openstack->objectStoreV1()->getContainer('{containerName}')->createObject($options);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $openstack->objectStoreV1()->getContainer('{containerName}')->delete();
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $service = $openstack->imagesV2(); $image = $service->createImage(['name' => '{name}', 'tags' => ['{tag1}', '{tag2}'], 'containerFormat' => '{containerFormat}', 'diskFormat' => '{diskFormat}', 'visibility' => '{visibility}', 'minDisk' => 10, 'protected' => true, 'minRam' => 10]);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $compute = $openstack->computeV2(['region' => '{region}']); $options = ['name' => '{serverName}', 'imageId' => '{imageId}', 'flavorId' => '{flavorId}', 'networks' => [['uuid' => '{networkId}']], 'metadata' => ['foo' => 'bar'], 'userData' => base64_encode('echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt')]; // Create the server /**@var OpenStack\Compute\v2\Models\Server $server */ $server = $compute->createServer($options);
<?php require 'vendor/autoload.php'; $openstack = new OpenStack\OpenStack(['authUrl' => '{authUrl}', 'region' => '{region}', 'user' => ['id' => '{userId}', 'password' => '{password}'], 'scope' => ['project' => ['id' => '{projectId}']]]); $floatingIp = $openstack->networkingV2ExtLayer3()->getFloatingIp('{id}'); $floatingIp->portId = '{newPortId}'; $floatingIp->update();