Documentation

PublicServer extends Server
in package

A virtual machine (VM) instance in the Cloud Servers environment.

Table of Contents

PATCH_CONTENT_TYPE  = OpenCloudCommonConstantsMime::JSON_PATCH
$accessIPv4  : string
$accessIPv6  : string
$addresses  : type
$adminPass  : string
$availabilityZone  : string
$created  : string
$extendedStatus  : string
$flavor  : type
The Flavor for this server.
$hostId  : string
The compute provisioning algorithm has an anti-affinity property that attempts to spread customer VMs across hosts. Under certain situations, VMs from the same customer might be placed on the same host. $hostId represents the host your server runs on and can be used to determine this scenario if it is relevant to your application.
$id  : string
$image  : ImageInterface
The Image for this server.
$keypair  : string|object
$links  : array<string|int, mixed>
$name  : string
$networks  : type
$powerStatus  : int
$progress  : int
The build completion progress, as a percentage. Value is from 0 to 100.
$security_groups  : array<string|int, string|\OpenCloud\Networking\Resource\SecurityGroup>
Security groups for this server. An array of either the names or SecurityGroup objects.
$status  : string
The server status. {@see \OpenCloud\Compute\Constants\ServerState} for supported types.
$taskStatus  : string
$tenant_id  : string
$updated  : string
$user_data  : string
Cloud-init boot executable code
$user_id  : string
$volume  : Volume
The bootable volume for this server.
$volumeDeleteOnTermination  : bool
Whether to delete the bootable volume when the server is terminated (deleted).
$aliases  : array<string|int, mixed>
The aliases configure for the properties of the instance.
$json_name  : mixed
$metadata  : Metadata
$parent  : BaseResource
$service  : ServiceInterface
$url_resource  : mixed
$flavorRef  : type
$imageRef  : type
$logger  : LoggerInterface
The logger instance
$personality  : array<string|int, mixed>
$properties  : array<string|int, mixed>
Holds all the properties added by overloading.
__call()  : mixed
Intercept non-existent method calls for dynamic getter/setter functionality.
__construct()  : mixed
addFile()  : void
Adds a "personality" file to be uploaded during create() or rebuild()
attachVolume()  : mixed
Attaches a volume to a server
checkExtension()  : bool
Check whether an extension is valid
checkJsonError()  : mixed
Checks the most recent JSON operation for errors.
console()  : mixed
Returns a console connection Note: Where is this documented?
create()  : Response
Create a new resource
createImage()  : bool|Image
Creates a new image from a server
CreateJson()  : mixed
createUrl()  : Url
delete()  : Response
Delete this resource
detachVolume()  : mixed
Removes a volume attachment from a server
diagnostics()  : object
Get server diagnostics
findLink()  : bool
Find a resource link based on a type
generateUuid()  : mixed
getClient()  : ClientInterface
Convenience method to return the service's client
getInstance()  : static
getLogger()  : LoggerInterface
Returns the Logger object.
getMetadata()  : Metadata
getParent()  : mixed
getService()  : ServiceInterface
getUrl()  : mixed
Get this resource's URL
hasLogger()  : bool
id()  : mixed
imageSchedule()  : mixed
Schedule daily image backups
ip()  : string
Returns the primary external IP address of the server
ips()  : object
Returns the IP address block for the Server or for a specific network.
jsonCollectionElement()  : string
Returns the nested keys that could (rarely) prefix collection items. For example:
jsonCollectionName()  : string
Returns the top-level key for collection responses
jsonName()  : mixed
Returns the top-level key for the returned response JSON document
makeResourceIteratorOptions()  : mixed
metadata()  : ServerMetadata
Retrieves the metadata associated with a Server.
name()  : string
parseResponse()  : mixed
Parse a HTTP response for the required content
populate()  : mixed
Populates the current object based on an unknown data type.
reboot()  : Response
Reboots a server
rebuild()  : mixed
Rebuilds an existing server
refresh()  : Response
Refresh the state of a resource
refreshFromLocationUrl()  : mixed
Given a `location` URL, refresh this resource
region()  : mixed
rescue()  : string
Puts the server into *rescue* mode
resize()  : bool
Initiates the resize of a server
resizeConfirm()  : bool
confirms the resize of a server
resizeRevert()  : bool
reverts the resize of a server
resourceName()  : mixed
Returns the URI path for this resource
resume()  : Response
Resume a server
setLogger()  : $this
Sets the logger.
setMetadata()  : $this
setParent()  : self
setPassword()  : bool
Sets the root password on the server
setService()  : PersistentObject
start()  : Response
Start a server
status()  : string
stop()  : Response
Stop a server
stripNamespace()  : mixed
suspend()  : Response
Suspend a server
toCamel()  : mixed
Convert a string to camelCase format.
toUnderscores()  : mixed
Convert string to underscore format.
unrescue()  : HttpResponse
Takes the server out of RESCUE mode
update()  : Response
Update a resource
url()  : mixed
volumeAttachment()  : mixed
Returns a VolumeAttachment object
volumeAttachmentList()  : Collection
Returns a Collection of VolumeAttachment objects
waitFor()  : mixed
A method to repeatedly poll the API resource, waiting for an eventual state change
action()  : Response
This method is used for many purposes, such as rebooting server, etc.
createJson()  : object
Provides JSON for create request body
generateJsonPatch()  : string
Generates a JSON Patch representation and return its
getAlias()  : string
Returns the alias configured for the given key. If no alias exists it returns the original key.
getJsonHeader()  : mixed
getPatchHeaders()  : mixed
getProperty()  : mixed
Grab value out of the data array.
getUpdateablePropertiesAsArray()  : mixed
Returns the object's properties as an array
noCreate()  : mixed
noDelete()  : mixed
noUpdate()  : mixed
primaryKeyField()  : string
Returns the primary key field for the object
propertyExists()  : bool
Basic check to see whether property exists.
recursivelyAliasPropertyValue()  : mixed
Returns the given property value's alias, if configured; Else, the unchanged property value is returned. If the given property value is an array or an instance of \stdClass, it is aliases recursively.
refreshFromParent()  : mixed
Causes resource to refresh based on parent's URL
setProperty()  : mixed
We can set a property under three conditions:
updateJson()  : mixed
Provides JSON for update request body
checkAttributePrefix()  : bool
Checks the attribute $property and only permits it if the prefix is in the specified $prefixes array
isAccessible()  : bool
Does the property exist in the object variable list (i.e. does it have public or protected visibility?)

