Server
extends NovaResource
in package
implements
HasPtrRecordsInterface
A virtual machine (VM) instance in the Cloud Servers environment.
Tags
Interfaces, Classes and Traits
- HasPtrRecordsInterface
- An interface for resources that can hold PTR records (for reverse DNS).
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>
- $metadata : 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 : mixed
- {@inheritDoc}
- $json_name : mixed
- $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
- Creates a new Server object and associates it with a Compute service
- 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() : mixed
- {@inheritDoc}
- createImage() : bool|Image
- Creates a new image from a server
- 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() : mixed
- 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
- 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).
$availabilityZone
public
string
$availabilityZone
Availability zone of the VM
Tags
$created
public
string
$created
The time stamp for the creation date.
$extendedStatus
public
string
$extendedStatus
Virtual machine status.
Tags
$flavor
The Flavor for this server.
public
type
$flavor
Tags
$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.
$image
The Image for this server.
public
ImageInterface
$image
Tags
$keypair
public
string|object
$keypair
Keypair or string representation of keypair name
$links
public
array<string|int, mixed>
$links
Server links.
$metadata
public
mixed
$metadata
Metadata key and value pairs.
$name
public
string
$name
The server name.
$networks
public
type
$networks
= array()
$powerStatus
public
int
$powerStatus
Power status of the VM
Tags
$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
$taskStatus
public
string
$taskStatus
Status indicating a running task
Tags
$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
{@inheritDoc}
protected
mixed
$aliases
= array('OS-EXT-STS:vm_state' => 'extendedStatus', 'OS-EXT-STS:task_state' => 'taskStatus', 'OS-EXT-STS:power_state' => 'powerStatus', 'OS-EXT-AZ:availability_zone' => 'availabilityZone')
$json_name
protected
static mixed
$json_name
= 'server'
$parent
protected
BaseResource
$parent
$service
protected
ServiceInterface
$service
$url_resource
protected
static mixed
$url_resource
= 'servers'
$flavorRef
private
type
$flavorRef
Flavor reference (for create)
$imageRef
private
type
$imageRef
Image reference (for create)
$logger
The logger instance
private
LoggerInterface
$logger
$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
Tags
Return values
mixed —__construct()
Creates a new Server object and associates it with a Compute service
public
__construct(Service $service[, mixed $info = null ]) : mixed
Parameters
- $service : Service
- $info : mixed = null
-
- If NULL, an empty Server object is created
- If an object, then a Server object is created from the data in the object
- If a string, then it's treated as a Server ID and retrieved from the service The normal use case for SDK clients is to treat it as either NULL or an ID. The object value parameter is a special case used to construct a Server object from a ServerList element to avoid a secondary call to the Service.
Tags
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 —checkExtension()
Check whether an extension is valid
public
checkExtension(mixed $alias) : bool
Parameters
- $alias : mixed
-
The extension name
Tags
Return values
bool —checkJsonError()
Checks the most recent JSON operation for errors.
public
static checkJsonError() : mixed
Tags
Return values
mixed —console()
Returns a console connection Note: Where is this documented?
public
console([mixed $type = 'novnc' ]) : mixed
Parameters
- $type : mixed = 'novnc'
Tags
Return values
mixed —create()
{@inheritDoc}
public
create([mixed $params = array() ]) : mixed
Parameters
- $params : mixed = array()
Return values
mixed —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
Return values
bool|Image —New Image instance on success; FALSE on failure
createUrl()
public
createUrl() : Url
Tags
Return values
Url —delete()
Delete this resource
public
delete() : Response
Return values
Response —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 —findLink()
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 —getClient()
Convenience method to return the service's client
public
getClient() : ClientInterface
Return values
ClientInterface —getInstance()
public
static getInstance() : static
Return values
static —getLogger()
Returns the Logger object.
public
getLogger() : LoggerInterface
Return values
LoggerInterface —getMetadata()
public
getMetadata() : Metadata
Return values
Metadata —getParent()
public
getParent() : mixed
Return values
mixed —getService()
public
getService() : ServiceInterface
Tags
Return values
ServiceInterface —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 —id()
public
id() : mixed
Tags
Return values
mixed —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
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
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
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
Return values
ServerMetadata —object
name()
public
name() : string
Tags
Return values
string —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
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 —refresh()
Refresh the state of a resource
public
refresh([null $id = null ][, null $url = null ]) : Response
Parameters
- $id : null = null
- $url : null = null
Tags
Return values
Response —refreshFromLocationUrl()
Given a `location` URL, refresh this resource
public
refreshFromLocationUrl( $url) : mixed
Parameters
Return values
mixed —region()
public
region() : mixed
Tags
Return values
mixed —rescue()
Puts the server into *rescue* mode
public
rescue() : string
Tags
Return values
string —the root password of the rescue server
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
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 —setLogger()
Sets the logger.
public
setLogger([LoggerInterface $logger = null ]) : $this
Parameters
- $logger : LoggerInterface = null
Return values
$this —setMetadata()
public
setMetadata(mixed $data) : $this
Parameters
- $data : mixed
Return values
$this —setParent()
public
setParent(BaseResource $parent) : self
Parameters
- $parent : BaseResource
Return values
self —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
setService()
public
setService(ServiceInterface $service) : PersistentObject
Parameters
- $service : ServiceInterface
Return values
PersistentObject —start()
Start a server
public
start() : Response
Starts a stopped server and changes its status to ACTIVE.
Return values
Response —status()
public
status() : string
Tags
Return values
string —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
Return values
mixed —toUnderscores()
Convert string to underscore format.
public
toUnderscores( $string) : mixed
Parameters
Return values
mixed —unrescue()
Takes the server out of RESCUE mode
public
unrescue() : HttpResponse
Tags
Return values
HttpResponse —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
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
Tags
Return values
Response —createJson()
protected
createJson() : mixed
Return values
mixed —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 —noCreate()
protected
noCreate() : mixed
Tags
Return values
mixed —noDelete()
protected
noDelete() : mixed
Tags
Return values
mixed —noUpdate()
protected
noUpdate() : mixed
Tags
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
- If it has a concrete setter: setProperty()
- If the property exists
- If the property name's prefix is in an approved list
Parameters
- $property : mixed
- $value : mixed
Return values
mixed —updateJson()
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