
multiple API verstions for each service. This included updating the directory structure for the tests and moving the Common files to a Common namespace. Implements blueprint multiple-api-versions Change-Id: I9f9dfc4ef8f4172243519772a9af86dd92690fcf
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../src/OpenStack/Autoloader.php';
|
|
|
|
use \OpenStack\Autoloader;
|
|
use \OpenStack\Identity\v2\IdentityService;
|
|
use \OpenStack\ObjectStore\v1\ObjectStorage;
|
|
use \OpenStack\ObjectStore\v1\ObjectStorage\Object;
|
|
|
|
Autoloader::useAutoloader();
|
|
|
|
// Load these from an ini file.
|
|
$ini = parse_ini_file(getenv('HOME') . '/.OpenStack.ini');
|
|
$username = $ini['username'];
|
|
$password = $ini['password'];
|
|
$tenantId = $ini['tenantId'];
|
|
$endpoint = $ini['url'];
|
|
|
|
$idService = new IdentityService($endpoint);
|
|
$token = $idService->authenticateAsUser($username, $password, $tenantId);
|
|
|
|
$catalog = $idService->serviceCatalog();
|
|
|
|
$store = ObjectStorage::newFromServiceCatalog($catalog, $token);
|
|
|
|
$store->createContainer('Example');
|
|
$container = $store->container('Example');
|
|
|
|
$name = 'hello.txt';
|
|
$content = 'Hello World';
|
|
$mime = 'text/plain';
|
|
|
|
$localObject = new Object($name, $content, $mime);
|
|
$container->save($localObject);
|
|
|
|
$object = $container->object('hello.txt');
|
|
printf("Name: %s \n", $object->name());
|
|
printf("Size: %d \n", $object->contentLength());
|
|
printf("Type: %s \n", $object->contentType());
|
|
print $object->content() . PHP_EOL;
|