Constants

PATCH_CONTENT_TYPE

public mixed PATCH_CONTENT_TYPE = OpenCloudCommonConstantsMime::JSON_PATCH

Properties

$accessIPv4

public string $accessIPv4

The public IP version 4 access address.

$accessIPv6

public string $accessIPv6

The public IP version 6 access address.

$addresses

public type $addresses

Public and private IP addresses for this server.

$adminPass

public string $adminPass

The root password (only populated on server creation).

$created

public string $created

The time stamp for the creation date.

$hostId

The compute provisioning algorithm has an anti-affinity property that attempts to spread customer VMs across hosts. Under certain situations, VMs from the same customer might be placed on the same host. $hostId represents the host your server runs on and can be used to determine this scenario if it is relevant to your application.

public string $hostId

$id

public string $id

The server ID.

$keypair

public string|object $keypair

Keypair or string representation of keypair name

public array<string|int, mixed> $links

Server links.

$name

public string $name

The server name.

$networks

public type $networks = array()

$progress

The build completion progress, as a percentage. Value is from 0 to 100.

public int $progress

$security_groups

Security groups for this server. An array of either the names or SecurityGroup objects.

public array<string|int, string|\OpenCloud\Networking\Resource\SecurityGroup> $security_groups = array()

$status

The server status. {@see \OpenCloud\Compute\Constants\ServerState} for supported types.

public string $status

$tenant_id

public string $tenant_id

The tenant ID.

$updated

public string $updated

The time stamp for the last update.

$user_data

Cloud-init boot executable code

public string $user_data

$user_id

public string $user_id

The user ID.

$volume

The bootable volume for this server.

public Volume $volume

$volumeDeleteOnTermination

Whether to delete the bootable volume when the server is terminated (deleted).

public bool $volumeDeleteOnTermination

$aliases

The aliases configure for the properties of the instance.

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

$json_name

protected static mixed $json_name = 'server'

$url_resource

protected static mixed $url_resource = 'servers'

$flavorRef

private type $flavorRef

Flavor reference (for create)

$imageRef

private type $imageRef

Image reference (for create)

$personality

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

Uploaded file attachments

$properties

Holds all the properties added by overloading.

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

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

addFile()

Adds a "personality" file to be uploaded during create() or rebuild()

public addFile(string $path, string $data) : void
Parameters
$path : string

The path where the file will be stored on the target server (up to 255 characters)

$data : string

the file contents (max size set by provider)

Return values
void

attachVolume()

Attaches a volume to a server

public attachVolume(Volume $volume[, string $device = 'auto' ]) : mixed

Requires the os-volumes extension. This is a synonym for VolumeAttachment::create()

Parameters
$volume : Volume

