Documentation

Service extends NovaService
in package

The Compute class represents the OpenStack Nova service.

It is constructed from a OpenStack object and requires a service name, region, and URL type to select the proper endpoint from the service catalog. However, constants can be used to define default values for these to make it easier to use:

Creating a compute object:

$rackspace = new OpenCloud\Rackspace(...); $dallas = new Compute( $rackspace, // connection 'cloudServersOpenStack', // the service's name 'DFW', // region identifier 'publicURL' // URL type );

The easy way (with defaults); this assumes that the constants (RAXSDK_...) are defined elsewhere before the inclusion of the first SDK library file:

$rackspace = new OpenCloud\Rackspace(...); $dallas = new OpenCloud\Compute($rackspace); // uses defaults

Table of Contents

DEFAULT_NAME  = 'cloudServersOpenStack'
DEFAULT_TYPE  = 'compute'
DEFAULT_URL_TYPE  = 'publicURL'
PATCH_CONTENT_TYPE  = OpenCloudCommonConstantsMime::JSON_PATCH
SUPPORTED_VERSION  = null
$additionalExtensions  : mixed
$aliases  : array<string|int, mixed>
The aliases configure for the properties of the instance.
$client  : Client
$endpoint  : Endpoint
$namespaces  : array<string|int, mixed>
$regionless  : bool
$resources  : array<string|int, mixed>
$logger  : LoggerInterface
The logger instance
$name  : string
$properties  : array<string|int, mixed>
Holds all the properties added by overloading.
$region  : string
$type  : string
$urlType  : string
__call()  : mixed
Intercept non-existent method calls for dynamic getter/setter functionality.
__construct()  : mixed
checkJsonError()  : mixed
Checks the most recent JSON operation for errors.
collection()  : mixed
flavor()  : Flavor
Returns a flavor from the service
flavorList()  : Collection
Returns a list of Flavor objects
generateUuid()  : mixed
getBaseUrl()  : Url
Get the base URL for this service, based on the set URL type.
getClient()  : Client
getEndpoint()  : Endpoint
getExtensions()  : array<string|int, mixed>
Returns the /extensions for the service
getInstance()  : static
getLogger()  : LoggerInterface
Returns the Logger object.
getName()  : string
getNamespaces()  : array<string|int, mixed>
Returns a list of supported namespaces
getRegion()  : string
getResources()  : array<string|int, mixed>
Get all associated resources for this service.
getType()  : string
getUrl()  : Url
Returns the URL for the Service
getUrlType()  : string
hasLogger()  : bool
image()  : Image
Returns an image from the service
imageList()  : Collection
Returns a Collection of images (class Image)
keypair()  : mixed
limits()  : array<string|int, mixed>
Returns the limits for the service
listKeypairs()  : mixed
makeResourceIteratorOptions()  : mixed
name()  : mixed
namespaces()  : mixed
network()  : Network
Returns a Network object
networkList()  : PaginatedIterator
Returns a Collection of Network objects
populate()  : mixed
Populates the current object based on an unknown data type.
region()  : mixed
resource()  : object
Factory method for instantiating resource objects.
resourceList()  : PaginatedIterator
Factory method for instantiating a resource collection.
server()  : Server
Returns a Server object associated with this Compute service
serverList()  : PaginatedIterator
Returns a Collection of server objects, filtered by the specified parameters
setClient()  : mixed
setEndpoint()  : mixed
setLogger()  : $this
Sets the logger.
stripNamespace()  : mixed
toCamel()  : mixed
Convert a string to camelCase format.
toUnderscores()  : mixed
Convert string to underscore format.
url()  : mixed
getCurrentNamespace()  : type
Internal method for accessing child namespace from parent scope.
getJsonHeader()  : mixed
getPatchHeaders()  : mixed
getProperty()  : mixed
Grab value out of the data array.
loadNamespaces()  : mixed
Loads the available namespaces from the /extensions resource
propertyExists()  : bool
Basic check to see whether property exists.
resolveResourceClass()  : string
Resolves FQCN for local resource.
setProperty()  : mixed
We can set a property under three conditions:
checkAttributePrefix()  : bool
Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
findEndpoint()  : Endpoint
Extracts the appropriate endpoint from the service catalog based on the name and type of a service, and sets for further use.
getMetaUrl()  : stdClass
Constructs a specified URL from the subresource
isAccessible()  : bool
Does the property exist in the object variable list (i.e. does it have public or protected visibility?)

Constants

DEFAULT_NAME

public mixed DEFAULT_NAME = 'cloudServersOpenStack'

DEFAULT_TYPE

public mixed DEFAULT_TYPE = 'compute'

PATCH_CONTENT_TYPE

public mixed PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH

Properties

$additionalExtensions

protected mixed $additionalExtensions = array('OS-FLV-DISABLED')

$aliases

The aliases configure for the properties of the instance.

protected array<string|int, mixed> $aliases = array()

$namespaces

protected array<string|int, mixed> $namespaces = array()

Namespaces for this service.

$regionless

protected bool $regionless = false

Indicates whether a service is "regionless" or not. Defaults to FALSE because nearly all services are region-specific.

$resources

protected array<string|int, mixed> $resources = array()

A collection of resource models that this service has control over.

$name

private string $name

The name of this service, as set in Catalog.

$properties

Holds all the properties added by overloading.

private array<string|int, mixed> $properties = array()

$region

private string $region

The chosen region(s) for this service.

$type

private string $type

The type of this service, as set in Catalog.

$urlType

private string $urlType

Either 'publicURL' or 'internalURL'.

Methods

__call()

Intercept non-existent method calls for dynamic getter/setter functionality.

public __call( $method,  $args) : mixed
Parameters
$method :
$args :
Tags
throws
RuntimeException
Return values
mixed

__construct()

public __construct(Client $client[, mixed $type = null ][, mixed $name = null ][, mixed $region = null ][, mixed $urlType = null ]) : mixed
Parameters
$client : Client
$type : mixed = null
$name : mixed = null
$region : mixed = null
$urlType : mixed = null
Return values
mixed

checkJsonError()

Checks the most recent JSON operation for errors.

public static checkJsonError() : mixed
Tags
throws
JsonError
codeCoverageIgnore
Return values
mixed

collection()

public collection(mixed $class[, mixed $url = null ][, mixed $parent = null ][, mixed $data = null ]) : mixed
Parameters
$class : mixed
$url : mixed = null
$parent : mixed = null
$data : mixed = null
Tags
codeCoverageIgnore
Return values
mixed

flavor()

Returns a flavor from the service

public flavor([string|null $id = null ]) : Flavor
Parameters
$id : string|null = null
Return values
Flavor

flavorList()

Returns a list of Flavor objects

public flavorList([bool $details = true ][, array<string|int, mixed> $filter = array() ]) : Collection
Parameters
$details : bool = true

Returns full details or not.

$filter : array<string|int, mixed> = array()

Array for creating queries

Return values
Collection

generateUuid()

public static generateUuid() : mixed
Return values
mixed

getExtensions()

Returns the /extensions for the service

public getExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

of objects

getInstance()

public static getInstance() : static
Return values
static

getNamespaces()

Returns a list of supported namespaces

public getNamespaces() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRegion()

public getRegion() : string
Return values
string

getResources()

Get all associated resources for this service.

public getResources() : array<string|int, mixed>
Tags
access

public

Return values
array<string|int, mixed>

getUrl()

Returns the URL for the Service

public getUrl([string $path = null ][, array<string|int, mixed> $query = array() ]) : Url
Parameters
$path : string = null

URL path segment

$query : array<string|int, mixed> = array()

Array of query pairs

Return values
Url

getUrlType()

public getUrlType() : string
Return values
string

hasLogger()

public hasLogger() : bool
Return values
bool

image()

Returns an image from the service

public image([string $id = null ]) : Image

This is a factory method and should normally be called instead of creating an Image object directly.

Parameters
$id : string = null
  • if supplied, returns the image with the specified ID.
Return values
Image

object

imageList()

Returns a Collection of images (class Image)

public imageList([bool $details = true ][, array<string|int, mixed> $filter = array() ]) : Collection

This is a factory method and should normally be used instead of creating an ImageList object directly.

Parameters
$details : bool = true
  • if TRUE (the default), returns complete image details. Set to FALSE to improve performance, but only return a minimal set of data
$filter : array<string|int, mixed> = array()
  • key/value pairs to pass to the images resource. The actual values available here are determined by the OpenStack code and any extensions installed by your cloud provider; see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html for current filters available.
Return values
Collection

keypair()

public keypair([mixed $data = null ]) : mixed
Parameters
$data : mixed = null
Return values
mixed

limits()

Returns the limits for the service

public limits() : array<string|int, mixed>
Return values
array<string|int, mixed>

of limits

listKeypairs()

public listKeypairs() : mixed
Return values
mixed

makeResourceIteratorOptions()

public makeResourceIteratorOptions(mixed $resource) : mixed
Parameters
$resource : mixed
Return values
mixed

name()

public name() : mixed
Tags
deprecated
Return values
mixed

namespaces()

public namespaces() : mixed
Tags
deprecated
Return values
mixed

network()

Returns a Network object

public network([string $id = null ]) : Network
Parameters
$id : string = null

the network ID

Return values
Network

networkList()

Returns a Collection of Network objects

public networkList([array<string|int, mixed> $filter = array() ]) : PaginatedIterator
Parameters
$filter : array<string|int, mixed> = array()

array of filter key/value pairs

Return values
PaginatedIterator

populate()

Populates the current object based on an unknown data type.

public populate(mixed $info[, mixed $setObjects = true ]) : mixed
Parameters
$info : mixed
$setObjects : mixed = true
Tags
throws
InvalidArgumentError
Return values
mixed

region()

public region() : mixed
Tags
deprecated
Return values
mixed

resource()

Factory method for instantiating resource objects.

public resource(string $resourceName[, mixed $info = null ][, mixed $parent = null ]) : object
Parameters
$resourceName : string
$info : mixed = null

(default: null)

$parent : mixed = null

The parent object

Return values
object

resourceList()

Factory method for instantiating a resource collection.

public resourceList(string $resourceName[, string|null $url = null ][, string|null $parent = null ]) : PaginatedIterator
Parameters
$resourceName : string
$url : string|null = null
$parent : string|null = null
Return values
PaginatedIterator

server()

Returns a Server object associated with this Compute service

public server([string $id = null ]) : Server

This is a factory method and should generally be used to create server objects (thus ensuring that they are correctly associated with the server) instead of calling the Server class explicitly.

Parameters
$id : string = null
  • if specified, the server with the ID is retrieved
Return values
Server

object

serverList()

Returns a Collection of server objects, filtered by the specified parameters

public serverList([bool $details = true ][, array<string|int, mixed> $filter = array() ]) : PaginatedIterator

This is a factory method and should normally be called instead of creating a ServerList object directly.

Parameters
$details : bool = true
  • if TRUE, full server details are returned; if FALSE, just the minimal set of info is listed. Defaults to TRUE; you might set this to FALSE to improve performance at the risk of not having all the information you need.
$filter : array<string|int, mixed> = array()
  • a set of key/value pairs that is passed to the servers list for filtering
Return values
PaginatedIterator

stripNamespace()

public stripNamespace(mixed $namespace) : mixed
Parameters
$namespace : mixed
Return values
mixed

toCamel()

Convert a string to camelCase format.

public toCamel( $string[, bool $capitalise = true ]) : mixed
Parameters
$string :
$capitalise : bool = true

Optional flag which allows for word capitalization.

Return values
mixed

toUnderscores()

Convert string to underscore format.

public toUnderscores( $string) : mixed
Parameters
$string :
Return values
mixed

url()

public url([mixed $path = null ][, array<string|int, mixed> $query = array() ]) : mixed
Parameters
$path : mixed = null
$query : array<string|int, mixed> = array()
Tags
deprecated
Return values
mixed

getCurrentNamespace()

Internal method for accessing child namespace from parent scope.

protected getCurrentNamespace() : type
Return values
type

getJsonHeader()

protected static getJsonHeader() : mixed
Return values
mixed

getPatchHeaders()

protected static getPatchHeaders() : mixed
Return values
mixed

getProperty()

Grab value out of the data array.

protected getProperty(string $property) : mixed
Parameters
$property : string
Return values
mixed

loadNamespaces()

Loads the available namespaces from the /extensions resource

protected loadNamespaces() : mixed
Return values
mixed

propertyExists()

Basic check to see whether property exists.

protected propertyExists(string $property[, bool $allowRetry = true ]) : bool
Parameters
$property : string

The property name being investigated.

$allowRetry : bool = true

If set to TRUE, the check will try to format the name in underscores because there are sometimes discrepancies between camelCaseNames and underscore_names.

Return values
bool

resolveResourceClass()

Resolves FQCN for local resource.

protected resolveResourceClass( $resourceName) : string
Parameters
$resourceName :
Tags
throws
UnrecognizedServiceError
Return values
string

setProperty()

We can set a property under three conditions:

protected setProperty(mixed $property, mixed $value) : mixed
  1. If it has a concrete setter: setProperty()
  2. If the property exists
  3. If the property name's prefix is in an approved list
Parameters
$property : mixed
$value : mixed
Return values
mixed

checkAttributePrefix()

Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array

private checkAttributePrefix(string $property) : bool

This is to support extension namespaces in some services.

Parameters
$property : string

the name of the attribute

Return values
bool

findEndpoint()

Extracts the appropriate endpoint from the service catalog based on the name and type of a service, and sets for further use.

private findEndpoint() : Endpoint
Tags
throws
EndpointError
Return values
Endpoint

getMetaUrl()

Constructs a specified URL from the subresource

private getMetaUrl(string $resource) : stdClass

Given a subresource (e.g., "extensions"), this constructs the proper URL and retrieves the resource.

Parameters
$resource : string

The resource requested; should NOT have slashes at the beginning or end

Return values
stdClass

object

isAccessible()

Does the property exist in the object variable list (i.e. does it have public or protected visibility?)

private isAccessible( $property) : bool
Parameters
$property :
Return values
bool

Search results