Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • Flavor
  • Image
  • Network
  • Server
  • ServerMetadata
  • Service
  • VolumeAttachment
  • Overview
  • Namespace
  • Class
  • Tree
  • Download

Class Server

The Server class represents a single server node.

A Server is always associated with a (Compute) Service. This implementation supports extension attributes OS-DCF:diskConfig, RAX-SERVER:bandwidth, rax-bandwidth:bandwith

OpenCloud\Common\Base
Extended by OpenCloud\Common\PersistentObject
Extended by OpenCloud\Compute\Server
Namespace: OpenCloud\Compute
Located at OpenCloud/Compute/Server.php
Methods summary
public
# __construct( OpenCloud\Compute\Service $service, mixed $info = null )

Creates a new Server object and associates it with a Compute service

Creates a new Server object and associates it with a Compute service

Parameters

$service
mixed
$info * 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.
$info
mixed
$info The ID or array/object of data

Throws

ServerNotFound
if a 404 is returned
UnknownError
if another error status is reported

Overrides

OpenCloud\Common\PersistentObject::__construct()
public string
# ip( integer $ip_type = RAXSDK_DEFAULT_IP_VERSION )

Returns the primary external IP address of the server

Returns the primary external IP address of the server

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

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

Returns

string
IP address

Api

public HttpResponse
# create( array $params = array() )

Creates a new object

Creates a new object

Parameters

$params
array
$params array of values to set when creating the object

Returns

HttpResponse

Throws

VolumeCreateError
if HTTP status is not Success

Overrides

OpenCloud\Common\PersistentObject::create()
public string
# createUrl( )

returns the URL used for Create

returns the URL used for Create

Returns

string

Overrides

OpenCloud\Common\PersistentObject::createUrl()
public
# rebuild( array $params = array() )

Rebuilds an existing server

Rebuilds an existing server

Parameters

$params
array
$params - an associative array of key/value pairs of attributes to set on the new server

Api

public boolean
# reboot( string $type = RAXSDK_SOFT_REBOOT )

Reboots a server

Reboots a server

You can pass the parameter RAXSDK_SOFT_REBOOT (default) or RAXSDK_HARD_REBOOT to specify the type of reboot. 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
$type - either 'soft' (the default) or 'hard' to indicate the type of reboot

Returns

boolean
TRUE on success; FALSE on failure

Api

public boolean
# createImage( string $name, array $metadata = array() )

Creates a new image from a server

Creates a new image from a server

Parameters

$name
string
$name The name of the new image
$metadata
array
$metadata Optional metadata to be stored on the image

Returns

boolean
TRUE on success; FALSE on failure

Api

public mixed
# imageSchedule( mixed $retention = false )

Schedule daily image backups

Schedule daily image backups

Parameters

$retention
mixed
$retention - 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.

Returns

mixed
an object or FALSE on error

Throws

ServerImageScheduleError
if an error is encountered

Api

public boolean
# resize( OpenCloud\Compute\Flavor $flavorRef )

Initiates the resize of a server

Initiates the resize of a server

Parameters

$flavorRef
OpenCloud\Compute\Flavor
$flavorRef a Flavor object indicating the new server size

Returns

boolean
TRUE on success; FALSE on failure

Api

public boolean
# resizeConfirm( )

confirms the resize of a server

confirms the resize of a server

Returns

boolean
TRUE on success; FALSE on failure

Api

public boolean
# resizeRevert( )

reverts the resize of a server

reverts the resize of a server

Returns

boolean
TRUE on success; FALSE on failure

Api

public boolean
# setPassword( string $newpasswd )

Sets the root password on the server

Sets the root password on the server

Parameters

$newpasswd
string
$newpasswd The new root password for the server

Returns

boolean
TRUE on success; FALSE on failure

Api

public string
# rescue( )

Puts the server into rescue mode

Puts the server into rescue mode

Returns

string
the root password of the rescue server

Throws

ServerActionError
if the server has no ID (i.e., has not been created yet)

Link

http://docs.rackspace.com/servers/api/v2/cs-devguide/content/rescue_mode.html

Api

public HttpResponse
# unrescue( )

Takes the server out of rescue mode

Takes the server out of rescue mode

Returns

HttpResponse

Throws

ServerActionError
if the server has no ID (i.e., has not been created yet)

Link

http://docs.rackspace.com/servers/api/v2/cs-devguide/content/rescue_mode.html

Api

public OpenCloud\Compute\Metadata
# metadata( string $key = null )

Retrieves the metadata associated with a Server

Retrieves the metadata associated with a Server

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
$key - the (optional) name of the metadata item to return

Returns

OpenCloud\Compute\Metadata
object

Throws

MetadataError

Api

public object
# ips( string $network = null )

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

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

Parameters

$network
string
$network - if supplied, then only the IP(s) for the specified network are returned. Otherwise, all IPs are returned.

Returns

object

Throws

ServerIpsError

Api

public
# attachVolume( OpenCloud\Volume\Volume $volume, string $device = 'auto' )

Attaches a volume to a server

Attaches a volume to a server

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

Parameters

$volume
OpenCloud\VolumeService\Volume
$vol 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
$device the device to which to attach it

Api

public
# detachVolume( OpenCloud\Volume\Volume $volume )

removes a volume attachment from a server

removes a volume attachment from a server

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

Parameters

$volume
OpenCloud\VolumeService\Volume
$vol the volume to remove

Throws

VolumeError

Api

public
# volumeAttachment( mixed $id = null )

returns a VolumeAttachment object

returns a VolumeAttachment object

public Collection
# volumeAttachmentList( )

returns a Collection of VolumeAttachment objects

returns a Collection of VolumeAttachment objects

Returns

Collection

Api

public
# addFile( string $path, string $data )

adds a "personality" file to be uploaded during Create() or Rebuild()

adds a "personality" file to be uploaded during Create() or Rebuild()

The $path argument specifies where the file will be stored on the target server; the $data is the actual data values to be stored. To upload a local file, use file_get_contents('name') for the $data value.

Parameters

$path
string
$path the file path (up to 255 characters)
$data
string
$data the file contents (max size set by provider)

Throws

PersonalityError
if server already exists (has an ID)

Api

public
# console( mixed $type = 'novnc' )

Returns a console connection Note: Where is this documented?

Returns a console connection Note: Where is this documented?

CodeCoverageIgnore

protected json
# createJson( )

Creates the JSON for creating a new server

Creates the JSON for creating a new server

Returns

json

Throws

CreateError
if not overridden

Overrides

OpenCloud\Common\PersistentObject::createJson()
protected json
# updateJson( mixed $params = array() )

Creates the JSON for updating a server

Creates the JSON for updating a server

Returns

json

Throws

UpdateError
if not overridden

Overrides

OpenCloud\Common\PersistentObject::updateJson()
Methods inherited from OpenCloud\Common\PersistentObject
__set(), action(), checkExtension(), customAction(), delete(), findLink(), getParent(), getService(), id(), jsonCollectionElement(), jsonCollectionName(), jsonName(), name(), noCreate(), noDelete(), noUpdate(), parent(), primaryKeyField(), refresh(), region(), resourceName(), service(), setParent(), setService(), status(), update(), url(), waitFor()
Methods inherited from OpenCloud\Common\Base
checkJsonError(), getHttpRequestObject(), getLogger(), makeQueryString(), populate(), setLogger(), setProperty()
Properties summary
public mixed $status
#
public mixed $updated
#
public mixed $hostId
#
public mixed $addresses
#
public mixed $links
#
public mixed $image
#
public mixed $flavor
#
public array $networks array()
#
public mixed $id
#
public mixed $user_id
#
public mixed $name
#
public mixed $created
#
public mixed $tenant_id
#
public mixed $accessIPv4
#
public mixed $accessIPv6
#
public mixed $progress
#
public mixed $adminPass
#
public mixed $metadata
#
protected static string $json_name 'server'
#
protected static string $url_resource 'servers'
#
PHP OpenCloud API API documentation generated by ApiGen 2.8.0