Converted Object Storage to the OpenStack namespace.

This commit is contained in:
Matt Farina
2013-09-16 17:14:20 -04:00
parent a995a9c0a6
commit c7780debf4
22 changed files with 329 additions and 329 deletions

View File

@@ -30,10 +30,10 @@ SOFTWARE.
* a text document, a binary). * a text document, a binary).
*/ */
namespace HPCloud\Storage; namespace OpenStack\Storage;
use HPCloud\Storage\ObjectStorage\Container; use OpenStack\Storage\ObjectStorage\Container;
use HPCloud\Storage\ObjectStorage\ACL; use OpenStack\Storage\ObjectStorage\ACL;
/** /**
* Access to ObjectStorage (Swift). * Access to ObjectStorage (Swift).
@@ -44,7 +44,7 @@ use HPCloud\Storage\ObjectStorage\ACL;
* *
* There is also a stream wrapper interface that exposes ObjectStorage * There is also a stream wrapper interface that exposes ObjectStorage
* to PHP's streams system. For common use of an object store, you may * to PHP's streams system. For common use of an object store, you may
* prefer to use that system. (See HPCloud::Bootstrap). * prefer to use that system. (See OpenStack::Bootstrap).
* *
* When constructing a new ObjectStorage object, you will need to know * When constructing a new ObjectStorage object, you will need to know
* what kind of authentication you are going to perform. Older * what kind of authentication you are going to perform. Older
@@ -53,7 +53,7 @@ use HPCloud\Storage\ObjectStorage\ACL;
* perform this type of authentication. * perform this type of authentication.
* *
* Newer versions use the IdentityServices authentication mechanism (see * Newer versions use the IdentityServices authentication mechanism (see
* HPCloud::Services::IdentityServices). That method is the preferred * OpenStack::Services::IdentityServices). That method is the preferred
* method. * method.
* *
* Common Tasks * Common Tasks
@@ -69,7 +69,7 @@ use HPCloud\Storage\ObjectStorage\ACL;
class ObjectStorage { class ObjectStorage {
/** /**
* The name of this service type in HPCloud. * The name of this service type in OpenStack.
* *
* This is used with IdentityService::serviceCatalog(). * This is used with IdentityService::serviceCatalog().
*/ */
@@ -92,7 +92,7 @@ class ObjectStorage {
* Create a new instance after getting an authenitcation token. * Create a new instance after getting an authenitcation token.
* *
* THIS METHOD IS DEPRECATED. OpenStack now uses Keyston to authenticate. * THIS METHOD IS DEPRECATED. OpenStack now uses Keyston to authenticate.
* You should use HPCloud::Services::IdentityServices to authenticate. * You should use OpenStack::Services::IdentityServices to authenticate.
* Then use this class's constructor to create an object. * Then use this class's constructor to create an object.
* *
* This uses the legacy Swift authentication facility to authenticate * This uses the legacy Swift authentication facility to authenticate
@@ -118,11 +118,11 @@ class ObjectStorage {
* @param string $url * @param string $url
* The URL to the object storage endpoint. * The URL to the object storage endpoint.
* *
* @throws HPCloud::Transport::AuthorizationException if the * @throws OpenStack::Transport::AuthorizationException if the
* authentication failed. * authentication failed.
* @throws HPCloud::Transport::FileNotFoundException if the URL is * @throws OpenStack::Transport::FileNotFoundException if the URL is
* wrong. * wrong.
* @throws HPCloud::Exception if some other exception occurs. * @throws OpenStack::Exception if some other exception occurs.
* *
* @deprecated Newer versions of OpenStack use Keystone auth instead * @deprecated Newer versions of OpenStack use Keystone auth instead
* of Swift auth. * of Swift auth.
@@ -133,7 +133,7 @@ class ObjectStorage {
'X-Auth-Key' => $key, 'X-Auth-Key' => $key,
); );
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
// This will throw an exception if it cannot connect or // This will throw an exception if it cannot connect or
// authenticate. // authenticate.
@@ -160,13 +160,13 @@ class ObjectStorage {
* Given an IdentityServices instance, create an ObjectStorage instance. * Given an IdentityServices instance, create an ObjectStorage instance.
* *
* This constructs a new ObjectStorage from an authenticated instance * This constructs a new ObjectStorage from an authenticated instance
* of an HPCloud::Services::IdentityServices object. * of an OpenStack::Services::IdentityServices object.
* *
* @param HPCloud::Services::IdentityServices $identity * @param OpenStack::Services::IdentityServices $identity
* An identity services object that already has a valid token and a * An identity services object that already has a valid token and a
* service catalog. * service catalog.
* @retval HPCloud::Storage::ObjectStorage * @retval OpenStack::Storage::ObjectStorage
* @return \HPCloud\Storage\ObjectStorage * @return \OpenStack\Storage\ObjectStorage
* A new ObjectStorage instance. * A new ObjectStorage instance.
*/ */
public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION) { public static function newFromIdentity($identity, $region = ObjectStorage::DEFAULT_REGION) {
@@ -190,8 +190,8 @@ class ObjectStorage {
* just ObjectStorage::SERVICE_TYPE. * just ObjectStorage::SERVICE_TYPE.
* @param string $authToken * @param string $authToken
* The auth token returned by IdentityServices. * The auth token returned by IdentityServices.
* @retval HPCloud::Storage::ObjectStorage * @retval OpenStack::Storage::ObjectStorage
* @return \HPCloud\Storage\ObjectStorage * @return \OpenStack\Storage\ObjectStorage
* A new ObjectStorage instance. * A new ObjectStorage instance.
*/ */
public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION) { public static function newFromServiceCatalog($catalog, $authToken, $region = ObjectStorage::DEFAULT_REGION) {
@@ -283,7 +283,7 @@ class ObjectStorage {
* @return array * @return array
* An associative array of containers, where the key is the * An associative array of containers, where the key is the
* container's name and the value is an * container's name and the value is an
* HPCloud::Storage::ObjectStorage::Container object. Results are * OpenStack::Storage::ObjectStorage::Container object. Results are
* ordered in server order (the order that the remote host puts them * ordered in server order (the order that the remote host puts them
* in). * in).
*/ */
@@ -316,10 +316,10 @@ class ObjectStorage {
* *
* @param string $name * @param string $name
* The name of the container to load. * The name of the container to load.
* @retval HPCloud::Storage::ObjectStorage::Container * @retval OpenStack::Storage::ObjectStorage::Container
* @return \HPCloud\Storage\ObjectStorage\Container * @return \OpenStack\Storage\ObjectStorage\Container
* A container. * A container.
* @throws HPCloud::Transport::FileNotFoundException * @throws OpenStack::Transport::FileNotFoundException
* if the named container is not found on the remote server. * if the named container is not found on the remote server.
*/ */
public function container($name) { public function container($name) {
@@ -335,7 +335,7 @@ class ObjectStorage {
} }
// If we get here, it's not a 404 and it's not a 204. // If we get here, it's not a 404 and it's not a 204.
throw new \HPCloud\Exception("Unknown status: $status"); throw new \OpenStack\Exception("Unknown status: $status");
} }
/** /**
@@ -350,14 +350,14 @@ class ObjectStorage {
* @retval boolean * @retval boolean
* @return boolean * @return boolean
* TRUE if the container exists, FALSE if it does not. * TRUE if the container exists, FALSE if it does not.
* @throws HPCloud::Exception * @throws OpenStack::Exception
* If an unexpected network error occurs. * If an unexpected network error occurs.
*/ */
public function hasContainer($name) { public function hasContainer($name) {
try { try {
$container = $this->container($name); $container = $this->container($name);
} }
catch (\HPCloud\Transport\FileNotFoundException $fnfe) { catch (\OpenStack\Transport\FileNotFoundException $fnfe) {
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@@ -410,15 +410,15 @@ class ObjectStorage {
* ?> * ?>
* @endcode * @endcode
* *
* For details on ACLs, see HPCloud::Storage::ObjectStorage::ACL. * For details on ACLs, see OpenStack::Storage::ObjectStorage::ACL.
* *
* @param string $name * @param string $name
* The name of the container. * The name of the container.
* @param object $acl HPCloud::Storage::ObjectStorage::ACL * @param object $acl OpenStack::Storage::ObjectStorage::ACL
* An access control list object. By default, a container is * An access control list object. By default, a container is
* non-public (private). To change this behavior, you can add a * non-public (private). To change this behavior, you can add a
* custom ACL. To make the container publically readable, you can * custom ACL. To make the container publically readable, you can
* use this: HPCloud::Storage::ObjectStorage::ACL::makePublic(). * use this: OpenStack::Storage::ObjectStorage::ACL::makePublic().
* @param array $metadata * @param array $metadata
* An associative array of metadata to attach to the container. * An associative array of metadata to attach to the container.
* @retval boolean * @retval boolean
@@ -437,7 +437,7 @@ class ObjectStorage {
$headers += Container::generateMetadataHeaders($metadata, $prefix); $headers += Container::generateMetadataHeaders($metadata, $prefix);
} }
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
// Add ACLs to header. // Add ACLs to header.
if (!empty($acl)) { if (!empty($acl)) {
$headers += $acl->headers(); $headers += $acl->headers();
@@ -455,7 +455,7 @@ class ObjectStorage {
} }
// According to the OpenStack docs, there are no other return codes. // According to the OpenStack docs, there are no other return codes.
else { else {
throw new \HPCloud\Exception('Server returned unexpected code: ' . $status); throw new \OpenStack\Exception('Server returned unexpected code: ' . $status);
} }
} }
@@ -482,7 +482,7 @@ class ObjectStorage {
* *
* @param string $name * @param string $name
* The name of the container. * The name of the container.
* @param object $acl HPCloud::Storage::ObjectStorage::ACL * @param object $acl OpenStack::Storage::ObjectStorage::ACL
* An ACL. To make the container publically readable, use * An ACL. To make the container publically readable, use
* ACL::makePublic(). * ACL::makePublic().
* @retval boolean * @retval boolean
@@ -502,7 +502,7 @@ class ObjectStorage {
* the object storage. * the object storage.
* *
* The container MUST be empty before it can be deleted. If it is not, * The container MUST be empty before it can be deleted. If it is not,
* an HPCloud::Storage::ObjectStorage::ContainerNotEmptyException will * an OpenStack::Storage::ObjectStorage::ContainerNotEmptyException will
* be thrown. * be thrown.
* *
* @param string $name * @param string $name
@@ -511,10 +511,10 @@ class ObjectStorage {
* @return boolean * @return boolean
* TRUE if the container was deleted, FALSE if the container was not * TRUE if the container was deleted, FALSE if the container was not
* found (and hence, was not deleted). * found (and hence, was not deleted).
* @throws HPCloud::Storage::ObjectStorage::ContainerNotEmptyException * @throws OpenStack::Storage::ObjectStorage::ContainerNotEmptyException
* if the container is not empty. * if the container is not empty.
* @throws HPCloud::Exception if an unexpected response code is returned. * @throws OpenStack::Exception if an unexpected response code is returned.
* While this should never happen on HPCloud servers, forks of * While this should never happen on OpenStack servers, forks of
* OpenStack may choose to extend object storage in a way that * OpenStack may choose to extend object storage in a way that
* results in a non-standard code. * results in a non-standard code.
*/ */
@@ -524,12 +524,12 @@ class ObjectStorage {
try { try {
$data = $this->req($url, 'DELETE', FALSE); $data = $this->req($url, 'DELETE', FALSE);
} }
catch (\HPCloud\Transport\FileNotFoundException $e) { catch (\OpenStack\Transport\FileNotFoundException $e) {
return FALSE; return FALSE;
} }
// XXX: I'm not terribly sure about this. Why not just throw the // XXX: I'm not terribly sure about this. Why not just throw the
// ConflictException? // ConflictException?
catch (\HPCloud\Transport\ConflictException $e) { catch (\OpenStack\Transport\ConflictException $e) {
throw new ObjectStorage\ContainerNotEmptyException("Non-empty container cannot be deleted."); throw new ObjectStorage\ContainerNotEmptyException("Non-empty container cannot be deleted.");
} }
@@ -542,7 +542,7 @@ class ObjectStorage {
// OpenStacks documentation doesn't suggest any other return // OpenStacks documentation doesn't suggest any other return
// codes. // codes.
else { else {
throw new \HPCloud\Exception('Server returned unexpected code: ' . $status); throw new \OpenStack\Exception('Server returned unexpected code: ' . $status);
} }
} }
@@ -560,7 +560,7 @@ class ObjectStorage {
* - bytes: Bytes consumed by existing content. * - bytes: Bytes consumed by existing content.
* - containers: Number of containers. * - containers: Number of containers.
* - objects: Number of objects. * - objects: Number of objects.
* @throws HPCloud::Transport::AuthorizationException * @throws OpenStack::Transport::AuthorizationException
* if the user credentials are invalid or have expired. * if the user credentials are invalid or have expired.
*/ */
public function accountInfo() { public function accountInfo() {
@@ -590,7 +590,7 @@ class ObjectStorage {
* Internal request issuing command. * Internal request issuing command.
*/ */
protected function req($url, $method = 'GET', $jsonDecode = TRUE, $body = '') { protected function req($url, $method = 'GET', $jsonDecode = TRUE, $body = '') {
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$headers = array( $headers = array(
'X-Auth-Token' => $this->token(), 'X-Auth-Token' => $this->token(),
); );

View File

@@ -25,7 +25,7 @@ SOFTWARE.
* Contains the class for manipulating ObjectStorage ACL strings. * Contains the class for manipulating ObjectStorage ACL strings.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* Access control list for object storage. * Access control list for object storage.
@@ -151,8 +151,8 @@ class ACL {
* *
* - READ to any host, with container listings. * - READ to any host, with container listings.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* an ACL object with the appopriate permissions set. * an ACL object with the appopriate permissions set.
*/ */
public static function makePublic() { public static function makePublic() {
@@ -172,8 +172,8 @@ class ACL {
* This does not grant any permissions. OpenStack interprets an object * This does not grant any permissions. OpenStack interprets an object
* with no permissions as a private object. * with no permissions as a private object.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* an ACL object with the appopriate permissions set. * an ACL object with the appopriate permissions set.
*/ */
public static function makeNonPublic() { public static function makeNonPublic() {
@@ -196,8 +196,8 @@ class ACL {
* *
* @param array $headers * @param array $headers
* An associative array of headers. * An associative array of headers.
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* A new ACL. * A new ACL.
*/ */
public static function newFromHeaders($headers) { public static function newFromHeaders($headers) {
@@ -324,8 +324,8 @@ class ACL {
* The name of the user, or optionally an indexed array of user * The name of the user, or optionally an indexed array of user
* names. * names.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* $this for current object so the method can be used in chaining. * $this for current object so the method can be used in chaining.
*/ */
public function addAccount($perm, $account, $user = NULL) { public function addAccount($perm, $account, $user = NULL) {
@@ -361,8 +361,8 @@ class ACL {
* @param string $host * @param string $host
* A host specification string as described above. * A host specification string as described above.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* $this for current object so the method can be used in chaining. * $this for current object so the method can be used in chaining.
*/ */
public function addReferrer($perm, $host = '*') { public function addReferrer($perm, $host = '*') {
@@ -379,8 +379,8 @@ class ACL {
* @param array $rule * @param array $rule
* A rule array. * A rule array.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* $this for current object so the method can be used in chaining. * $this for current object so the method can be used in chaining.
*/ */
protected function addRule($perm, $rule) { protected function addRule($perm, $rule) {
@@ -402,8 +402,8 @@ class ACL {
* In the current Swift implementation, there is no mechanism for * In the current Swift implementation, there is no mechanism for
* allowing some hosts to get listings, while denying others. * allowing some hosts to get listings, while denying others.
* *
* @retval HPCloud::Storage::ObjectStorage::ACL * @retval OpenStack::Storage::ObjectStorage::ACL
* @return \HPCloud\Storage\ObjectStorage\ACL * @return \OpenStack\Storage\ObjectStorage\ACL
* $this for current object so the method can be used in chaining. * $this for current object so the method can be used in chaining.
*/ */
public function allowListings() { public function allowListings() {

View File

@@ -25,7 +25,7 @@ SOFTWARE.
* Contains the class for ObjectStorage Container objects. * Contains the class for ObjectStorage Container objects.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* A container in an ObjectStorage. * A container in an ObjectStorage.
@@ -44,9 +44,9 @@ namespace HPCloud\Storage\ObjectStorage;
* *
* @code * @code
* <?php * <?php
* use \HPCloud\Storage\ObjectStorage; * use \OpenStack\Storage\ObjectStorage;
* use \HPCloud\Storage\ObjectStorage\Container; * use \OpenStack\Storage\ObjectStorage\Container;
* use \HPCloud\Storage\ObjectStorage\Object; * use \OpenStack\Storage\ObjectStorage\Object;
* *
* // Create a new ObjectStorage instance, logging in with older Swift * // Create a new ObjectStorage instance, logging in with older Swift
* // credentials. * // credentials.
@@ -210,8 +210,8 @@ class Container implements \Countable, \IteratorAggregate {
* The base URL. The container name is automatically appended to * The base URL. The container name is automatically appended to
* this at construction time. * this at construction time.
* *
* @retval HPCloud::Storage::ObjectStorage::Comtainer * @retval OpenStack::Storage::ObjectStorage::Comtainer
* @return \HPCloud\Storage\ObjectStorage\Container * @return \OpenStack\Storage\ObjectStorage\Container
* A new container object. * A new container object.
*/ */
public static function newFromJSON($jsonArray, $token, $url) { public static function newFromJSON($jsonArray, $token, $url) {
@@ -247,15 +247,15 @@ class Container implements \Countable, \IteratorAggregate {
* *
* @param string $name * @param string $name
* The name of the container. * The name of the container.
* @param object $response HPCloud::Transport::Response * @param object $response OpenStack::Transport::Response
* The HTTP response object from the Transporter layer * The HTTP response object from the Transporter layer
* @param string $token * @param string $token
* The auth token. * The auth token.
* @param string $url * @param string $url
* The base URL. The container name is automatically appended to * The base URL. The container name is automatically appended to
* this at construction time. * this at construction time.
* @retval HPCloud::Storage::ObjectStorage::Container * @retval OpenStack::Storage::ObjectStorage::Container
* @return \HPCloud\Storage\ObjectStorage\Container * @return \OpenStack\Storage\ObjectStorage\Container
* The Container object, initialized and ready for use. * The Container object, initialized and ready for use.
*/ */
public static function newFromResponse($name, $response, $token, $url) { public static function newFromResponse($name, $response, $token, $url) {
@@ -398,8 +398,8 @@ class Container implements \Countable, \IteratorAggregate {
* more than 256. UTF-8 or ASCII characters are allowed, though ASCII * more than 256. UTF-8 or ASCII characters are allowed, though ASCII
* seems to be preferred. * seems to be preferred.
* *
* @retval HPCloud::Storage::ObjectStorage::Container * @retval OpenStack::Storage::ObjectStorage::Container
* @return \HPCloud\Storage\ObjectStorage\Container * @return \OpenStack\Storage\ObjectStorage\Container
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setMetadata($metadata) { public function setMetadata($metadata) {
@@ -434,11 +434,11 @@ class Container implements \Countable, \IteratorAggregate {
/** /**
* Save an Object into Object Storage. * Save an Object into Object Storage.
* *
* This takes an HPCloud::Storage::ObjectStorage::Object * This takes an OpenStack::Storage::ObjectStorage::Object
* and stores it in the given container in the present * and stores it in the given container in the present
* container on the remote object store. * container on the remote object store.
* *
* @param object $obj HPCloud::Storage::ObjectStorage::Object * @param object $obj OpenStack::Storage::ObjectStorage::Object
* The object to store. * The object to store.
* @param resource $file * @param resource $file
* An optional file argument that, if set, will be treated as the * An optional file argument that, if set, will be treated as the
@@ -446,24 +446,24 @@ class Container implements \Countable, \IteratorAggregate {
* @retval boolean * @retval boolean
* @return boolean * @return boolean
* TRUE if the object was saved. * TRUE if the object was saved.
* @throws HPCloud::Transport::LengthRequiredException * @throws OpenStack::Transport::LengthRequiredException
* if the Content-Length could not be determined and chunked * if the Content-Length could not be determined and chunked
* encoding was not enabled. This should not occur for this class, * encoding was not enabled. This should not occur for this class,
* which always automatically generates Content-Length headers. * which always automatically generates Content-Length headers.
* However, subclasses could generate this error. * However, subclasses could generate this error.
* @throws HPCloud::Transport::UnprocessableEntityException * @throws OpenStack::Transport::UnprocessableEntityException
* if the checksome passed here does not match the checksum * if the checksome passed here does not match the checksum
* calculated remotely. * calculated remotely.
* @throws HPCloud::Exception when an unexpected (usually * @throws OpenStack::Exception when an unexpected (usually
* network-related) error condition arises. * network-related) error condition arises.
*/ */
public function save(Object $obj, $file = NULL) { public function save(Object $obj, $file = NULL) {
if (empty($this->token)) { if (empty($this->token)) {
throw new \HPCloud\Exception('Container does not have an auth token.'); throw new \OpenStack\Exception('Container does not have an auth token.');
} }
if (empty($this->url)) { if (empty($this->url)) {
throw new \HPCloud\Exception('Container does not have a URL to send data.'); throw new \OpenStack\Exception('Container does not have a URL to send data.');
} }
//$url = $this->url . '/' . rawurlencode($obj->name()); //$url = $this->url . '/' . rawurlencode($obj->name());
@@ -502,7 +502,7 @@ class Container implements \Countable, \IteratorAggregate {
$headers += $moreHeaders; $headers += $moreHeaders;
} }
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
if (empty($file)) { if (empty($file)) {
// Now build up the rest of the headers: // Now build up the rest of the headers:
@@ -544,7 +544,7 @@ class Container implements \Countable, \IteratorAggregate {
} }
if ($response->status() != 201) { if ($response->status() != 201) {
throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status());
} }
return TRUE; return TRUE;
} }
@@ -560,14 +560,14 @@ class Container implements \Countable, \IteratorAggregate {
* particularly in cases where custom headers have been set. * particularly in cases where custom headers have been set.
* Use with caution. * Use with caution.
* *
* @param object $obj HPCloud::Storage::ObjectStorage::Object * @param object $obj OpenStack::Storage::ObjectStorage::Object
* The object to update. * The object to update.
* *
* @retval boolean * @retval boolean
* @return boolean * @return boolean
* TRUE if the metadata was updated. * TRUE if the metadata was updated.
* *
* @throws HPCloud::Transport::FileNotFoundException * @throws OpenStack::Transport::FileNotFoundException
* if the object does not already exist on the object storage. * if the object does not already exist on the object storage.
*/ */
public function updateMetadata(Object $obj) { public function updateMetadata(Object $obj) {
@@ -587,13 +587,13 @@ class Container implements \Countable, \IteratorAggregate {
// content type IS reset during this operation. // content type IS reset during this operation.
$headers['Content-Type'] = $obj->contentType(); $headers['Content-Type'] = $obj->contentType();
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
// The POST verb is for updating headers. // The POST verb is for updating headers.
$response = $client->doRequest($url, 'POST', $headers, $obj->content()); $response = $client->doRequest($url, 'POST', $headers, $obj->content());
if ($response->status() != 202) { if ($response->status() != 202) {
throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status());
} }
return TRUE; return TRUE;
} }
@@ -610,7 +610,7 @@ class Container implements \Countable, \IteratorAggregate {
* Note that there is no MOVE operation. You must copy and then DELETE * Note that there is no MOVE operation. You must copy and then DELETE
* in order to achieve that. * in order to achieve that.
* *
* @param object $obj HPCloud::Storage::ObjectStorage::Object * @param object $obj OpenStack::Storage::ObjectStorage::Object
* The object to copy. This object MUST already be saved on the * The object to copy. This object MUST already be saved on the
* remote server. The body of the object is not sent. Instead, the * remote server. The body of the object is not sent. Instead, the
* copy operation is performed on the remote server. You can, and * copy operation is performed on the remote server. You can, and
@@ -630,7 +630,7 @@ class Container implements \Countable, \IteratorAggregate {
$sourceUrl = self::objectUrl($this->url, $obj->name()); $sourceUrl = self::objectUrl($this->url, $obj->name());
if (empty($newName)) { if (empty($newName)) {
throw new \HPCloud\Exception("An object name is required to copy the object."); throw new \OpenStack\Exception("An object name is required to copy the object.");
} }
// Figure out what container we store in. // Figure out what container we store in.
@@ -645,11 +645,11 @@ class Container implements \Countable, \IteratorAggregate {
'Destination' => $destUrl, 'Destination' => $destUrl,
); );
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$response = $client->doRequest($sourceUrl, 'COPY', $headers); $response = $client->doRequest($sourceUrl, 'COPY', $headers);
if ($response->status() != 201) { if ($response->status() != 201) {
throw new \HPCloud\Exception("An unknown condition occurred during copy. " . $response->status()); throw new \OpenStack\Exception("An unknown condition occurred during copy. " . $response->status());
} }
return TRUE; return TRUE;
} }
@@ -675,8 +675,8 @@ class Container implements \Countable, \IteratorAggregate {
* *
* @param string $name * @param string $name
* The name of the object to load. * The name of the object to load.
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* A remote object with the content already stored locally. * A remote object with the content already stored locally.
*/ */
public function object($name) { public function object($name) {
@@ -687,12 +687,12 @@ class Container implements \Countable, \IteratorAggregate {
// Auth token. // Auth token.
$headers['X-Auth-Token'] = $this->token; $headers['X-Auth-Token'] = $this->token;
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$response = $client->doRequest($url, 'GET', $headers); $response = $client->doRequest($url, 'GET', $headers);
if ($response->status() != 200) { if ($response->status() != 200) {
throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status());
} }
$remoteObject = RemoteObject::newFromHeaders($name, $response->headers(), $this->token, $url); $remoteObject = RemoteObject::newFromHeaders($name, $response->headers(), $this->token, $url);
@@ -727,8 +727,8 @@ class Container implements \Countable, \IteratorAggregate {
* *
* @param string $name * @param string $name
* The name of the object to fetch. * The name of the object to fetch.
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* A remote object ready for use. * A remote object ready for use.
*/ */
public function proxyObject($name) { public function proxyObject($name) {
@@ -738,12 +738,12 @@ class Container implements \Countable, \IteratorAggregate {
); );
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$response = $client->doRequest($url, 'HEAD', $headers); $response = $client->doRequest($url, 'HEAD', $headers);
if ($response->status() != 200) { if ($response->status() != 200) {
throw new \HPCloud\Exception('An unknown error occurred while saving: ' . $response->status()); throw new \OpenStack\Exception('An unknown error occurred while saving: ' . $response->status());
} }
$headers = $response->headers(); $headers = $response->headers();
@@ -937,8 +937,8 @@ class Container implements \Countable, \IteratorAggregate {
* ObjectStorage methods. * ObjectStorage methods.
* *
* @todo Determine how to get the ACL from JSON data. * @todo Determine how to get the ACL from JSON data.
* @retval \HPCloud\Storage\ObjectStorage\ACL * @retval \OpenStack\Storage\ObjectStorage\ACL
* @return HPCloud::Storage::ObjectStorage::ACL * @return OpenStack::Storage::ObjectStorage::ACL
* An ACL, or NULL if the ACL could not be retrieved. * An ACL, or NULL if the ACL could not be retrieved.
*/ */
public function acl() { public function acl() {
@@ -954,8 +954,8 @@ class Container implements \Countable, \IteratorAggregate {
* Not all containers come fully instantiated. This method is sometimes * Not all containers come fully instantiated. This method is sometimes
* called to "fill in" missing fields. * called to "fill in" missing fields.
* *
* @retval HPCloud::Storage::ObjectStorage::Comtainer * @retval OpenStack::Storage::ObjectStorage::Comtainer
* @return \HPCloud\Storage\ObjectStorage\Container * @return \OpenStack\Storage\ObjectStorage\Container
*/ */
protected function loadExtraData() { protected function loadExtraData() {
@@ -964,10 +964,10 @@ class Container implements \Countable, \IteratorAggregate {
// created with Container::createContainer(). We treat // created with Container::createContainer(). We treat
// this as an error condition. // this as an error condition.
if (empty($this->url) || empty($this->token)) { if (empty($this->url) || empty($this->token)) {
throw new \HPCloud\Exception('Remote data cannot be fetched. Tokena and endpoint URL are required.'); throw new \OpenStack\Exception('Remote data cannot be fetched. Tokena and endpoint URL are required.');
} }
// Do a GET on $url to fetch headers. // Do a GET on $url to fetch headers.
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$headers = array( $headers = array(
'X-Auth-Token' => $this->token, 'X-Auth-Token' => $this->token,
); );
@@ -1006,7 +1006,7 @@ class Container implements \Countable, \IteratorAggregate {
$query = str_replace('%2F', '/', $query); $query = str_replace('%2F', '/', $query);
$url = $this->url . '?' . $query; $url = $this->url . '?' . $query;
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$headers = array( $headers = array(
'X-Auth-Token' => $this->token, 'X-Auth-Token' => $this->token,
); );
@@ -1016,7 +1016,7 @@ class Container implements \Countable, \IteratorAggregate {
// The only codes that should be returned are 200 and the ones // The only codes that should be returned are 200 and the ones
// already thrown by doRequest. // already thrown by doRequest.
if ($response->status() != 200) { if ($response->status() != 200) {
throw new \HPCloud\Exception('An unknown exception occurred while processing the request.'); throw new \OpenStack\Exception('An unknown exception occurred while processing the request.');
} }
$responseContent = $response->content(); $responseContent = $response->content();
@@ -1029,7 +1029,7 @@ class Container implements \Countable, \IteratorAggregate {
$list[] = new Subdir($item['subdir'], $params['delimiter']); $list[] = new Subdir($item['subdir'], $params['delimiter']);
} }
elseif (empty($item['name'])) { elseif (empty($item['name'])) {
throw new \HPCloud\Exception('Unexpected entity returned.'); throw new \OpenStack\Exception('Unexpected entity returned.');
} }
else { else {
//$url = $this->url . '/' . rawurlencode($item['name']); //$url = $this->url . '/' . rawurlencode($item['name']);
@@ -1088,17 +1088,17 @@ class Container implements \Countable, \IteratorAggregate {
'X-Auth-Token' => $this->token, 'X-Auth-Token' => $this->token,
); );
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
try { try {
$response = $client->doRequest($url, 'DELETE', $headers); $response = $client->doRequest($url, 'DELETE', $headers);
} }
catch (\HPCloud\Transport\FileNotFoundException $fnfe) { catch (\OpenStack\Transport\FileNotFoundException $fnfe) {
return FALSE; return FALSE;
} }
if ($response->status() != 204) { if ($response->status() != 204) {
throw new \HPCloud\Exception("An unknown exception occured while deleting $name."); throw new \OpenStack\Exception("An unknown exception occured while deleting $name.");
} }
return TRUE; return TRUE;

View File

@@ -25,7 +25,7 @@ SOFTWARE.
* Contains exception class for ContainerNotEmptyException. * Contains exception class for ContainerNotEmptyException.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* Indicatest that a container is not empty. * Indicatest that a container is not empty.
@@ -35,4 +35,4 @@ namespace HPCloud\Storage\ObjectStorage;
* exception is thrown when such an operation encounters an unempty * exception is thrown when such an operation encounters an unempty
* container when it requires an empty one. * container when it requires an empty one.
*/ */
class ContainerNotEmptyException extends \HPCloud\Transport\ServerException {} class ContainerNotEmptyException extends \OpenStack\Transport\ServerException {}

View File

@@ -24,7 +24,7 @@ SOFTWARE.
* *
* Contains the ContentVerificationException object. * Contains the ContentVerificationException object.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* Content Verification error condition. * Content Verification error condition.
@@ -34,4 +34,4 @@ namespace HPCloud\Storage\ObjectStorage;
* RemoteObject::setContentVerification(). * RemoteObject::setContentVerification().
* *
*/ */
class ContentVerificationException extends \HPCloud\Exception {} class ContentVerificationException extends \OpenStack\Exception {}

View File

@@ -24,12 +24,12 @@ SOFTWARE.
* Contains the class Object for ObjectStorage. * Contains the class Object for ObjectStorage.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* An object for ObjectStorage. * An object for ObjectStorage.
* *
* The HPCloud ObjectStorage system provides a method for storing * The OpenStack ObjectStorage system provides a method for storing
* complete chunks of data (objects) in the cloud. This class describes * complete chunks of data (objects) in the cloud. This class describes
* such a chunk of data. * such a chunk of data.
* *
@@ -148,8 +148,8 @@ class Object {
* @param array $array * @param array $array
* An associative array of metadata names to values. * An associative array of metadata names to values.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setMetadata(array $array) { public function setMetadata(array $array) {
@@ -180,13 +180,13 @@ class Object {
* object store. * object store.
* *
* To copy an object, see * To copy an object, see
* HPCloud::Storage::ObjectStorage::Container::copyObject(). * OpenStack::Storage::ObjectStorage::Container::copyObject().
* *
* @param string $name * @param string $name
* A file or object name. * A file or object name.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setName($name) { public function setName($name) {
@@ -235,8 +235,8 @@ class Object {
* @param string $type * @param string $type
* A valid content type. * A valid content type.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setContentType($type) { public function setContentType($type) {
@@ -278,8 +278,8 @@ class Object {
* The content type (MIME type). This can be set here for * The content type (MIME type). This can be set here for
* convenience, or you can call setContentType() directly. * convenience, or you can call setContentType() directly.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setContent($content, $type = NULL) { public function setContent($content, $type = NULL) {
@@ -372,8 +372,8 @@ class Object {
* @param string $encoding * @param string $encoding
* A valid encoding type. * A valid encoding type.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setEncoding($encoding) { public function setEncoding($encoding) {
@@ -417,8 +417,8 @@ class Object {
* A valid disposition declaration. These are defined in various * A valid disposition declaration. These are defined in various
* HTTP specifications. * HTTP specifications.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setDisposition($disposition) { public function setDisposition($disposition) {
@@ -474,8 +474,8 @@ class Object {
* each value is the HTTP header value. No encoding or escaping is * each value is the HTTP header value. No encoding or escaping is
* done. * done.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setAdditionalHeaders($headers) { public function setAdditionalHeaders($headers) {
@@ -509,8 +509,8 @@ class Object {
* @param array $keys * @param array $keys
* The header names to be removed. * The header names to be removed.
* *
* @retval HPCloud::Storage::ObjectStorage::Object * @retval OpenStack::Storage::ObjectStorage::Object
* @return \HPCloud\Storage\ObjectStorage\Object * @return \OpenStack\Storage\ObjectStorage\Object
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
public function removeHeaders($keys) { public function removeHeaders($keys) {

View File

@@ -22,8 +22,8 @@ SOFTWARE.
/** /**
* @file * @file
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* Thrown if an object that is read only is modified. * Thrown if an object that is read only is modified.
*/ */
class ReadOnlyObjectException extends \HPCloud\Exception {} class ReadOnlyObjectException extends \OpenStack\Exception {}

View File

@@ -25,14 +25,14 @@ SOFTWARE.
* Contains the RemoteObject class. * Contains the RemoteObject class.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* A representation of an object stored in remote Object Storage. * A representation of an object stored in remote Object Storage.
* *
* A remote object is one whose canonical copy is stored in a remote * A remote object is one whose canonical copy is stored in a remote
* object storage. It represents a local (and possibly partial) copy of * object storage. It represents a local (and possibly partial) copy of
* an object. (Contrast this with HPCloud::Storage::ObjectStorage::Object) * an object. (Contrast this with OpenStack::Storage::ObjectStorage::Object)
* *
* Depending on how the object was constructed, it may or may not have a * Depending on how the object was constructed, it may or may not have a
* local copy of the entire contents of the file. It may only have the * local copy of the entire contents of the file. It may only have the
@@ -43,7 +43,7 @@ namespace HPCloud\Storage\ObjectStorage;
* Remote objects can be modified locally. Simply modifying an object * Remote objects can be modified locally. Simply modifying an object
* will not result in those modifications being stored on the remote * will not result in those modifications being stored on the remote
* server. The object must be saved (see * server. The object must be saved (see
* HPCloud::Storage::ObjectStorage::Container::save()). When an * OpenStack::Storage::ObjectStorage::Container::save()). When an
* object is modified so that its local contents differ from the remote * object is modified so that its local contents differ from the remote
* stored copy, it is marked dirty (see isDirty()). * stored copy, it is marked dirty (see isDirty()).
*/ */
@@ -112,8 +112,8 @@ class RemoteObject extends Object {
* The URL to the object in the object storage. Used for issuing * The URL to the object in the object storage. Used for issuing
* subsequent requests. * subsequent requests.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* A new RemoteObject. * A new RemoteObject.
*/ */
public static function newFromHeaders($name, $headers, $token, $url) { public static function newFromHeaders($name, $headers, $token, $url) {
@@ -208,8 +208,8 @@ class RemoteObject extends Object {
/** /**
* Set the headers * Set the headers
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
public function setHeaders($headers) { public function setHeaders($headers) {
@@ -266,8 +266,8 @@ class RemoteObject extends Object {
/** /**
* Filter the headers. * Filter the headers.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
public function filterHeaders(&$headers) { public function filterHeaders(&$headers) {
@@ -303,8 +303,8 @@ class RemoteObject extends Object {
* @param array $keys * @param array $keys
* The header names to be removed. * The header names to be removed.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
public function removeHeaders($keys) { public function removeHeaders($keys) {
@@ -334,10 +334,10 @@ class RemoteObject extends Object {
* @retval string * @retval string
* @return string * @return string
* The contents of the file as a string. * The contents of the file as a string.
* @throws \HPCloud\Transport\FileNotFoundException * @throws \OpenStack\Transport\FileNotFoundException
* when the requested content cannot be located on the remote * when the requested content cannot be located on the remote
* server. * server.
* @throws \HPCloud\Exception * @throws \OpenStack\Exception
* when an unknown exception (usually an abnormal network condition) * when an unknown exception (usually an abnormal network condition)
* occurs. * occurs.
*/ */
@@ -452,8 +452,8 @@ class RemoteObject extends Object {
* If this is TRUE, caching will be enabled. If this is FALSE, * If this is TRUE, caching will be enabled. If this is FALSE,
* caching will be disabled. * caching will be disabled.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setCaching($enabled) { public function setCaching($enabled) {
@@ -498,8 +498,8 @@ class RemoteObject extends Object {
* is hashed and checked against a server-supplied MD5 hashcode. If * is hashed and checked against a server-supplied MD5 hashcode. If
* this is FALSE, no checking is done. * this is FALSE, no checking is done.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
public function setContentVerification($enabled) { public function setContentVerification($enabled) {
@@ -574,8 +574,8 @@ class RemoteObject extends Object {
* @param boolean $fetchContent * @param boolean $fetchContent
* If this is TRUE, the content will be downloaded as well. * If this is TRUE, the content will be downloaded as well.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
public function refresh($fetchContent = FALSE) { public function refresh($fetchContent = FALSE) {
@@ -601,15 +601,15 @@ class RemoteObject extends Object {
* cause the remote host to return the object in the response body. * cause the remote host to return the object in the response body.
* The response body is not handled, though. If this is set to * The response body is not handled, though. If this is set to
* FALSE, a HEAD request is sent, and no body is returned. * FALSE, a HEAD request is sent, and no body is returned.
* @retval HPCloud::Transport::Response * @retval OpenStack::Transport::Response
* @return \HPCloud\Transport\Response * @return \OpenStack\Transport\Response
* containing the object metadata and (depending on the * containing the object metadata and (depending on the
* $fetchContent flag) optionally the data. * $fetchContent flag) optionally the data.
*/ */
protected function fetchObject($fetchContent = FALSE) { protected function fetchObject($fetchContent = FALSE) {
$method = $fetchContent ? 'GET' : 'HEAD'; $method = $fetchContent ? 'GET' : 'HEAD';
$client = \HPCloud\Transport::instance(); $client = \OpenStack\Transport::instance();
$headers = array( $headers = array(
'X-Auth-Token' => $this->token, 'X-Auth-Token' => $this->token,
); );
@@ -617,7 +617,7 @@ class RemoteObject extends Object {
$response = $client->doRequest($this->url, $method, $headers); $response = $client->doRequest($this->url, $method, $headers);
if ($response->status() != 200) { if ($response->status() != 200) {
throw new \HPCloud\Exception('An unknown exception occurred during transmission.'); throw new \OpenStack\Exception('An unknown exception occurred during transmission.');
} }
$this->extractFromHeaders($response); $this->extractFromHeaders($response);
@@ -630,8 +630,8 @@ class RemoteObject extends Object {
* *
* This is used internally to set object properties from headers. * This is used internally to set object properties from headers.
* *
* @retval HPCloud::Storage::ObjectStorage::RemoteObject * @retval OpenStack::Storage::ObjectStorage::RemoteObject
* @return \HPCloud\Storage\ObjectStorage\RemoteObject * @return \OpenStack\Storage\ObjectStorage\RemoteObject
* $this for the current object so it can be used in chaining methods. * $this for the current object so it can be used in chaining methods.
*/ */
protected function extractFromHeaders($response) { protected function extractFromHeaders($response) {

View File

@@ -24,10 +24,10 @@ SOFTWARE.
* Contains the stream wrapper for `swift://` URLs. * Contains the stream wrapper for `swift://` URLs.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
use \HPCloud\Bootstrap; use \OpenStack\Bootstrap;
use \HPCloud\Storage\ObjectStorage; use \OpenStack\Storage\ObjectStorage;
/** /**
* Provides stream wrapping for Swift. * Provides stream wrapping for Swift.
@@ -83,7 +83,7 @@ use \HPCloud\Storage\ObjectStorage;
* The principle purpose of this wrapper is to make it easy to access and * The principle purpose of this wrapper is to make it easy to access and
* manipulate objects on a remote object storage instance. Managing * manipulate objects on a remote object storage instance. Managing
* containers is a secondary concern (and can often better be managed using * containers is a secondary concern (and can often better be managed using
* the HPCloud API). Consequently, almost all actions done through the * the OpenStack API). Consequently, almost all actions done through the
* stream wrapper are focused on objects, not containers, servers, etc. * stream wrapper are focused on objects, not containers, servers, etc.
* *
* <b>Retrieving an Existing Object</b> * <b>Retrieving an Existing Object</b>
@@ -102,7 +102,7 @@ use \HPCloud\Storage\ObjectStorage;
* *
* @code * @code
* <?php * <?php
* \HPCloud\Bootstrap::useStreamWrappers(); * \OpenStack\Bootstrap::useStreamWrappers();
* // Set up the context. * // Set up the context.
* $context = stream_context_create( * $context = stream_context_create(
* array('swift' => array( * array('swift' => array(
@@ -144,7 +144,7 @@ use \HPCloud\Storage\ObjectStorage;
* - filesize() * - filesize()
* - fileperms() * - fileperms()
* *
* The HPCloud stream wrapper provides support for these file-level functions. * The OpenStack stream wrapper provides support for these file-level functions.
* But there are a few things you should know: * But there are a few things you should know:
* *
* - Each call to one of these functions generates at least one request. It may * - Each call to one of these functions generates at least one request. It may
@@ -199,14 +199,14 @@ use \HPCloud\Storage\ObjectStorage;
* said markers ought to be created, they are not supported by the stream * said markers ought to be created, they are not supported by the stream
* wrapper. * wrapper.
* *
* As usual, the underlying HPCloud::Storage::ObjectStorage::Container class * As usual, the underlying OpenStack::Storage::ObjectStorage::Container class
* supports the full range of Swift features. * supports the full range of Swift features.
* *
* <b>SUPPORTED CONTEXT PARAMETERS</b> * <b>SUPPORTED CONTEXT PARAMETERS</b>
* *
* This section details paramters that can be passed <i>either</i> * This section details paramters that can be passed <i>either</i>
* through a stream context <i>or</i> through * through a stream context <i>or</i> through
* HPCloud::Bootstrap::setConfiguration(). * OpenStack::Bootstrap::setConfiguration().
* *
* @attention * @attention
* PHP functions that do not allow you to pass a context may still be supported * PHP functions that do not allow you to pass a context may still be supported
@@ -227,7 +227,7 @@ use \HPCloud\Storage\ObjectStorage;
* to an account and tenant. * to an account and tenant.
* *
* The following parameters may be set either in the stream context * The following parameters may be set either in the stream context
* or through HPCloud::Bootstrap::setConfiguration(): * or through OpenStack::Bootstrap::setConfiguration():
* *
* - token: An auth token. If this is supplied, authentication is skipped and * - token: An auth token. If this is supplied, authentication is skipped and
* this token is used. NOTE: You MUST set swift_endpoint if using this * this token is used. NOTE: You MUST set swift_endpoint if using this
@@ -241,7 +241,7 @@ use \HPCloud\Storage\ObjectStorage;
* - endpoint: The URL to the authentication endpoint. Necessary if you are not * - endpoint: The URL to the authentication endpoint. Necessary if you are not
* using a 'token' and 'swift_endpoint'. * using a 'token' and 'swift_endpoint'.
* - use_swift_auth: If this is set to TRUE, it will force the app to use * - use_swift_auth: If this is set to TRUE, it will force the app to use
* the deprecated swiftAuth instead of IdentityServices authentication. * the deprecated swiftAuth instead of IdentityService authentication.
* In general, you should avoid using this. * In general, you should avoid using this.
* - content_type: This is effective only when writing files. It will * - content_type: This is effective only when writing files. It will
* set the Content-Type of the file during upload. * set the Content-Type of the file during upload.
@@ -420,7 +420,7 @@ class StreamWrapper {
$this->dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep); $this->dirListing = $container->objectsWithPrefix($this->dirPrefix, $sep);
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Directory could not be opened: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Directory could not be opened: ' . $e->getMessage(), E_USER_WARNING);
return FALSE; return FALSE;
} }
@@ -462,7 +462,7 @@ class StreamWrapper {
$curr = $this->dirListing[$this->dirIndex]; $curr = $this->dirListing[$this->dirIndex];
$this->dirIndex++; $this->dirIndex++;
if ($curr instanceof \HPCloud\Storage\ObjectStorage\Subdir) { if ($curr instanceof \OpenStack\Storage\ObjectStorage\Subdir) {
$fullpath = $curr->path(); $fullpath = $curr->path();
} }
else { else {
@@ -578,7 +578,7 @@ class StreamWrapper {
return $container->delete($src['path']); return $container->delete($src['path']);
} }
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Rename was not completed: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Rename was not completed: ' . $e->getMessage(), E_USER_WARNING);
return FALSE; return FALSE;
} }
@@ -631,7 +631,7 @@ class StreamWrapper {
try { try {
$this->writeRemote(); $this->writeRemote();
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE); trigger_error('Error while closing: ' . $e->getMessage(), E_USER_NOTICE);
return FALSE; return FALSE;
} }
@@ -671,7 +671,7 @@ class StreamWrapper {
try { try {
$this->writeRemote(); $this->writeRemote();
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
syslog(LOG_WARNING, $e); syslog(LOG_WARNING, $e);
trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE); trigger_error('Error while flushing: ' . $e->getMessage(), E_USER_NOTICE);
return FALSE; return FALSE;
@@ -820,7 +820,7 @@ class StreamWrapper {
try { try {
$this->initializeObjectStorage(); $this->initializeObjectStorage();
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Failed to init object storage: ' . $e->getMessage(), E_USER_WARNING);
return FALSE; return FALSE;
} }
@@ -834,7 +834,7 @@ class StreamWrapper {
try { try {
$this->container = $this->store->container($containerName); $this->container = $this->store->container($containerName);
} }
catch (\HPCloud\Transport\FileNotFoundException $e) { catch (\OpenStack\Transport\FileNotFoundException $e) {
trigger_error('Container not found.', E_USER_WARNING); trigger_error('Container not found.', E_USER_WARNING);
return FALSE; return FALSE;
} }
@@ -883,7 +883,7 @@ class StreamWrapper {
// If a 404 is thrown, we need to determine whether // If a 404 is thrown, we need to determine whether
// or not a new file should be created. // or not a new file should be created.
catch (\HPCloud\Transport\FileNotFoundException $nf) { catch (\OpenStack\Transport\FileNotFoundException $nf) {
// For many modes, we just go ahead and create. // For many modes, we just go ahead and create.
if ($this->createIfNotFound) { if ($this->createIfNotFound) {
@@ -900,7 +900,7 @@ class StreamWrapper {
} }
// All other exceptions are fatal. // All other exceptions are fatal.
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
//if ($this->triggerErrors) { //if ($this->triggerErrors) {
trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Failed to fetch object: ' . $e->getMessage(), E_USER_WARNING);
//} //}
@@ -1001,7 +1001,7 @@ class StreamWrapper {
* *
* To use standard \c stat() on a Swift stream, you will * To use standard \c stat() on a Swift stream, you will
* need to set account information (tenant ID, account ID, secret, * need to set account information (tenant ID, account ID, secret,
* etc.) through HPCloud::Bootstrap::setConfiguration(). * etc.) through OpenStack::Bootstrap::setConfiguration().
* *
* @retval array * @retval array
* @return array * @return array
@@ -1061,7 +1061,7 @@ class StreamWrapper {
* a marker will NOT delete the contents of the "directory". * a marker will NOT delete the contents of the "directory".
* *
* @attention * @attention
* You will need to use HPCloud::Bootstrap::setConfiguration() to set the * You will need to use OpenStack::Bootstrap::setConfiguration() to set the
* necessary stream configuration, since \c unlink() does not take a context. * necessary stream configuration, since \c unlink() does not take a context.
* *
* @param string $path * @param string $path
@@ -1093,10 +1093,10 @@ class StreamWrapper {
$name = $url['host']; $name = $url['host'];
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . rawurlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token); $container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token);
return $container->delete($url['path']); return $container->delete($url['path']);
} }
catch (\HPCLoud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Error during unlink: ' . $e->getMessage(), E_USER_WARNING);
return FALSE; return FALSE;
} }
@@ -1126,10 +1126,10 @@ class StreamWrapper {
$name = $url['host']; $name = $url['host'];
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . rawurlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token); $container = new \OpenStack\Storage\ObjectStorage\Container($name, $endpoint_url, $token);
$obj = $container->remoteObject($url['path']); $obj = $container->remoteObject($url['path']);
} }
catch(\HPCloud\Exception $e) { catch(\OpenStack\Exception $e) {
// Apparently file_exists does not set STREAM_URL_STAT_QUIET. // Apparently file_exists does not set STREAM_URL_STAT_QUIET.
//if ($flags & STREAM_URL_STAT_QUIET) { //if ($flags & STREAM_URL_STAT_QUIET) {
//trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING); //trigger_error('Could not stat remote file: ' . $e->getMessage(), E_USER_WARNING);
@@ -1141,7 +1141,7 @@ class StreamWrapper {
try { try {
return @$this->generateStat($obj, $container, $obj->contentLength()); return @$this->generateStat($obj, $container, $obj->contentLength());
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
return FALSE; return FALSE;
} }
} }
@@ -1180,7 +1180,7 @@ class StreamWrapper {
/** /**
* EXPERT: Get the ObjectStorage for this wrapper. * EXPERT: Get the ObjectStorage for this wrapper.
* *
* @retval object HPCloud::ObjectStorage * @retval object OpenStack::ObjectStorage
* An ObjectStorage object. * An ObjectStorage object.
* @see object() * @see object()
*/ */
@@ -1200,7 +1200,7 @@ class StreamWrapper {
} }
/** /**
* EXPERT: Get the service catalog (IdentityServices) for this wrapper. * EXPERT: Get the service catalog (IdentityService) for this wrapper.
* *
* This is only available when a file is opened via fopen(). * This is only available when a file is opened via fopen().
* *
@@ -1256,7 +1256,7 @@ class StreamWrapper {
$gid = 0; $gid = 0;
} }
if ($object instanceof \HPCloud\Storage\ObjectStorage\RemoteObject) { if ($object instanceof \OpenStack\Storage\ObjectStorage\RemoteObject) {
$modTime = $object->lastModified(); $modTime = $object->lastModified();
} }
else { else {
@@ -1295,8 +1295,8 @@ class StreamWrapper {
* @param string $mode * @param string $mode
* The mode string, e.g. `r+` or `wb`. * The mode string, e.g. `r+` or `wb`.
* *
* @retval HPCloud::Storage::ObjectStorage::StreamWrapper * @retval OpenStack::Storage::ObjectStorage::StreamWrapper
* @return \HPCloud\Storage\ObjectStorage\StreamWrapper * @return \OpenStack\Storage\ObjectStorage\StreamWrapper
* $this so the method can be used in chaining. * $this so the method can be used in chaining.
*/ */
protected function setMode($mode) { protected function setMode($mode) {
@@ -1409,8 +1409,8 @@ class StreamWrapper {
} }
// Check to see if the value can be gotten from // Check to see if the value can be gotten from
// \HPCloud\Bootstrap. // \OpenStack\Bootstrap.
$val = \HPCloud\Bootstrap::config($name, NULL); $val = \OpenStack\Bootstrap::config($name, NULL);
if (isset($val)) { if (isset($val)) {
return $val; return $val;
} }
@@ -1458,7 +1458,7 @@ class StreamWrapper {
* Based on the context, initialize the ObjectStorage. * Based on the context, initialize the ObjectStorage.
* *
* The following parameters may be set either in the stream context * The following parameters may be set either in the stream context
* or through HPCloud::Bootstrap::setConfiguration(): * or through OpenStack::Bootstrap::setConfiguration():
* *
* - token: An auth token. If this is supplied, authentication is skipped and * - token: An auth token. If this is supplied, authentication is skipped and
* this token is used. NOTE: You MUST set swift_endpoint if using this * this token is used. NOTE: You MUST set swift_endpoint if using this
@@ -1472,7 +1472,7 @@ class StreamWrapper {
* - endpoint: The URL to the authentication endpoint. Necessary if you are not * - endpoint: The URL to the authentication endpoint. Necessary if you are not
* using a 'token' and 'swift_endpoint'. * using a 'token' and 'swift_endpoint'.
* - use_swift_auth: If this is set to TRUE, it will force the app to use * - use_swift_auth: If this is set to TRUE, it will force the app to use
* the deprecated swiftAuth instead of IdentityServices authentication. * the deprecated swiftAuth instead of IdentityService authentication.
* In general, you should avoid using this. * In general, you should avoid using this.
* *
* To find these params, the method first checks the supplied context. If the * To find these params, the method first checks the supplied context. If the
@@ -1502,23 +1502,23 @@ class StreamWrapper {
// FIXME: If a token is invalidated, we should try to re-authenticate. // FIXME: If a token is invalidated, we should try to re-authenticate.
// If context has the info we need, start from there. // If context has the info we need, start from there.
if (!empty($token) && !empty($endpoint)) { if (!empty($token) && !empty($endpoint)) {
$this->store = new \HPCloud\Storage\ObjectStorage($token, $endpoint); $this->store = new \OpenStack\Storage\ObjectStorage($token, $endpoint);
} }
// DEPRECATED: For old swift auth. // DEPRECATED: For old swift auth.
elseif ($this->cxt('use_swift_auth', FALSE)) { elseif ($this->cxt('use_swift_auth', FALSE)) {
if (empty($authUrl) || empty($account) || empty($key)) { if (empty($authUrl) || empty($account) || empty($key)) {
throw new \HPCloud\Exception('account, endpoint, key are required stream parameters.'); throw new \OpenStack\Exception('account, endpoint, key are required stream parameters.');
} }
$this->store = \HPCloud\Storage\ObjectStorage::newFromSwiftAuth($account, $key, $authUrl); $this->store = \OpenStack\Storage\ObjectStorage::newFromSwiftAuth($account, $key, $authUrl);
} }
// If we get here and tenant ID is not set, we can't get a container. // If we get here and tenant ID is not set, we can't get a container.
elseif (empty($tenantId) && empty($tenantName)) { elseif (empty($tenantId) && empty($tenantName)) {
throw new \HPCloud\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.'); throw new \OpenStack\Exception('Either Tenant ID (tenantid) or Tenant Name (tenantname) is required.');
} }
elseif (empty($authUrl)) { elseif (empty($authUrl)) {
throw new \HPCloud\Exception('An Identity Service Endpoint (endpoint) is required.'); throw new \OpenStack\Exception('An Identity Service Endpoint (endpoint) is required.');
} }
// Try to authenticate and get a new token. // Try to authenticate and get a new token.
else { else {
@@ -1534,8 +1534,8 @@ class StreamWrapper {
/* /*
$catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE); $catalog = $ident->serviceCatalog(ObjectStorage::SERVICE_TYPE);
if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) { if (empty($catalog) || empty($catalog[0]['endpoints'][0]['publicURL'])) {
//throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE)); //throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.' . print_r($catalog, TRUE));
throw new \HPCloud\Exception('No object storage services could be found for this tenant ID.'); throw new \OpenStack\Exception('No object storage services could be found for this tenant ID.');
} }
$serviceURL = $catalog[0]['endpoints'][0]['publicURL']; $serviceURL = $catalog[0]['endpoints'][0]['publicURL'];
@@ -1559,7 +1559,7 @@ class StreamWrapper {
$tenantName = $this->cxt('tenantname'); $tenantName = $this->cxt('tenantname');
$authUrl = $this->cxt('endpoint'); $authUrl = $this->cxt('endpoint');
$ident = new \HPCloud\Services\IdentityServices($authUrl); $ident = new \OpenStack\Services\IdentityService($authUrl);
// Frustrated? Go burninate. http://www.homestarrunner.com/trogdor.html // Frustrated? Go burninate. http://www.homestarrunner.com/trogdor.html
@@ -1570,7 +1570,7 @@ class StreamWrapper {
$token = $ident->authenticateAsAccount($account, $key, $tenantId, $tenantName); $token = $ident->authenticateAsAccount($account, $key, $tenantId, $tenantName);
} }
else { else {
throw new \HPCloud\Exception('Either username/password or account/key must be provided.'); throw new \OpenStack\Exception('Either username/password or account/key must be provided.');
} }
// Cache the service catalog. // Cache the service catalog.
self::$serviceCatalogCache[$token] = $ident->serviceCatalog(); self::$serviceCatalogCache[$token] = $ident->serviceCatalog();

View File

@@ -25,7 +25,7 @@ SOFTWARE.
* *
* <b>Note, this stream wrapper is in early testing.</b> * <b>Note, this stream wrapper is in early testing.</b>
* *
* The stream wrapper implemented in HPCloud\Storage\ObjectStorage\StreamWrapper * The stream wrapper implemented in OpenStack\Storage\ObjectStorage\StreamWrapper
* only supports the elements of a stream that are implemented by object * only supports the elements of a stream that are implemented by object
* storage. This is how the PHP documentation states a stream wrapper should be * storage. This is how the PHP documentation states a stream wrapper should be
* created. Because some features do not exist, attempting to treat a stream * created. Because some features do not exist, attempting to treat a stream
@@ -38,7 +38,7 @@ SOFTWARE.
* Hence the protocol is swiftfs standing for swift file system. * Hence the protocol is swiftfs standing for swift file system.
* *
* To understand how this stream wrapper works start by first reading the * To understand how this stream wrapper works start by first reading the
* documentation on the HPCloud::Storage::ObjectStorage::StreamWrapper. * documentation on the OpenStack::Storage::ObjectStorage::StreamWrapper.
* *
* <b>DIRECTORIES</b> * <b>DIRECTORIES</b>
* *
@@ -51,7 +51,7 @@ SOFTWARE.
* *
* In addition to the parameters supported by StreamWrapper, the following * In addition to the parameters supported by StreamWrapper, the following
* parameters may be set either in the stream context or through * parameters may be set either in the stream context or through
* HPCloud::Bootstrap::setConfiguration(): * OpenStack::Bootstrap::setConfiguration():
* - swiftfs_fake_stat_mode: Directories don't exist in swift. When stat() is * - swiftfs_fake_stat_mode: Directories don't exist in swift. When stat() is
* is called on a directory we mock the stat information so functions like * is called on a directory we mock the stat information so functions like
* is_dir will work. The default file permissions is 0777. Though this * is_dir will work. The default file permissions is 0777. Though this
@@ -64,10 +64,10 @@ SOFTWARE.
* FALSE. * FALSE.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
use \HPCloud\Bootstrap; use \OpenStack\Bootstrap;
use \HPCloud\Storage\ObjectStorage; use \OpenStack\Storage\ObjectStorage;
/** /**
* Provides stream wrapping for Swift like a file system. * Provides stream wrapping for Swift like a file system.
@@ -178,7 +178,7 @@ class StreamWrapperFS extends StreamWrapper {
return !empty($dirListing); return !empty($dirListing);
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING); trigger_error('Path could not be opened: ' . $e->getMessage(), E_USER_WARNING);
return FALSE; return FALSE;
} }

View File

@@ -24,7 +24,7 @@ SOFTWARE.
* Contains the Subdir class. * Contains the Subdir class.
*/ */
namespace HPCloud\Storage\ObjectStorage; namespace OpenStack\Storage\ObjectStorage;
/** /**
* Represent a subdirectory (subdir) entry. * Represent a subdirectory (subdir) entry.

View File

@@ -76,11 +76,11 @@ Your settings should look something like this:
``` ```
; Settings to work with swift: ; Settings to work with swift:
; hpcloud.swift.account = 12345678:87654321 ; openstack.swift.account = 12345678:87654321
; hpcloud.swift.key = abcdef123456 ; openstack.swift.key = abcdef123456
; hpcloud.swift.url = https://region-a.geo-1.objects.hpcloudsvc.com/auth/v1.0/ ; openstack.swift.url = https://region-a.geo-1.objects.hpcloudsvc.com/auth/v1.0/
hpcloud.swift.container = "I♡HPCloud" openstack.swift.container = "I♡HPCloud"
openstack.identity.url = https://region-a.geo-1.idenity.hpcloudsvc.com openstack.identity.url = https://region-a.geo-1.idenity.hpcloudsvc.com
openstack.identity.tenantId = 12345 openstack.identity.tenantId = 12345
@@ -93,7 +93,7 @@ hpcloud.identity.key = 9878787
You will need to add all of the `hpcloud.identity` settings, and all of You will need to add all of the `hpcloud.identity` settings, and all of
this information can be found on your console. this information can be found on your console.
The hpcloud.swift.account, key, and url params are no longer required The openstack.swift.account, key, and url params are no longer required
for the basic tests, but are required if you are also running the tests for the basic tests, but are required if you are also running the tests
in the group `deprecated`. in the group `deprecated`.

View File

@@ -47,7 +47,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
public static $ostore = NULL; public static $ostore = NULL;
/** /**
* The IdentityServices instance. * The IdentityService instance.
*/ */
public static $ident; public static $ident;
@@ -97,17 +97,17 @@ class TestCase extends \PHPUnit_Framework_TestCase {
*/ */
protected function swiftAuth() { protected function swiftAuth() {
$user = self::$settings['hpcloud.swift.account']; $user = self::$settings['openstack.swift.account'];
$key = self::$settings['hpcloud.swift.key']; $key = self::$settings['openstack.swift.key'];
$url = self::$settings['hpcloud.swift.url']; $url = self::$settings['openstack.swift.url'];
//$url = self::$settings['openstack.identity.url']; //$url = self::$settings['openstack.identity.url'];
return \HPCloud\Storage\ObjectStorage::newFromSwiftAuth($user, $key, $url); return \OpenStack\Storage\ObjectStorage::newFromSwiftAuth($user, $key, $url);
} }
/** /**
* Get a handle to an IdentityServices object. * Get a handle to an IdentityService object.
* *
* Authentication is performed, and the returned * Authentication is performed, and the returned
* service has its tenant ID set already. * service has its tenant ID set already.
@@ -127,7 +127,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$is = new \HPCloud\Services\IdentityServices($url); $is = new \OpenStack\Services\IdentityService($url);
$token = $is->authenticateAsUser($user, $pass, $tenantId); $token = $is->authenticateAsUser($user, $pass, $tenantId);
@@ -142,7 +142,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
if ($reset || empty(self::$ostore)) { if ($reset || empty(self::$ostore)) {
$ident = $this->identity($reset); $ident = $this->identity($reset);
$objStore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); $objStore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident);
self::$ostore = $objStore; self::$ostore = $objStore;
@@ -158,7 +158,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
if (empty($this->containerFixture)) { if (empty($this->containerFixture)) {
$store = $this->objectStore(); $store = $this->objectStore();
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
try { try {
$store->createContainer($cname); $store->createContainer($cname);
@@ -216,7 +216,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
*/ */
protected function destroyContainerFixture() { protected function destroyContainerFixture() {
$store = $this->objectStore(); $store = $this->objectStore();
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
try { try {
$container = $store->container($cname); $container = $store->container($cname);

View File

@@ -24,16 +24,16 @@ SOFTWARE.
* *
* Unit tests for ObjectStorage ACLs. * Unit tests for ObjectStorage ACLs.
*/ */
namespace HPCloud\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\Storage\ObjectStorage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\ACL; use \OpenStack\Storage\ObjectStorage\ACL;
/** /**
* @ingroup Tests * @ingroup Tests
*/ */
class ACLTest extends \HPCloud\Tests\TestCase { class ACLTest extends \OpenStack\Tests\TestCase {
public function testConstructor() { public function testConstructor() {
$acl = new ACL(); $acl = new ACL();

View File

@@ -24,16 +24,16 @@ SOFTWARE.
* *
* Unit tests for Containers. * Unit tests for Containers.
*/ */
namespace HPCloud\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\Storage\ObjectStorage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\Container; use \OpenStack\Storage\ObjectStorage\Container;
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
use \HPCloud\Storage\ObjectStorage\ACL; use \OpenStack\Storage\ObjectStorage\ACL;
class ContainerTest extends \HPCloud\Tests\TestCase { class ContainerTest extends \OpenStack\Tests\TestCase {
const FILENAME = 'unit-test-dummy.txt'; const FILENAME = 'unit-test-dummy.txt';
const FILESTR = 'This is a test.'; const FILESTR = 'This is a test.';
@@ -54,7 +54,7 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
} }
/** /**
* @expectedException \HPCloud\Exception * @expectedException \OpenStack\Exception
*/ */
public function testConstructorFailure() { public function testConstructorFailure() {
$container = new Container('foo'); $container = new Container('foo');
@@ -195,8 +195,8 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
try { try {
$foo = $container->object('no/such'); $foo = $container->object('no/such');
} }
catch (\HPCloud\Exception $e) { catch (\OpenStack\Exception $e) {
$this->assertInstanceOf('\HPCloud\Transport\FileNotFoundException', $e); $this->assertInstanceOf('\OpenStack\Transport\FileNotFoundException', $e);
} }
} }
@@ -265,7 +265,7 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
$this->assertEquals(2, count($objects)); $this->assertEquals(2, count($objects));
foreach ($objects as $o) { foreach ($objects as $o) {
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\Object', $o); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\Object', $o);
} }
// This should give us one file and one subdir. // This should give us one file and one subdir.
@@ -378,7 +378,7 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
// Create a new container. // Create a new container.
$store = $this->objectStore(); $store = $this->objectStore();
$cname = self::$settings['hpcloud.swift.container'] . 'COPY'; $cname = self::$settings['openstack.swift.container'] . 'COPY';
if ($store->hasContainer($cname)) { if ($store->hasContainer($cname)) {
$this->eradicateContainer($cname); $this->eradicateContainer($cname);
} }
@@ -424,7 +424,7 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
*/ */
public function testAcl() { public function testAcl() {
$store = $this->objectStore(); $store = $this->objectStore();
$cname = self::$settings['hpcloud.swift.container'] . 'PUBLIC'; $cname = self::$settings['openstack.swift.container'] . 'PUBLIC';
if ($store->hasContainer($cname)) { if ($store->hasContainer($cname)) {
$store->deleteContainer($cname); $store->deleteContainer($cname);
@@ -438,7 +438,7 @@ class ContainerTest extends \HPCloud\Tests\TestCase {
$acl = $container->acl(); $acl = $container->acl();
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\ACL', $acl); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\ACL', $acl);
$this->assertTrue($acl->isPublic()); $this->assertTrue($acl->isPublic());
$store->deleteContainer($cname); $store->deleteContainer($cname);

View File

@@ -24,16 +24,16 @@ SOFTWARE.
* *
* Unit tests for ObjectStorage. * Unit tests for ObjectStorage.
*/ */
namespace HPCloud\Tests\Storage; namespace OpenStack\Tests\Storage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
use \HPCloud\Storage\ObjectStorage\ACL; use \OpenStack\Storage\ObjectStorage\ACL;
class ObjectStorageTest extends \HPCloud\Tests\TestCase { class ObjectStorageTest extends \OpenStack\Tests\TestCase {
/** /**
* Canary test. * Canary test.
@@ -50,7 +50,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
$ostore = $this->swiftAuth(); $ostore = $this->swiftAuth();
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@@ -60,7 +60,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
public function testConstructor() { public function testConstructor() {
$ident = $this->identity(); $ident = $this->identity();
$services = $ident->serviceCatalog(\HPCloud\Storage\ObjectStorage::SERVICE_TYPE); $services = $ident->serviceCatalog(\OpenStack\Storage\ObjectStorage::SERVICE_TYPE);
if (empty($services)) { if (empty($services)) {
throw new \Exception('No object-store service found.'); throw new \Exception('No object-store service found.');
@@ -69,9 +69,9 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
//$serviceURL = $services[0]['endpoints'][0]['adminURL']; //$serviceURL = $services[0]['endpoints'][0]['adminURL'];
$serviceURL = $services[0]['endpoints'][0]['publicURL']; $serviceURL = $services[0]['endpoints'][0]['publicURL'];
$ostore = new \HPCloud\Storage\ObjectStorage($ident->token(), $serviceURL); $ostore = new \OpenStack\Storage\ObjectStorage($ident->token(), $serviceURL);
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@@ -80,8 +80,8 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
$ident = $this->identity(); $ident = $this->identity();
$tok = $ident->token(); $tok = $ident->token();
$cat = $ident->serviceCatalog(); $cat = $ident->serviceCatalog();
$ostore = \HPCloud\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok); $ostore = \OpenStack\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok);
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
@@ -89,25 +89,25 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
$ident = $this->identity(); $ident = $this->identity();
$tok = $ident->token(); $tok = $ident->token();
$cat = $ident->serviceCatalog(); $cat = $ident->serviceCatalog();
$ostore = \HPCloud\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok, 'region-w.geo-99999.fake'); $ostore = \OpenStack\Storage\ObjectStorage::newFromServiceCatalog($cat, $tok, 'region-w.geo-99999.fake');
$this->assertEmpty($ostore); $this->assertEmpty($ostore);
} }
public function testNewFromIdnetity() { public function testNewFromIdnetity() {
$ident = $this->identity(); $ident = $this->identity();
$ostore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); $ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident);
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
} }
public function testNewFromIdentityAltRegion() { public function testNewFromIdentityAltRegion() {
$ident = $this->identity(); $ident = $this->identity();
$ostore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1'); $ostore = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident, 'region-b.geo-1');
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage', $ostore); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage', $ostore);
$this->assertTrue(strlen($ostore->token()) > 0); $this->assertTrue(strlen($ostore->token()) > 0);
// Make sure the store is not the same as the default region. // Make sure the store is not the same as the default region.
$ostoreDefault = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); $ostoreDefault = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident);
$this->assertNotEquals($ostore, $ostoreDefault); $this->assertNotEquals($ostore, $ostoreDefault);
} }
@@ -116,7 +116,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @ group acl * @ group acl
*/ */
public function testCreateContainer() { public function testCreateContainer() {
$testCollection = self::$settings['hpcloud.swift.container']; $testCollection = self::$settings['openstack.swift.container'];
$this->assertNotEmpty($testCollection, "Canary: container name must be in settings file."); $this->assertNotEmpty($testCollection, "Canary: container name must be in settings file.");
@@ -161,14 +161,14 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
//$first = array_shift($containers); //$first = array_shift($containers);
$testCollection = self::conf('hpcloud.swift.container'); $testCollection = self::conf('openstack.swift.container');
$testContainer = $containers[$testCollection]; $testContainer = $containers[$testCollection];
$this->assertEquals($testCollection, $testContainer->name()); $this->assertEquals($testCollection, $testContainer->name());
$this->assertEquals(0, $testContainer->bytes()); $this->assertEquals(0, $testContainer->bytes());
$this->assertEquals(0, $testContainer->count()); $this->assertEquals(0, $testContainer->count());
// Make sure we get back an ACL: // Make sure we get back an ACL:
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\ACL', $testContainer->acl()); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\ACL', $testContainer->acl());
} }
@@ -176,7 +176,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @depends testCreateContainer * @depends testCreateContainer
*/ */
public function testContainer() { public function testContainer() {
$testCollection = self::$settings['hpcloud.swift.container']; $testCollection = self::$settings['openstack.swift.container'];
$store = $this->objectStore(); $store = $this->objectStore();
$container = $store->container($testCollection); $container = $store->container($testCollection);
@@ -194,7 +194,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @depends testCreateContainer * @depends testCreateContainer
*/ */
public function testHasContainer() { public function testHasContainer() {
$testCollection = self::$settings['hpcloud.swift.container']; $testCollection = self::$settings['openstack.swift.container'];
$store = $this->objectStore(); $store = $this->objectStore();
$this->assertTrue($store->hasContainer($testCollection)); $this->assertTrue($store->hasContainer($testCollection));
@@ -205,7 +205,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @depends testHasContainer * @depends testHasContainer
*/ */
public function testDeleteContainer() { public function testDeleteContainer() {
$testCollection = self::$settings['hpcloud.swift.container']; $testCollection = self::$settings['openstack.swift.container'];
$store = $this->objectStore(); $store = $this->objectStore();
//$ret = $store->createContainer($testCollection); //$ret = $store->createContainer($testCollection);
@@ -221,11 +221,11 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
} }
/** /**
* @expectedException \HPCloud\Storage\ObjectStorage\ContainerNotEmptyException * @expectedException \OpenStack\Storage\ObjectStorage\ContainerNotEmptyException
*/ */
public function testDeleteNonEmptyContainer() { public function testDeleteNonEmptyContainer() {
$testCollection = self::$settings['hpcloud.swift.container']; $testCollection = self::$settings['openstack.swift.container'];
$this->assertNotEmpty($testCollection); $this->assertNotEmpty($testCollection);
@@ -258,7 +258,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @group acl * @group acl
*/ */
public function testCreateContainerPublic() { public function testCreateContainerPublic() {
$testCollection = self::$settings['hpcloud.swift.container'] . 'PUBLIC'; $testCollection = self::$settings['openstack.swift.container'] . 'PUBLIC';
$store = $this->objectStore(); $store = $this->objectStore();
if ($store->hasContainer($testCollection)) { if ($store->hasContainer($testCollection)) {
$store->deleteContainer($testCollection); $store->deleteContainer($testCollection);
@@ -273,7 +273,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
$url = $container->url() . '?format=xml'; $url = $container->url() . '?format=xml';
// Use CURL to get better debugging: // Use CURL to get better debugging:
//$client = \HPCloud\Transport::instance(); //$client = \OpenStack\Transport::instance();
//$response = $client->doRequest($url, 'GET'); //$response = $client->doRequest($url, 'GET');
$data = file_get_contents($url); $data = file_get_contents($url);
@@ -289,7 +289,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
* @depends testCreateContainerPublic * @depends testCreateContainerPublic
*/ */
public function testChangeContainerACL() { public function testChangeContainerACL() {
$testCollection = self::$settings['hpcloud.swift.container'] . 'PUBLIC'; $testCollection = self::$settings['openstack.swift.container'] . 'PUBLIC';
$store = $this->objectStore(); $store = $this->objectStore();
if ($store->hasContainer($testCollection)) { if ($store->hasContainer($testCollection)) {
$store->deleteContainer($testCollection); $store->deleteContainer($testCollection);
@@ -297,7 +297,7 @@ class ObjectStorageTest extends \HPCloud\Tests\TestCase {
$ret = $store->createContainer($testCollection); $ret = $store->createContainer($testCollection);
$acl = \HPCloud\Storage\ObjectStorage\ACL::makePublic(); $acl = \OpenStack\Storage\ObjectStorage\ACL::makePublic();
$ret = $store->changeContainerACL($testCollection, $acl); $ret = $store->changeContainerACL($testCollection, $acl);
$this->assertFalse($ret); $this->assertFalse($ret);

View File

@@ -24,14 +24,14 @@ SOFTWARE.
* *
* Unit tests for ObjectStorage Object. * Unit tests for ObjectStorage Object.
*/ */
namespace HPCloud\Tests\Storage; namespace OpenStack\Tests\Storage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
class ObjectTest extends \HPCloud\Tests\TestCase { class ObjectTest extends \OpenStack\Tests\TestCase {
const FNAME = 'descartes.txt'; const FNAME = 'descartes.txt';
const FCONTENT = 'Cogito ergo sum.'; const FCONTENT = 'Cogito ergo sum.';

View File

@@ -24,16 +24,16 @@ SOFTWARE.
* *
* Unit tests for ObjectStorage RemoteObject. * Unit tests for ObjectStorage RemoteObject.
*/ */
namespace HPCloud\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\Storage\ObjectStorage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\RemoteObject; use \OpenStack\Storage\ObjectStorage\RemoteObject;
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
use \HPCloud\Storage\ObjectStorage\Container; use \OpenStack\Storage\ObjectStorage\Container;
class RemoteObjectTest extends \HPCloud\Tests\TestCase { class RemoteObjectTest extends \OpenStack\Tests\TestCase {
const FNAME = 'RemoteObjectTest'; const FNAME = 'RemoteObjectTest';
//const FTYPE = 'text/plain; charset=UTF-8'; //const FTYPE = 'text/plain; charset=UTF-8';
@@ -74,7 +74,7 @@ class RemoteObjectTest extends \HPCloud\Tests\TestCase {
$obj = $container->remoteObject(self::FNAME); $obj = $container->remoteObject(self::FNAME);
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj);
return $obj; return $obj;
} }
@@ -184,8 +184,8 @@ class RemoteObjectTest extends \HPCloud\Tests\TestCase {
// This will be HTTP if we are using the PHP stream // This will be HTTP if we are using the PHP stream
// wrapper, but for CURL this will be PHP. // wrapper, but for CURL this will be PHP.
$klass = \HPCloud\Bootstrap::config('transport', NULL); $klass = \OpenStack\Bootstrap::config('transport', NULL);
if ($klass == '\HPCloud\Transport\PHPStreamTransport') { if ($klass == '\OpenStack\Transport\PHPStreamTransport') {
$expect = 'http'; $expect = 'http';
} }
else { else {
@@ -259,8 +259,8 @@ class RemoteObjectTest extends \HPCloud\Tests\TestCase {
// The CURL, though, backs its up with a temp file wrapped in a PHP // The CURL, though, backs its up with a temp file wrapped in a PHP
// stream. Other backends are likely to do the same. So this test // stream. Other backends are likely to do the same. So this test
// is weakened for CURL backends. // is weakened for CURL backends.
$transport = \HPCloud\Bootstrap::config('transport'); $transport = \OpenStack\Bootstrap::config('transport');
if ($transport == '\HPCloud\Transport\PHPStreamTransport') { if ($transport == '\OpenStack\Transport\PHPStreamTransport') {
$expect = 'http'; $expect = 'http';
} }
else { else {

View File

@@ -24,11 +24,11 @@ SOFTWARE.
* *
* Unit tests for Response. * Unit tests for Response.
*/ */
namespace HPCloud\Tests\Transport; namespace OpenStack\Tests\Transport;
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
class ResponseTest extends \HPCloud\Tests\TestCase { class ResponseTest extends \OpenStack\Tests\TestCase {
protected $fakeBody = '{"msg":"This is a fake response"}'; protected $fakeBody = '{"msg":"This is a fake response"}';
protected $fakeHeaders = array( protected $fakeHeaders = array(
@@ -61,7 +61,7 @@ class ResponseTest extends \HPCloud\Tests\TestCase {
// reset and seek don't reset the unread_bytes. // reset and seek don't reset the unread_bytes.
$metadata['unread_bytes'] = strlen($this->fakeBody); $metadata['unread_bytes'] = strlen($this->fakeBody);
return new \HPCloud\Transport\Response($file, $metadata); return new \OpenStack\Transport\Response($file, $metadata);
} }

View File

@@ -24,20 +24,20 @@ SOFTWARE.
* *
* Unit tests for the stream wrapper file systema. * Unit tests for the stream wrapper file systema.
*/ */
namespace HPCloud\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\Storage\ObjectStorage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\StreamWrapperFS; use \OpenStack\Storage\ObjectStorage\StreamWrapperFS;
use \HPCloud\Storage\ObjectStorage\Container; use \OpenStack\Storage\ObjectStorage\Container;
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
use \HPCloud\Storage\ObjectStorage\ACL; use \OpenStack\Storage\ObjectStorage\ACL;
/** /**
* @group streamWrapper * @group streamWrapper
*/ */
class StreamWrapperFSTest extends \HPCloud\Tests\TestCase { class StreamWrapperFSTest extends \OpenStack\Tests\TestCase {
const FNAME = 'streamTest.txt'; const FNAME = 'streamTest.txt';
const FTYPE = 'application/x-tuna-fish; charset=iso-8859-13'; const FTYPE = 'application/x-tuna-fish; charset=iso-8859-13';
@@ -56,22 +56,22 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$ident = new \HPCloud\Services\IdentityServices($url); $ident = new \OpenStack\Services\IdentityService($url);
$token = $ident->authenticateAsUser($user, $pass, $tenantId); $token = $ident->authenticateAsUser($user, $pass, $tenantId);
// Then we need to get an instance of storage // Then we need to get an instance of storage
$store = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); $store = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident);
// Delete the container and all the contents. // Delete the container and all the contents.
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
try { try {
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\HPCloud\Transport\FileNotFoundException $e) { catch (\OpenStack\Transport\FileNotFoundException $e) {
return; return;
} }
@@ -87,7 +87,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
protected function newUrl($objectName) { protected function newUrl($objectName) {
$scheme = StreamWrapperFS::DEFAULT_SCHEME; $scheme = StreamWrapperFS::DEFAULT_SCHEME;
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
$cname = urlencode($cname); $cname = urlencode($cname);
$objectParts = explode('/', $objectName); $objectParts = explode('/', $objectName);
@@ -105,7 +105,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
* This assumes auth has already been done. * This assumes auth has already been done.
*/ */
protected function basicSwiftContext($add = array(), $scheme = NULL) { protected function basicSwiftContext($add = array(), $scheme = NULL) {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
if (empty($scheme)) { if (empty($scheme)) {
$scheme = StreamWrapperFS::DEFAULT_SCHEME; $scheme = StreamWrapperFS::DEFAULT_SCHEME;
@@ -128,11 +128,11 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
/** /**
* This performs authentication via context. * This performs authentication via context.
* *
* UPDATE: This now users IdentityServices instead of deprecated * UPDATE: This now users IdentityService instead of deprecated
* swauth. * swauth.
*/ */
protected function authSwiftContext($add = array(), $scheme = NULL) { protected function authSwiftContext($add = array(), $scheme = NULL) {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
$account = self::$settings['openstack.identity.access']; $account = self::$settings['openstack.identity.access'];
$key = self::$settings['openstack.identity.secret']; $key = self::$settings['openstack.identity.secret'];
$tenant = self::$settings['openstack.identity.tenantId']; $tenant = self::$settings['openstack.identity.tenantId'];
@@ -173,14 +173,14 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
'token' => $this->objectStore()->token(), 'token' => $this->objectStore()->token(),
'swift_endpoint' => $this->objectStore()->url(), 'swift_endpoint' => $this->objectStore()->url(),
); );
\HPCloud\Bootstrap::setConfiguration($opts); \OpenStack\Bootstrap::setConfiguration($opts);
} }
// Canary. There are UTF-8 encoding issues in stream wrappers. // Canary. There are UTF-8 encoding issues in stream wrappers.
public function testStreamContext() { public function testStreamContext() {
// Clear old values. // Clear old values.
\HPCloud\Bootstrap::setConfiguration(array( \OpenStack\Bootstrap::setConfiguration(array(
'token' => NULL, 'token' => NULL,
)); ));
@@ -200,7 +200,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
// Canary // Canary
$this->assertNotEmpty(StreamWrapperFS::DEFAULT_SCHEME); $this->assertNotEmpty(StreamWrapperFS::DEFAULT_SCHEME);
$klass = '\HPCloud\Storage\ObjectStorage\StreamWrapperFS'; $klass = '\OpenStack\Storage\ObjectStorage\StreamWrapperFS';
stream_wrapper_register(StreamWrapperFS::DEFAULT_SCHEME, $klass); stream_wrapper_register(StreamWrapperFS::DEFAULT_SCHEME, $klass);
$wrappers = stream_get_wrappers(); $wrappers = stream_get_wrappers();
@@ -222,7 +222,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
* @depends testRegister * @depends testRegister
*/ */
public function testOpen() { public function testOpen() {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
// Create a fresh container. // Create a fresh container.
$this->eradicateContainer($cname); $this->eradicateContainer($cname);
@@ -384,7 +384,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
//throw new \Exception(print_r($md, true)); //throw new \Exception(print_r($md, true));
$obj = $md['wrapper_data']->object(); $obj = $md['wrapper_data']->object();
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj);
$this->assertEquals(self::FTYPE, $obj->contentType()); $this->assertEquals(self::FTYPE, $obj->contentType());

View File

@@ -24,20 +24,20 @@ SOFTWARE.
* *
* Unit tests for the stream wrapper. * Unit tests for the stream wrapper.
*/ */
namespace HPCloud\Tests\Storage\ObjectStorage; namespace OpenStack\Tests\Storage\ObjectStorage;
require_once 'src/HPCloud/Bootstrap.php'; require_once 'src/OpenStack/Bootstrap.php';
require_once 'test/TestCase.php'; require_once 'test/TestCase.php';
use \HPCloud\Storage\ObjectStorage\StreamWrapper; use \OpenStack\Storage\ObjectStorage\StreamWrapper;
use \HPCloud\Storage\ObjectStorage\Container; use \OpenStack\Storage\ObjectStorage\Container;
use \HPCloud\Storage\ObjectStorage\Object; use \OpenStack\Storage\ObjectStorage\Object;
use \HPCloud\Storage\ObjectStorage\ACL; use \OpenStack\Storage\ObjectStorage\ACL;
/** /**
* @group streamWrapper * @group streamWrapper
*/ */
class StreamWrapperTest extends \HPCloud\Tests\TestCase { class StreamWrapperTest extends \OpenStack\Tests\TestCase {
const FNAME = 'streamTest.txt'; const FNAME = 'streamTest.txt';
const FTYPE = 'application/x-tuna-fish; charset=iso-8859-13'; const FTYPE = 'application/x-tuna-fish; charset=iso-8859-13';
@@ -53,22 +53,22 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
$tenantId = self::conf('openstack.identity.tenantId'); $tenantId = self::conf('openstack.identity.tenantId');
$url = self::conf('openstack.identity.url'); $url = self::conf('openstack.identity.url');
$ident = new \HPCloud\Services\IdentityServices($url); $ident = new \OpenStack\Services\IdentityService($url);
$token = $ident->authenticateAsUser($user, $pass, $tenantId); $token = $ident->authenticateAsUser($user, $pass, $tenantId);
// Then we need to get an instance of storage // Then we need to get an instance of storage
$store = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident); $store = \OpenStack\Storage\ObjectStorage::newFromIdentity($ident);
// Delete the container and all the contents. // Delete the container and all the contents.
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
try { try {
$container = $store->container($cname); $container = $store->container($cname);
} }
// The container was never created. // The container was never created.
catch (\HPCloud\Transport\FileNotFoundException $e) { catch (\OpenStack\Transport\FileNotFoundException $e) {
return; return;
} }
@@ -84,7 +84,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
protected function newUrl($objectName) { protected function newUrl($objectName) {
$scheme = StreamWrapper::DEFAULT_SCHEME; $scheme = StreamWrapper::DEFAULT_SCHEME;
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
$cname = urlencode($cname); $cname = urlencode($cname);
$objectParts = explode('/', $objectName); $objectParts = explode('/', $objectName);
@@ -102,7 +102,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
* This assumes auth has already been done. * This assumes auth has already been done.
*/ */
protected function basicSwiftContext($add = array(), $scheme = NULL) { protected function basicSwiftContext($add = array(), $scheme = NULL) {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
if (empty($scheme)) { if (empty($scheme)) {
$scheme = StreamWrapper::DEFAULT_SCHEME; $scheme = StreamWrapper::DEFAULT_SCHEME;
@@ -125,11 +125,11 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
/** /**
* This performs authentication via context. * This performs authentication via context.
* *
* UPDATE: This now users IdentityServices instead of deprecated * UPDATE: This now users IdentityService instead of deprecated
* swauth. * swauth.
*/ */
protected function authSwiftContext($add = array(), $scheme = NULL) { protected function authSwiftContext($add = array(), $scheme = NULL) {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
$account = self::$settings['openstack.identity.access']; $account = self::$settings['openstack.identity.access'];
$key = self::$settings['openstack.identity.secret']; $key = self::$settings['openstack.identity.secret'];
$tenant = self::$settings['openstack.identity.tenantId']; $tenant = self::$settings['openstack.identity.tenantId'];
@@ -170,7 +170,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
'token' => $this->objectStore()->token(), 'token' => $this->objectStore()->token(),
'swift_endpoint' => $this->objectStore()->url(), 'swift_endpoint' => $this->objectStore()->url(),
); );
\HPCloud\Bootstrap::setConfiguration($opts); \OpenStack\Bootstrap::setConfiguration($opts);
} }
@@ -178,7 +178,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
public function testStreamContext() { public function testStreamContext() {
// Reset this in case something else left its // Reset this in case something else left its
// auth token lying around. // auth token lying around.
\HPCloud\Bootstrap::setConfiguration(array( \OpenStack\Bootstrap::setConfiguration(array(
'token' => NULL, 'token' => NULL,
)); ));
$cxt = $this->authSwiftContext(); $cxt = $this->authSwiftContext();
@@ -197,7 +197,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
// Canary // Canary
$this->assertNotEmpty(StreamWrapper::DEFAULT_SCHEME); $this->assertNotEmpty(StreamWrapper::DEFAULT_SCHEME);
$klass = '\HPCloud\Storage\ObjectStorage\StreamWrapper'; $klass = '\OpenStack\Storage\ObjectStorage\StreamWrapper';
stream_wrapper_register(StreamWrapper::DEFAULT_SCHEME, $klass); stream_wrapper_register(StreamWrapper::DEFAULT_SCHEME, $klass);
$wrappers = stream_get_wrappers(); $wrappers = stream_get_wrappers();
@@ -209,7 +209,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
* @depends testRegister * @depends testRegister
*/ */
public function testOpenFailureWithoutContext() { public function testOpenFailureWithoutContext() {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
// Create a fresh container. // Create a fresh container.
$this->eradicateContainer($cname); $this->eradicateContainer($cname);
@@ -225,7 +225,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
* @depends testRegister * @depends testRegister
*/ */
public function testOpen() { public function testOpen() {
$cname = self::$settings['hpcloud.swift.container']; $cname = self::$settings['openstack.swift.container'];
// Create a fresh container. // Create a fresh container.
$this->eradicateContainer($cname); $this->eradicateContainer($cname);
@@ -386,7 +386,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
//throw new \Exception(print_r($md, true)); //throw new \Exception(print_r($md, true));
$obj = $md['wrapper_data']->object(); $obj = $md['wrapper_data']->object();
$this->assertInstanceOf('\HPCloud\Storage\ObjectStorage\RemoteObject', $obj); $this->assertInstanceOf('\OpenStack\Storage\ObjectStorage\RemoteObject', $obj);
$this->assertEquals(self::FTYPE, $obj->contentType()); $this->assertEquals(self::FTYPE, $obj->contentType());

View File

@@ -23,18 +23,18 @@ openstack.identity.secret =
; Settings to work with swift: ; Settings to work with swift:
; Account is the tenandId:console username. ; Account is the tenandId:console username.
hpcloud.swift.account = 12345678:87654321 openstack.swift.account = 12345678:87654321
; Key is the console account password. ; Key is the console account password.
hpcloud.swift.key = abcdef123456 openstack.swift.key = abcdef123456
; URL is the same as used for identity services calls (including port) except ; URL is the same as used for identity services calls (including port) except
; with /auth/v1.0/ appended to the end. ; with /auth/v1.0/ appended to the end.
hpcloud.swift.url = https://region-a.geo-1.identity.hpcloudsvc.com:35357/auth/v1.0/ openstack.swift.url = https://region-a.geo-1.identity.hpcloudsvc.com:35357/auth/v1.0/
; Container used for testing. ; Container used for testing.
hpcloud.swift.container = "I♡HPCloud" openstack.swift.container = "I♡HPCloud"
; Specified region name to test against. ; Specified region name to test against.
hpcloud.swift.region = "region-a.geo-1" openstack.swift.region = "region-a.geo-1"
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Configuration Parameters ; ; Configuration Parameters ;