class Server extends OperatorResource implements Creatable, Updateable, Deletable, Retrievable, Listable

Traits

Contains reusable functionality for resources that have long operations which require waiting in order to reach a particular state.

Properties

$id string
$ipv4 string
$ipv6 string
$addresses array
$created DateTimeImmutable
$updated DateTimeImmutable
$flavor Flavor
$hostId string
$hypervisorHostname string
$image Image
$links
$metadata array
$name string
$progress string
$status string
$tenantId string
$userId string
$adminPass string
$taskState string
$powerState string
$vmState string
$fault Fault

Methods

create (array $userOptions) : Creatable

Create a new resource according to the configuration set in the options.

update () : void

Update the current resource with the configuration set out in the user options.

delete () : void

Permanently delete this resource.

retrieve () : void

Retrieve details of the current resource from the remote API.

changePassword (string $newPassword)

Changes the root password for a server.

reboot (string $type = Enum::REBOOT_SOFT)

Reboots the server.

start ()

Starts server

stop ()

Stops server

rebuild (array $options)

Rebuilds the server.

rescue (array $options) : string

Rescues the server.

Unrescues the server.

resize (string $flavorId)

Resizes the server to a new flavor. Once this operation is complete and server has transitioned to an active state, you will either need to call {see confirmResize()} or {see revertResize()}.

Confirms a previous resize operation.

Reverts a previous resize operation.

getVncConsole (string $type = Enum::CONSOLE_NOVNC) : array

Gets a VNC console for a server.

getRDPConsole (string $type = Enum::CONSOLE_RDP_HTML5) : array

Gets a RDP console for a server.

getSpiceConsole (string $type = Enum::CONSOLE_SPICE_HTML5) : array

Gets a Spice console for a server.

getSerialConsole (string $type = Enum::CONSOLE_SERIAL) : array

Gets a serial console for a server.

createImage (array $options)

Creates an image for the current server.

listAddresses (array $options = array()) : array

Iterates over all the IP addresses for this server.

listInterfaceAttachments (array $options = array()) : Generator

Returns Generator for InterfaceAttachment

Gets an interface attachment.

Creates an interface attachment.

detachInterface (string $portId)

Detaches an interface attachment.

getMetadata () : array

Retrieves metadata from the API.

resetMetadata (array $metadata)

Resets all the metadata for this server with the values provided. All existing metadata keys will either be replaced or removed.

mergeMetadata (array $metadata) : array

Merges the existing metadata for the server with the values provided. Any existing keys referenced in the user options will be replaced with the user's new values. All other existing keys will remain unaffected.

getMetadataItem (string $key) : mixed

Retrieve the value for a specific metadata key.

deleteMetadataItem (string $key)

Remove a specific metadata key.

addSecurityGroup (array $options) : SecurityGroup

Add security group to a server (addSecurityGroup action)

removeSecurityGroup (array $options)

Add security group to a server (addSecurityGroup action)

parseMetadata (ResponseInterface $response)

No description

Returns Generator for SecurityGroups

Returns Generator for VolumeAttachment

attachVolume (string $volumeId) : VolumeAttachment

Attach a volume and returns volume that was attached

detachVolume (string $attachmentId) : void

Detach a volume

Details

create(array $userOptions)

Create a new resource according to the configuration set in the options.

Parameters

$userOptions array {see \OpenStack\Compute\v2\Api::postServer}

Return value

Creatable

Example code

$creatable = $server->create($userOptions);

update()

Update the current resource with the configuration set out in the user options.

Return value

void

Example code

$server->update();

delete()

Permanently delete this resource.

Return value

void

Example code

$server->delete();

retrieve()

Retrieve details of the current resource from the remote API.

Return value

void

Example code

$server->retrieve();

changePassword(string $newPassword)

Changes the root password for a server.

Parameters

$newPassword string The new root password

Example code

$server->changePassword($newPassword);

reboot(string $type = Enum::REBOOT_SOFT)

Reboots the server.

Parameters

$type string The type of reboot that will be performed. Either SOFT or HARD is supported.

Example code

$server->reboot($type);

start()

Starts server

Example code

$server->start();

stop()

Stops server

Example code

$server->stop();

rebuild(array $options)

Rebuilds the server.

Parameters

$options array {see \OpenStack\Compute\v2\Api::rebuildServer}

Example code

$server->rebuild($options);

rescue(array $options)

Rescues the server.

Parameters

$options array {see \OpenStack\Compute\v2\Api::rescueServer}

Return value

string

Example code

$string = $server->rescue($options);

unrescue()

Unrescues the server.

Example code

$server->unrescue();

resize(string $flavorId)

Resizes the server to a new flavor. Once this operation is complete and server has transitioned to an active state, you will either need to call {see confirmResize()} or {see revertResize()}.

Parameters

$flavorId string The UUID of the new flavor your server will be based on.

Example code

$server->resize($flavorId);

confirmResize()