The volume to attach. If "auto" is specified (the default), then the first available device is used to mount the volume (for example, if the primary disk is on /dev/xvhda, then the new volume would be attached to /dev/xvhdb).

$device : string = 'auto'

the device to which to attach it

Return values
mixed

checkJsonError()

Checks the most recent JSON operation for errors.

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

console()

Returns a console connection Note: Where is this documented?

public console([mixed $type = 'novnc' ]) : mixed
Parameters
$type : mixed = 'novnc'
Tags
codeCoverageIgnore
Return values
mixed

create()

Create a new resource

public create([array<string|int, mixed> $params = array() ]) : Response
Parameters
$params : array<string|int, mixed> = array()
Return values
Response

createImage()

Creates a new image from a server

public createImage(string $name[, array<string|int, mixed> $metadata = array() ]) : bool|Image
Parameters
$name : string

The name of the new image

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

Optional metadata to be stored on the image

Tags
throws
ImageError
Return values
bool|Image

New Image instance on success; FALSE on failure

CreateJson()

public CreateJson([mixed $x = 'server' ]) : mixed
Parameters
$x : mixed = 'server'
Return values
mixed

detachVolume()

Removes a volume attachment from a server

public detachVolume(Volume $volume) : mixed

Requires the os-volumes extension. This is a synonym for VolumeAttachment::delete()

Parameters
$volume : Volume

The volume to remove

Return values
mixed

diagnostics()

Get server diagnostics

public diagnostics() : object

Gets basic usage data for a specified server.

Return values
object

Find a resource link based on a type

public findLink([string $type = 'self' ]) : bool
Parameters
$type : string = 'self'
Return values
bool

generateUuid()

public static generateUuid() : mixed
Return values
mixed

getInstance()

public static getInstance() : static
Return values
static

getParent()

public getParent() : mixed
Return values
mixed

getUrl()

Get this resource's URL

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

URI path to add on

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

Query to add on

Return values
mixed

hasLogger()

public hasLogger() : bool
Return values
bool

imageSchedule()

Schedule daily image backups

public imageSchedule([mixed $retention = false ]) : mixed
Parameters
$retention : mixed = false
  • false (default) indicates you want to retrieve the image schedule. $retention <= 0 indicates you want to delete the current schedule. $retention > 0 indicates you want to schedule image backups and you would like to retain $retention backups.
Tags
throws
ServerImageScheduleError

if an error is encountered

Return values
mixed

an object or FALSE on error

ip()

Returns the primary external IP address of the server

public ip([int $type = null ]) : string

This function is based upon the accessIPv4 and accessIPv6 values. By default, these are set to the public IP address of the server. However, these values can be modified by the user; this might happen, for example, if the server is behind a firewall and needs to be routed through a NAT device to be reached.

Parameters
$type : int = null

the type of IP version (4 or 6) to return

Return values
string

IP address

ips()

Returns the IP address block for the Server or for a specific network.

public ips([string $network = null ]) : object
Parameters
$network : string = null
  • if supplied, then only the IP(s) for the specified network are returned. Otherwise, all IPs are returned.
Tags
throws
ServerIpsError
Return values
object

jsonCollectionElement()

Returns the nested keys that could (rarely) prefix collection items. For example:

public static jsonCollectionElement() : string

{ "keypairs": [ { "keypair": { "fingerprint": "...", "name": "key1", "public_key": "..." } }, { "keypair": { "fingerprint": "...", "name": "key2", "public_key": "..." } } ] }

In the above example, "keypairs" would be the $json_collection_name and "keypair" would be the $json_collection_element

Return values
string

jsonCollectionName()

Returns the top-level key for collection responses

public static jsonCollectionName() : string
Return values
string

jsonName()

Returns the top-level key for the returned response JSON document

public static jsonName() : mixed
Tags
throws
DocumentError
Return values
mixed

makeResourceIteratorOptions()

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

metadata()

Retrieves the metadata associated with a Server.

public metadata([string $key = null ]) : ServerMetadata

If a metadata item name is supplied, then only the single item is returned. Otherwise, the default is to return all metadata associated with a server.

Parameters
$key : string = null
  • the (optional) name of the metadata item to return
Tags
throws
MetadataError
Return values
ServerMetadata

object

parseResponse()

Parse a HTTP response for the required content

public parseResponse(Response $response) : mixed
Parameters
$response : Response
Return values
mixed

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

reboot()

Reboots a server

public reboot([string $type = null ]) : Response

A "soft" reboot requests that the operating system reboot itself; a "hard" reboot is the equivalent of pulling the power plug and then turning it back on, with a possibility of data loss.

