The OpenStack class represents a relationship (or "connection")
between a user and a service. This is the primary entry point into an OpenStack system, and the only one
where the developer is required to know and provide the endpoint URL (in
all other cases, the endpoint is derived from the Service Catalog provided
by the authentication system).
Since various providers have different mechanisms for authentication, users
will often use a subclass of OpenStack. For example, the Rackspace
class is provided for users of Rackspace's cloud services, and other cloud
providers are welcome to add their own subclasses as well.
General usage example:
$username = 'My Username';
$secret = 'My Secret';
$connection = new OpenCloud\OpenStack($username, $secret);
// having established the connection, we can set some defaults
// this sets the default name and region of the Compute service
$connection->SetDefaults('Compute', 'cloudServersOpenStack', 'ORD');
// access a Compute service
$chicago = $connection->Compute();
// if we want to access a different service, we can:
$dallas = $connection->Compute('cloudServersOpenStack', 'DFW');
Allows the user to append a user agent string Programs that are using these bindings are encouraged to add their
user agent to the one supplied by this SDK. This will permit cloud
providers to track users so that they can provide better service.
Arguments
Name
Type
Description
Default
$agent
string
an arbitrary user-agent string; e.g. "My Cloud App"
Creates and returns the formatted credentials to POST to the auth
service.
Return value
Type
Description
string
Expiration(
)
:
string
Description
Returns the cached expiration time;
if it has expired, then it re-authenticates
Return value
Type
Description
string
Tags
Name
Description
api
ExportCredentials(
)
:
array
Description
exports saved token, expiration, tenant, and service catalog as an array This could be stored in a cache (APC or disk file) and reloaded using
ImportCredentials()
Return value
Type
Description
array
ImportCredentials(
$values,
)
:
void
Description
imports credentials from an array Takes the same values as ExportCredentials() and reuses them.
Performs a single HTTP request The request() method is one of the most frequently-used in the entire
library. It performs an HTTP request using the specified URL, method,
and with the supplied headers and body. It handles error and
exceptions for the request.
Generic Service factory method Contains code reused by the other service factory methods.
Arguments
Name
Type
Description
Default
$class
string
the name of the Service class to produce
$name
string
the name of the Compute service to attach to
null
$region
string
the name of the region to use
null
$urltype
string
the URL type (normally "publicURL")
null
Return value
Type
Description
\OpenCloud\Service
(or subclass such as Compute, ObjectStore)
Tags
Name
Description
throws
ServiceCatalog(
)
:
\stdClass
Description
Returns the service catalog object from the auth service
Return value
Type
Description
\stdClass
ServiceCatalogItem(
$info
= array(),
)
:
n/a
Description
returns a service catalog item This is a helper function used to list service catalog items easily
Arguments
Name
Type
Description
Default
$info
n/a
array()
Return value
Type
Description
n/a
n/a
ServiceList(
)
:
n/a
Description
Returns a Collection of objects with information on services Note that these are informational (read-only) and are not actually
'Service'-class objects.
Sets default values for name, region, URL type for a service Once these are set (and they can also be set by defining global
constants), then you do not need to specify these values when
creating new service objects.
Allows the user to define a function for tracking downloads This can be used to implement a progress bar or similar function. The
callback function is called with a single parameter, the length of the
data that is being downloaded on this call.
Arguments
Name
Type
Description
Default
$callback
callable
the name of a global callback function, or an
array($object, $functionname)
Allows the user to define a function for tracking uploads This can be used to implement a progress bar or similar function. The
callback function is called with a single parameter, the length of the
data that is being uploaded on this call.
Arguments
Name
Type
Description
Default
$callback
callable
the name of a global callback function, or an
array($object, $functionname)
Return value
Type
Description
void
Tenant(
)
:
string
Description
Returns the tenant ID, re-authenticating if necessary
Return value
Type
Description
string
Tags
Name
Description
api
Token(
)
:
string
Description
Returns the cached token; if it has expired, then it re-authenticates
Creates a new OpenStack object The OpenStack object needs two bits of information: the URL to
authenticate against, and a "secret", which is an associative array
of name/value pairs. Usually, the secret will be a username and a
password, but other values may be required by different authentication
systems. For example, OpenStack Keystone requires a username and
password, but Rackspace uses a username, tenant ID, and API key.
(See OpenCloud\Rackspace for that.)
Callback function to handle reads for file uploads Internal function for handling file uploads. Note that, although this
function's visibility is public, this is only because it must be called
from the HttpRequest interface. This should NOT be called by users
directly.
Callback function to handle writes for file downloads Internal function for handling file downloads. Note that, although this
function's visibility is public, this is only because it must be called
via the HttpRequest interface. This should NOT be called by users
directly.
Tracks file descriptors used by streaming downloads This will permit multiple simultaneous streaming downloads; the
key is the URL of the object, and the value is its file descriptor.
To prevent memory overflows, each array element is deleted when
the end of the file is reached.
This associative array holds default values used to identify each
service (and to select it from the Service Catalog). Use the
Compute::SetDefaults() method to change the default values, or
define the global constants (for example, RAXSDK_COMPUTE_NAME)
BEFORE loading the OpenCloud library: <code>
define('RAXSDK_COMPUTE_NAME', 'cloudServersOpenStack');
include('openstack.php');
</code>
This holds the HTTP User-Agent: used for all requests to the
services. It is public so that, if necessary, it can be entirely
overridden by the developer. However, it's strongly recomended
that you use the OpenStack::AppendUserAgent() method to APPEND
your own User Agent identifier to the end of this string; the
user agent information can be very valuable to service providers
to track who is using their service.
Metadata The Metadata class represents either Server or Image metadata
Nova Nova is an abstraction layer for the OpenStack compute service.
ObjectStore Intermediate (abstract) class to implement shared
features of all object-storage classes
PersistentObject represents an object that has the ability to be
retrieved, created, updated, and deleted.
Service This class defines a "service"—a relationship between a specific OpenStack
and a provided service, represented by a URL in the service catalog.
ServiceCatalogItem Holds information on a single service from the Service Catalog
Curl The CurlRequest class is a simple wrapper to CURL functions. Not only does
this permit stubbing of the interface as described under the HttpRequest
interface, it could potentially allow us to replace the interface methods
with other function calls in the future.
HttpRequestInterface The HttpRequest interface defines methods for wrapping CURL; this allows
those methods to be stubbed out for unit testing, thus allowing us to
test without actually making live calls.
Response
Blank The HttpResponse returns an object with status information, separated
headers, and any response body necessary.
Http The HttpResponse returns an object with status information, separated
headers, and any response body necessary.
Compute
Flavor The Flavor class represents a flavor defined by the Compute service
Image The Image class represents a stored machine image returned by the
Compute service.
Network The Network class represents a single virtual network
Server The Server class represents a single server node.
Record The Record class represents a single domain record
Service This class defines a "service"—a relationship between a specific OpenStack
and a provided service, represented by a URL in the service catalog.
Subdomain The Subdomain is basically another domain, albeit one that is a child of
a parent domain. In terms of the code involved, the JSON is slightly
different than a top-level domain, and the parent is a domain instead of
the DNS service itself.
Database
Database This class represents a Database in the Rackspace "Red Dwarf"
database-as-a-service product.
Instance Instance represents an instance of DbService, similar to a Server in a
Compute service
Service The Rackspace Database As A Service (aka "Red Dwarf")
User This class represents a User in the Rackspace "Red Dwarf"
database-as-a-service product.
LoadBalancer
Algorithm sub-resource to manage algorithms (read-only)
AllowedDomain sub-resource to manage allowed domains
BillableLoadBalancer used to get a list of billable load balancers for a specific date range
LoadBalancer The LoadBalancer class represents a single load balancer
Protocol sub-resource to manage protocols (read-only)
Node information on a single node in the load balancer
NodeEvent a single node event, usually called as part of a Collection
Readonly This defines a read-only SubResource - one that cannot be created, updated,
or deleted. Many subresources are like this, and this simplifies their
class definitions.
Stats Stats returns statistics about the load balancer
SubResource SubResource is an abstract class that handles subresources of a
LoadBalancer object; for example, the
`/loadbalancers/{id}/errorpage`. Since most of the subresources are
handled in a similar manner, this consolidates the functions.
Curl The CurlRequest class is a simple wrapper to CURL functions. Not only does
this permit stubbing of the interface as described under the HttpRequest
interface, it could potentially allow us to replace the interface methods
with other function calls in the future.
DataObject A DataObject is an object in the ObjectStore
Database This class represents a Database in the Rackspace "Red Dwarf"
database-as-a-service product.
HttpRequestInterface The HttpRequest interface defines methods for wrapping CURL; this allows
those methods to be stubbed out for unit testing, thus allowing us to
test without actually making live calls.
Rackspace Rackspace extends the OpenStack class with support for Rackspace's
API key and tenant requirements.
Readonly This defines a read-only SubResource - one that cannot be created, updated,
or deleted. Many subresources are like this, and this simplifies their
class definitions.
Service This class defines a "service"—a relationship between a specific OpenStack
and a provided service, represented by a URL in the service catalog.
Service The Compute class represents the OpenStack Nova service.
Service The Rackspace Database As A Service (aka "Red Dwarf")
Service This class defines a "service"—a relationship between a specific OpenStack
and a provided service, represented by a URL in the service catalog.
Stack The Stack class requires a CloudFormation template and may contain additional
parameters for that template.
Stats Stats returns statistics about the load balancer
SubResource SubResource is an abstract class that handles subresources of a
LoadBalancer object; for example, the
`/loadbalancers/{id}/errorpage`. Since most of the subresources are
handled in a similar manner, this consolidates the functions.
Subdomain The Subdomain is basically another domain, albeit one that is a child of
a parent domain. In terms of the code involved, the JSON is slightly
different than a top-level domain, and the parent is a domain instead of
the DNS service itself.