Confirms a previous resize operation.

Example code

$server->confirmResize();

revertResize()

Reverts a previous resize operation.

Example code

$server->revertResize();

getVncConsole(string $type = Enum::CONSOLE_NOVNC)

Gets a VNC console for a server.

Parameters

$type string The type of VNC console: novnc|xvpvnc. Defaults to novnc.

Return value

array

Example code

$array = $server->getVncConsole($type);

getRDPConsole(string $type = Enum::CONSOLE_RDP_HTML5)

Gets a RDP console for a server.

Parameters

$type string The type of VNC console: rdp-html5 (default).

Return value

array

Example code

$array = $server->getRDPConsole($type);

getSpiceConsole(string $type = Enum::CONSOLE_SPICE_HTML5)

Gets a Spice console for a server.

Parameters

$type string The type of VNC console: spice-html5.

Return value

array

Example code

$array = $server->getSpiceConsole($type);

getSerialConsole(string $type = Enum::CONSOLE_SERIAL)

Gets a serial console for a server.

Parameters

$type string The type of VNC console: serial.

Return value

array

Example code

$array = $server->getSerialConsole($type);

createImage(array $options)

Creates an image for the current server.

Parameters

$options array {see \OpenStack\Compute\v2\Api::createServerImage}

Example code

$server->createImage($options);

listAddresses(array $options = array())

Iterates over all the IP addresses for this server.

Parameters

$options array {see \OpenStack\Compute\v2\Api::getAddressesByNetwork}

Return value

array An array containing to two keys: "public" and "private"

Example code

$array = $server->listAddresses($options);

listInterfaceAttachments(array $options = array())

Returns Generator for InterfaceAttachment

Parameters

$options array

Return value

Generator

Example code

$generator = $server->listInterfaceAttachments($options);

getInterfaceAttachment(string $portId)

Gets an interface attachment.

Parameters

$portId string The unique ID of the port.

Return value

InterfaceAttachment

Example code

$interfaceAttachment = $server->getInterfaceAttachment($portId);

createInterfaceAttachment(array $userOptions)

Creates an interface attachment.

Parameters

$userOptions array {see \OpenStack\Compute\v2\Api::postInterfaceAttachment}

Return value

InterfaceAttachment

Example code

$interfaceAttachment = $server->createInterfaceAttachment($userOptions);

detachInterface(string $portId)

Detaches an interface attachment.

Parameters

$portId string

Example code

$server->detachInterface($portId);

getMetadata()

Retrieves metadata from the API.

Return value

array

Example code

$array = $server->getMetadata();

resetMetadata(array $metadata)

Resets all the metadata for this server with the values provided. All existing metadata keys will either be replaced or removed.

Parameters

$metadata array {see \OpenStack\Compute\v2\Api::putServerMetadata}

Example code

$server->resetMetadata($metadata);

mergeMetadata(array $metadata)

Merges the existing metadata for the server with the values provided. Any existing keys referenced in the user options will be replaced with the user's new values. All other existing keys will remain unaffected.

Parameters

$metadata array {see \OpenStack\Compute\v2\Api::postServerMetadata}

Return value

array

Example code

$array = $server->mergeMetadata($metadata);

getMetadataItem(string $key)

Retrieve the value for a specific metadata key.

Parameters

$key string {see \OpenStack\Compute\v2\Api::getServerMetadataKey}

Return value

mixed

Example code

$mixed = $server->getMetadataItem($key);

deleteMetadataItem(string $key)

Remove a specific metadata key.

Parameters

$key string {see \OpenStack\Compute\v2\Api::deleteServerMetadataKey}

Example code

$server->deleteMetadataItem($key);

addSecurityGroup(array $options)

Add security group to a server (addSecurityGroup action)

Parameters

$options array {see \OpenStack\Compute\v2\Api::postSecurityGroup}

Return value

SecurityGroup

Example code

$securityGroup = $server->addSecurityGroup($options);

removeSecurityGroup(array $options)

Add security group to a server (addSecurityGroup action)

Parameters

$options array {see \OpenStack\Compute\v2\Api::deleteSecurityGroup}

Example code

$server->removeSecurityGroup($options);

parseMetadata(ResponseInterface $response)

Parameters

$response ResponseInterface

Example code

$server->parseMetadata($response);

listSecurityGroups()

Returns Generator for SecurityGroups

Return value

Generator

Example code

$generator = $server->listSecurityGroups();

listVolumeAttachments()

Returns Generator for VolumeAttachment

Return value

Generator

Example code

$generator = $server->listVolumeAttachments();

attachVolume(string $volumeId)

Attach a volume and returns volume that was attached

Parameters

$volumeId string

Return value

VolumeAttachment

Example code

$volumeAttachment = $server->attachVolume($volumeId);

detachVolume(string $attachmentId)

Detach a volume

Parameters

$attachmentId string

Return value

void

Example code

$server->detachVolume($attachmentId);