Parameters
$type : string = null

A particular reboot State. See Constants\ServerState for string values.

Return values
Response

rebuild()

Rebuilds an existing server

public rebuild([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()
  • an associative array of key/value pairs of attributes to set on the new server
Return values
mixed

refreshFromLocationUrl()

Given a `location` URL, refresh this resource

public refreshFromLocationUrl( $url) : mixed
Parameters
$url :
Return values
mixed

resize()

Initiates the resize of a server

public resize(Flavor $flavorRef) : bool
Parameters
$flavorRef : Flavor

a Flavor object indicating the new server size

Return values
bool

TRUE on success; FALSE on failure

resizeConfirm()

confirms the resize of a server

public resizeConfirm() : bool
Return values
bool

TRUE on success; FALSE on failure

resizeRevert()

reverts the resize of a server

public resizeRevert() : bool
Return values
bool

TRUE on success; FALSE on failure

resourceName()

Returns the URI path for this resource

public static resourceName() : mixed
Tags
throws
UrlError
Return values
mixed

resume()

Resume a server

public resume() : Response

A resume request resumes a suspended instance, its VM state was stored on disk, all memory was written to disk, and the virtual machine was stopped. Resuming a suspended instance is similar to resuming a device from hibernation.

Return values
Response

setMetadata()

public setMetadata(mixed $data) : $this
Parameters
$data : mixed
Return values
$this

setPassword()

Sets the root password on the server

public setPassword(string $newPassword) : bool
Parameters
$newPassword : string

The new root password for the server

Return values
bool

TRUE on success; FALSE on failure

start()

Start a server

public start() : Response

Starts a stopped server and changes its status to ACTIVE.

Return values
Response

stop()

Stop a server

public stop() : Response

Stops a running server and changes its status to STOPPED.

Return values
Response

stripNamespace()

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

suspend()

Suspend a server

public suspend() : Response

A suspend request suspend an instance, its VM state is stored on disk, all memory is written to disk, and the virtual machine is stopped. Suspending an instance is similar to placing a device in hibernation; memory and vCPUs become available to create other instances.

Return values
Response

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

update()

Update a resource

public update([array<string|int, mixed> $params = array() ]) : Response
Parameters
$params : array<string|int, mixed> = array()
Return values
Response

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

volumeAttachment()

Returns a VolumeAttachment object

public volumeAttachment([mixed $id = null ]) : mixed
Parameters
$id : mixed = null
Return values
mixed

volumeAttachmentList()

Returns a Collection of VolumeAttachment objects

public volumeAttachmentList() : Collection
Return values
Collection

waitFor()

A method to repeatedly poll the API resource, waiting for an eventual state change

public waitFor([null $state = null ][, null $timeout = null ][, null $callback = null ][, null $interval = null ]) : mixed
Parameters
$state : null = null

The expected state of the resource

$timeout : null = null

The maximum timeout to wait

$callback : null = null

The callback to use to check the state

$interval : null = null

How long between each refresh request

Return values
mixed

action()

This method is used for many purposes, such as rebooting server, etc.

protected action( $object) : Response
Parameters
$object :
Tags
throws
RuntimeException
throws
InvalidArgumentException
Return values
Response

createJson()

Provides JSON for create request body

protected createJson() : object
Tags
throws
RuntimeException
Return values
object

generateJsonPatch()

Generates a JSON Patch representation and return its

protected generateJsonPatch(mixed $updatedProperties) : string
Parameters
$updatedProperties : mixed

Properties of the resource to update

Return values
string

JSON Patch representation for updates

getAlias()

Returns the alias configured for the given key. If no alias exists it returns the original key.

protected getAlias(string $key) : string
Parameters
$key : string
Return values
string

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

getUpdateablePropertiesAsArray()

Returns the object's properties as an array

protected getUpdateablePropertiesAsArray() : mixed
Return values
mixed

primaryKeyField()

Returns the primary key field for the object

protected primaryKeyField() : string
Return values
string

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

recursivelyAliasPropertyValue()

Returns the given property value's alias, if configured; Else, the unchanged property value is returned. If the given property value is an array or an instance of \stdClass, it is aliases recursively.

protected recursivelyAliasPropertyValue(mixed $propertyValue) : mixed
Parameters
$propertyValue : mixed

Array or \stdClass instance to alias

Return values
mixed

Property value, aliased recursively

refreshFromParent()

Causes resource to refresh based on parent's URL

protected refreshFromParent() : mixed
Return values
mixed

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

updateJson()

Provides JSON for update request body

protected updateJson([mixed $params = array() ]) : mixed
Parameters
$params : mixed = array()
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

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