Removed all deprecated functionality and updated docs and tests as needed.
Implements blueprint remove-deprecated Change-Id: If363d7d551e00ad23e317f29f267a2bfb02a7785
This commit is contained in:
parent
3b63d64d4f
commit
bcdcba06f7
|
@ -61,7 +61,8 @@ use OpenStack\Common\Transport\GuzzleClient;
|
|||
* - During authentication, provide a tenant ID. This will attach a tenant at
|
||||
* the outset.
|
||||
* - After authentication, "rescope" the token to attach it to a tenant. This
|
||||
* is done with the rescope() method.
|
||||
* is done with either the rescopeUsingTenantId() or rescopeUsingTenantName()
|
||||
* method.
|
||||
*
|
||||
* Where do I get a tenant ID?
|
||||
*
|
||||
|
@ -101,7 +102,7 @@ use OpenStack\Common\Transport\GuzzleClient;
|
|||
* $tenants = $ident->tenants();
|
||||
*
|
||||
* // Switch to a different tenant.
|
||||
* $ident->rescope($tenants[0]['id']);
|
||||
* $ident->rescopeUsingTenantId($tenants[0]['id']);
|
||||
*
|
||||
* ?>
|
||||
*
|
||||
|
@ -112,7 +113,8 @@ use OpenStack\Common\Transport\GuzzleClient;
|
|||
* - authenticate()
|
||||
* - authenticateAsUser()
|
||||
* - tenants()
|
||||
* - rescope()
|
||||
* - rescopeUsingTenantId()
|
||||
* - rescopeUsingTenantName()
|
||||
*
|
||||
* Serializing
|
||||
*
|
||||
|
@ -303,7 +305,7 @@ class IdentityService
|
|||
* given, not both.
|
||||
*
|
||||
* If no tenant ID or tenant Name is given, it will likely be necessary to
|
||||
* rescope() the request (See also tenants()).
|
||||
* rescopeUsingTenantId() the request (See also tenants()).
|
||||
*
|
||||
* Other authentication methods:
|
||||
* - authenticate()
|
||||
|
@ -612,15 +614,6 @@ class IdentityService
|
|||
}
|
||||
|
||||
/**
|
||||
* @see \OpenStack\Identity\v2\IdentityService::rescopeUsingTenantId()
|
||||
* @deprecated
|
||||
*/
|
||||
public function rescope($tenantId)
|
||||
{
|
||||
return $this->rescopeUsingTenantId($tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rescope the authentication token to a different tenant.
|
||||
*
|
||||
* Note that this will rebuild the service catalog and user information for
|
||||
|
|
|
@ -40,15 +40,8 @@ use OpenStack\Common\Transport\GuzzleClient;
|
|||
* to PHP's streams system. For common use of an object store, you may
|
||||
* prefer to use that system. (@see \OpenStack\Bootstrap).
|
||||
*
|
||||
* When constructing a new ObjectStorage object, you will need to know
|
||||
* what kind of authentication you are going to perform. Older
|
||||
* implementations of OpenStack provide a separate authentication
|
||||
* mechanism for Swift. You can use ObjectStorage::newFromSwiftAuth() to
|
||||
* perform this type of authentication.
|
||||
*
|
||||
* Newer versions use the IdentityService authentication mechanism (@see
|
||||
* \OpenStack\Identity\v2\IdentityService). That method is the preferred
|
||||
* method.
|
||||
* To authenticate, use the IdentityService authentication mechanism (@see
|
||||
* \OpenStack\Identity\v2\IdentityService).
|
||||
*
|
||||
* Common Tasks
|
||||
*
|
||||
|
@ -85,66 +78,6 @@ class ObjectStorage
|
|||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Create a new instance after getting an authentication token.
|
||||
*
|
||||
* THIS METHOD IS DEPRECATED. OpenStack now uses Keyston to authenticate.
|
||||
* You should use \OpenStack\Identity\v2\IdentityService to authenticate.
|
||||
* Then use this class's constructor to create an object.
|
||||
*
|
||||
* This uses the legacy Swift authentication facility to authenticate
|
||||
* to swift, get a new token, and then create a new ObjectStorage
|
||||
* instance with that token.
|
||||
*
|
||||
* To use the legacy Object Storage authentication mechanism, you will
|
||||
* need the follwing pieces of information:
|
||||
*
|
||||
* - Account ID: This will typically be a combination of your tenantId and
|
||||
* username.
|
||||
* - Key: Typically this will be your password.
|
||||
* - Endpoint URL: The URL given to you by your service provider.
|
||||
*
|
||||
* @param string $account Your account name.
|
||||
* @param string $key Your secret key.
|
||||
* @param string $url The URL to the object storage endpoint.
|
||||
*
|
||||
* @throws \OpenStack\Common\Transport\Exception\AuthorizationException if the authentication failed.
|
||||
* @throws \OpenStack\Common\Transport\Exception\FileNotFoundException if the URL is wrong.
|
||||
* @throws \OpenStack\Common\Exception if some other exception occurs.
|
||||
*
|
||||
* @deprecated Newer versions of OpenStack use Keystone auth instead
|
||||
* of Swift auth.
|
||||
*/
|
||||
public static function newFromSwiftAuth($account, $key, $url, \OpenStack\Common\Transport\ClientInterface $client = null)
|
||||
{
|
||||
$headers = array(
|
||||
'X-Auth-User' => $account,
|
||||
'X-Auth-Key' => $key,
|
||||
);
|
||||
|
||||
// Guzzle is the default client to use.
|
||||
if (is_null($client)) {
|
||||
$client = new GuzzleClient();
|
||||
}
|
||||
|
||||
// This will throw an exception if it cannot connect or
|
||||
// authenticate.
|
||||
$res = $client->doRequest($url, 'GET', $headers);
|
||||
|
||||
// Headers that come back:
|
||||
// X-Storage-Url: https://region-a.geo-1.objects.hpcloudsvc.com:443/v1/AUTH_d8e28d35-3324-44d7-a625-4e6450dc1683
|
||||
// X-Storage-Token: AUTH_tkd2ffb4dac4534c43afbe532ca41bcdba
|
||||
// X-Auth-Token: AUTH_tkd2ffb4dac4534c43afbe532ca41bcdba
|
||||
// X-Trans-Id: tx33f1257e09f64bc58f28e66e0577268a
|
||||
|
||||
$token = $res->getHeader('X-Auth-Token');
|
||||
$newUrl = $res->getHeader('X-Storage-Url');
|
||||
|
||||
$store = new ObjectStorage($token, $newUrl, $client);
|
||||
|
||||
return $store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an IdentityService instance, create an ObjectStorage instance.
|
||||
*
|
||||
|
|
|
@ -42,9 +42,12 @@ use OpenStack\Common\Transport\GuzzleClient;
|
|||
* use \OpenStack\ObjectStore\v1\Resource\Container;
|
||||
* use \OpenStack\ObjectStore\v1\Resource\Object;
|
||||
*
|
||||
* // Create a new ObjectStorage instance, logging in with older Swift
|
||||
* // credentials.
|
||||
* $store = ObjectStorage::newFromSwiftAuth('user', 'key', 'http://example.com');
|
||||
* // Create a new ObjectStorage instance
|
||||
* // For more examples on authenticating and creating an ObjectStorage
|
||||
* // instance see functions below
|
||||
* // @see \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity()
|
||||
* // @see \OpenStack\ObjectStore\v1\ObjectStorage::newFromServiceCatalog()
|
||||
* $ostore = \OpenStack\ObjectStore\v1\ObjectStorage::newFromIdentity($yourIdentity, $yourRegion, $yourTransportClient);
|
||||
*
|
||||
* // Get the container called 'foo'.
|
||||
* $container = $store->container('foo');
|
||||
|
@ -645,7 +648,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||
* whose contents will be processed.
|
||||
*
|
||||
* For larger files or files whose content may never be accessed, use
|
||||
* remoteObject(), which delays loading the content until one of its
|
||||
* proxyObject(), which delays loading the content until one of its
|
||||
* content methods (e.g. RemoteObject::content()) is called.
|
||||
*
|
||||
* This does not yet support the following features of Swift:
|
||||
|
@ -694,7 +697,7 @@ class Container implements \Countable, \IteratorAggregate
|
|||
* its content. This may not be desireable for cases where the object
|
||||
* is large.
|
||||
*
|
||||
* This method can featch the relevant metadata, but delay fetching
|
||||
* This method can fetch the relevant metadata, but delay fetching
|
||||
* the content until it is actually needed.
|
||||
*
|
||||
* Since RemoteObject extends Object, all of the calls that can be
|
||||
|
@ -725,15 +728,6 @@ class Container implements \Countable, \IteratorAggregate
|
|||
|
||||
return $obj;
|
||||
}
|
||||
/**
|
||||
* This has been replaced with proxyObject().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function remoteObject($name)
|
||||
{
|
||||
return $this->proxyObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of objects in this container.
|
||||
|
|
|
@ -226,9 +226,6 @@ use \OpenStack\ObjectStore\v1\ObjectStorage;
|
|||
* - password: A password. MUST be accompanied by 'username' and 'tenantid' (or 'tenantname').
|
||||
* - endpoint: The URL to the authentication endpoint. Necessary if you are not
|
||||
* using a 'token' and 'swift_endpoint'.
|
||||
* - use_swift_auth: If this is set to true, it will force the app to use
|
||||
* the deprecated swiftAuth instead of IdentityService authentication.
|
||||
* In general, you should avoid using this.
|
||||
* - content_type: This is effective only when writing files. It will
|
||||
* set the Content-Type of the file during upload.
|
||||
* - tenantid: The tenant ID for the services you will use. (A user may
|
||||
|
@ -542,7 +539,7 @@ class StreamWrapper
|
|||
try {
|
||||
$container = $this->store->container($src['host']);
|
||||
|
||||
$object = $container->remoteObject($src['path']);
|
||||
$object = $container->proxyObject($src['path']);
|
||||
|
||||
$ret = $container->copy($object, $dest['path'], $dest['host']);
|
||||
if ($ret) {
|
||||
|
@ -1086,7 +1083,7 @@ class StreamWrapper
|
|||
$endpoint_url = $this->store->url() . '/' . rawurlencode($name);
|
||||
$client = $this->cxt('transport_client', null);
|
||||
$container = new \OpenStack\ObjectStore\v1\Resource\Container($name, $endpoint_url, $token, $client);
|
||||
$obj = $container->remoteObject($url['path']);
|
||||
$obj = $container->proxyObject($url['path']);
|
||||
} catch (\OpenStack\Common\Exception $e) {
|
||||
// Apparently file_exists does not set STREAM_URL_STAT_QUIET.
|
||||
//if ($flags & STREAM_URL_STAT_QUIET) {
|
||||
|
@ -1421,15 +1418,10 @@ class StreamWrapper
|
|||
* - password: A password. MUST be accompanied by 'username' and 'tenantname'.
|
||||
* - endpoint: The URL to the authentication endpoint. Necessary if you are not
|
||||
* using a 'token' and 'swift_endpoint'.
|
||||
* - use_swift_auth: If this is set to true, it will force the app to use
|
||||
* the deprecated swiftAuth instead of IdentityService authentication.
|
||||
* In general, you should avoid using this.
|
||||
* - transport_client: A transport client for the HTTP requests.
|
||||
*
|
||||
* To find these params, the method first checks the supplied context. If the
|
||||
* key is not found there, it checks the Bootstrap::conf().
|
||||
*
|
||||
* @fixme This should be rewritten to use \ObjectStorage::newFromServiceCatalog().
|
||||
*/
|
||||
protected function initializeObjectStorage()
|
||||
{
|
||||
|
@ -1473,7 +1465,6 @@ class StreamWrapper
|
|||
}
|
||||
|
||||
return !empty($this->store);
|
||||
|
||||
}
|
||||
|
||||
protected function authenticate()
|
||||
|
|
|
@ -68,11 +68,6 @@ if (!empty($argv[4 + $offset])) {
|
|||
$tenantId = $argv[4 + $offset];
|
||||
}
|
||||
|
||||
/*
|
||||
$store = ObjectStorage::newFromSwiftAuth($user, $key, $uri);
|
||||
|
||||
$token = $store->token();
|
||||
*/
|
||||
$cs = new IdentityService($uri);
|
||||
|
||||
$token = $cs->authenticateAsUser($user, $password, $tenantId);
|
||||
|
|
|
@ -316,7 +316,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||
* @group tenant
|
||||
* @depends testTenants
|
||||
*/
|
||||
public function testRescope()
|
||||
public function testRescopeUsingTenantId()
|
||||
{
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'), $this->getTransportClient());
|
||||
$user = self::conf('openstack.identity.username');
|
||||
|
@ -367,7 +367,7 @@ class IdentityServicesTest extends \OpenStack\Tests\TestCase
|
|||
$this->assertEquals($tenantName, $details['tenant']['name']);
|
||||
|
||||
// Test unscoping
|
||||
$service->rescope('');
|
||||
$service->rescopeUsingTenantName('');
|
||||
$details = $service->tokenDetails();
|
||||
$this->assertFalse(isset($details['tenant']));
|
||||
}
|
||||
|
|
|
@ -99,10 +99,10 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
/**
|
||||
* @depends testSave
|
||||
*/
|
||||
public function testRemoteObject()
|
||||
public function testProxyObject()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$object = $container->remoteObject(self::FNAME);
|
||||
$object = $container->proxyObject(self::FNAME);
|
||||
|
||||
$this->assertEquals(self::FNAME, $object->name());
|
||||
$this->assertEquals(self::FTYPE, $object->contentType());
|
||||
|
@ -135,12 +135,12 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
|
||||
|
||||
/**
|
||||
* @depends testRemoteObject
|
||||
* @depends testProxyObject
|
||||
*/
|
||||
public function testRefresh()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$object = $container->remoteObject(self::FNAME);
|
||||
$object = $container->proxyObject(self::FNAME);
|
||||
|
||||
$content = (string) $object->content();
|
||||
$object->setContent('FOO');
|
||||
|
@ -155,7 +155,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @depends testRemoteObject
|
||||
* @depends testProxyObject
|
||||
*/
|
||||
public function testObject()
|
||||
{
|
||||
|
@ -318,12 +318,12 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @depends testRemoteObject
|
||||
* @depends testProxyObject
|
||||
*/
|
||||
public function testUpdateMetadata()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$object = $container->remoteObject(self::FNAME);
|
||||
$object = $container->proxyObject(self::FNAME);
|
||||
|
||||
$md = $object->metadata();
|
||||
|
||||
|
@ -335,7 +335,7 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
|
||||
$container->updateMetadata($object);
|
||||
|
||||
$copy = $container->remoteObject(self::FNAME);
|
||||
$copy = $container->proxyObject(self::FNAME);
|
||||
|
||||
$this->assertEquals('456', $md['Foo']);
|
||||
$this->assertEquals('bert', $md['Bar']);
|
||||
|
@ -348,16 +348,16 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @depends testRemoteObject
|
||||
* @depends testProxyObject
|
||||
*/
|
||||
public function testCopy()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$object = $container->remoteObject(self::FNAME);
|
||||
$object = $container->proxyObject(self::FNAME);
|
||||
|
||||
$container->copy($object, 'FOO-1.txt');
|
||||
|
||||
$copy = $container->remoteObject('FOO-1.txt');
|
||||
$copy = $container->proxyObject('FOO-1.txt');
|
||||
|
||||
$this->assertEquals($object->contentType(), $copy->contentType());
|
||||
$this->assertEquals($object->etag(), $copy->etag());
|
||||
|
@ -383,13 +383,13 @@ class ContainerTest extends \OpenStack\Tests\TestCase
|
|||
|
||||
// Get teh old container and its object.
|
||||
$container = $this->containerFixture();
|
||||
$object = $container->remoteObject(self::FNAME);
|
||||
$object = $container->proxyObject(self::FNAME);
|
||||
|
||||
$ret = $container->copy($object, 'foo-1.txt', $cname);
|
||||
|
||||
$this->assertTrue($ret);
|
||||
|
||||
$copy = $newContainer->remoteObject('foo-1.txt');
|
||||
$copy = $newContainer->proxyObject('foo-1.txt');
|
||||
|
||||
$this->assertEquals($object->etag(), $copy->etag());
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class ObjectStorageTest extends \OpenStack\Tests\TestCase
|
|||
|
||||
$this->assertNotEmpty($testCollection, "Canary: container name must be in settings file.");
|
||||
|
||||
$store = $this->objectStore();//swiftAuth();
|
||||
$store = $this->objectStore();
|
||||
|
||||
$this->destroyContainerFixture();
|
||||
/*
|
||||
|
|
|
@ -64,7 +64,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||
$container = $this->containerFixture();
|
||||
$this->createAnObject();
|
||||
|
||||
$obj = $container->remoteObject(self::FNAME);
|
||||
$obj = $container->proxyObject(self::FNAME);
|
||||
|
||||
$this->assertInstanceOf('\OpenStack\ObjectStore\v1\Resource\RemoteObject', $obj);
|
||||
|
||||
|
@ -225,8 +225,8 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||
$content = $obj->content();
|
||||
$this->assertEquals(self::FCONTENT, $content);
|
||||
|
||||
// Make sure remoteObject retrieves the same content.
|
||||
$obj = $container->remoteObject(self::FNAME);
|
||||
// Make sure proxyObject retrieves the same content.
|
||||
$obj = $container->proxyObject(self::FNAME);
|
||||
$content = $obj->content();
|
||||
$this->assertEquals(self::FCONTENT, $content);
|
||||
|
||||
|
@ -238,7 +238,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||
public function testCaching()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$obj = $container->remoteObject(self::FNAME);
|
||||
$obj = $container->proxyObject(self::FNAME);
|
||||
|
||||
$this->assertFalse($obj->isCaching());
|
||||
|
||||
|
@ -284,7 +284,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||
public function testIsDirty()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$obj = $container->remoteObject(self::FNAME);
|
||||
$obj = $container->proxyObject(self::FNAME);
|
||||
|
||||
// THere is no content. Assert false.
|
||||
$this->assertFalse($obj->isDirty());
|
||||
|
@ -307,7 +307,7 @@ class RemoteObjectTest extends \OpenStack\Tests\TestCase
|
|||
public function testRefresh()
|
||||
{
|
||||
$container = $this->containerFixture();
|
||||
$obj = $container->remoteObject(self::FNAME);
|
||||
$obj = $container->proxyObject(self::FNAME);
|
||||
|
||||
$obj->setContent('foo');
|
||||
$this->assertTrue($obj->isDirty());
|
||||
|
|
|
@ -104,9 +104,6 @@ class StreamWrapperFSTest extends TestCase
|
|||
|
||||
/**
|
||||
* This performs authentication via context.
|
||||
*
|
||||
* UPDATE: This now users IdentityService instead of deprecated
|
||||
* swauth.
|
||||
*/
|
||||
protected function authSwiftContext(array $params = [], $scheme = null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue