OpenCloud/Compute/Server.php

Properties

Description

Defines an OpenStack Compute virtual server

Classes

Server

Properties

 
 
 
No 
No 

Description

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

Methods

AddFile, AttachVolume, Console, Create, CreateImage, CreateJson, DetachVolume, Metadata, Reboot, Rebuild, Rescue, Resize, ResizeConfirm, ResizeRevert, SetPassword, Unrescue, UpdateJson, VolumeAttachment, VolumeAttachmentList, __construct, ip, ips,

AddFile( string   $path, string   $data, ) : void

Description

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.

Arguments

Name Type Description Default
$path string

the file path (up to 255 characters)

$data string

the file contents (max size set by provider)

Return value

Type Description
void

Tags

Name Description
api
throws if server already exists (has an ID)

AttachVolume(   $volume, string   $device = 'auto', ) : n/a

Description

Attaches a volume to a server
Requires the os-volumes extension. This is a synonym for `VolumeAttachment::Create()`

Arguments

Name Type Description Default
$volume n/a
$device string

the device to which to attach it

'auto'

Return value

Type Description
n/a n/a

Tags

Name Description
api

Console(   $type = 'novnc', ) : n/a

Description

returns a console connection

Arguments

Name Type Description Default
$type n/a 'novnc'

Return value

Type Description
n/a n/a

Create( array   $params = array(), ) : \OpenCloud\Compute\HttpResponse

Description

Creates a new server from the data existing in the object

Arguments

Name Type Description Default
$params array
  • an associative array of key/value pairs of attributes to set on the new server
array()

Return value

Type Description
\OpenCloud\Compute\HttpResponse - this will include the administrative password in the body

Tags

Name Description
api
throws
throws
throws

CreateImage( string   $name, array   $metadata = array(), ) : boolean

Description

Creates a new image from a server

Arguments

Name Type Description Default
$name string

The name of the new image

$metadata array

Optional metadata to be stored on the image

array()

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

CreateJson(   $params = NULL, ) : \OpenCloud\Compute\json

Description

Creates the JSON for creating a new server

Arguments

Name Type Description Default
$params n/a NULL

Return value

Type Description
\OpenCloud\Compute\json

DetachVolume(   $volume, ) : n/a

Description

removes a volume attachment from a server
Requires the os-volumes extension. This is a synonym for `VolumeAttachment::Delete()`

Arguments

Name Type Description Default
$volume n/a

Return value

Type Description
n/a n/a

Tags

Name Description
api
throws

Metadata( string   $key = null, ) : \OpenCloud\Compute\OpenCloud\Compute\Metadata

Description

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.

Arguments

Name Type Description Default
$key string
  • the (optional) name of the metadata item to return
null

Return value

Type Description
\OpenCloud\Compute\OpenCloud\Compute\Metadata object

Tags

Name Description
api
throws

Reboot( string   $type = RAXSDK_SOFT_REBOOT, ) : boolean

Description

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.

Arguments

Name Type Description Default
$type string
  • either 'soft' (the default) or 'hard' to indicate the type of reboot
RAXSDK_SOFT_REBOOT

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

Rebuild( array   $params = array(), ) : n/a

Description

Rebuilds an existing server

Arguments

Name Type Description Default
$params array
  • an associative array of key/value pairs of attributes to set on the new server
array()

Return value

Type Description
n/a n/a

Tags

Name Description
api

Rescue( ) : string

Description

Puts the server into *rescue* mode

Return value

Type Description
string the root password of the rescue server

Tags

Name Description
api
link http://docs.rackspace.com/servers/api/v2/cs-devguide/content/rescue_mode.html
throws if the server has no ID (i.e., has not been created yet)

Resize( \OpenCloud\Compute\Flavor   $flavorRef, ) : boolean

Description

Initiates the resize of a server

Arguments

Name Type Description Default
$flavorRef \OpenCloud\Compute\Flavor

a Flavor object indicating the new server size

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

ResizeConfirm( ) : boolean

Description

confirms the resize of a server

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

ResizeRevert( ) : boolean

Description

reverts the resize of a server

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

SetPassword( string   $newpasswd, ) : boolean

Description

Sets the root password on the server

Arguments

Name Type Description Default
$newpasswd string

The new root password for the server

Return value

Type Description
boolean TRUE on success; FALSE on failure

Tags

Name Description
api

Unrescue( ) : \OpenCloud\Compute\HttpResponse

Description

Takes the server out of *rescue* mode

Return value

Type Description
\OpenCloud\Compute\HttpResponse

Tags

Name Description
api
link http://docs.rackspace.com/servers/api/v2/cs-devguide/content/rescue_mode.html
throws if the server has no ID (i.e., has not been created yet)

UpdateJson(   $params = array(), ) : \OpenCloud\Compute\json

Description

creates the JSON for updating a server

Arguments

Name Type Description Default
$params n/a array()

Return value

Type Description
\OpenCloud\Compute\json

VolumeAttachment(   $id = null, ) : n/a

Description

returns a VolumeAttachment object

Arguments

Name Type Description Default
$id n/a null

Return value

Type Description
n/a n/a

VolumeAttachmentList( ) : \OpenCloud\Compute\Collection

Description

returns a Collection of VolumeAttachment objects

Return value

Type Description
\OpenCloud\Compute\Collection

Tags

Name Description
api

__construct(   $service, mixed   $info = null, ) : n/a

Description

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

Arguments

Name Type Description Default
$service n/a
$info mixed
  • 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.
null

Return value

Type Description
n/a n/a

Tags

Name Description
throws if a 404 is returned
throws if another error status is reported

ip( integer   $ip_type = RAXSDK_DEFAULT_IP_VERSION, ) : string

Description

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.

Arguments

Name Type Description Default
$ip_type integer

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

RAXSDK_DEFAULT_IP_VERSION

Return value

Type Description
string IP address

Tags

Name Description
api

ips( string   $network = null, ) : object

Description

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

Arguments

Name Type Description Default
$network string
  • if supplied, then only the IP(s) for the specified network are returned. Otherwise, all IPs are returned.
null

Return value

Type Description
object

Tags

Name Description
api
throws

Properties

$accessIPv4, $accessIPv6, $addresses, $adminPass, $created, $flavor, $flavorRef, $hostId, $id, $image, $imageRef, $json_name, $links, $metadata, $name, $networks, $personality, $progress, $status, $tenant_id, $updated, $url_resource, $user_id,

  public  $accessIPv4 =




  public  $accessIPv6 =




  public  $addresses =




  public  $adminPass =




  public  $created =




  public  $flavor =




  private  $flavorRef =




  public  $hostId =




  public  $id =




  public  $image =




  private  $imageRef =




  protected  static $json_name = 'server'




  public  $links =




  public  $metadata =




  public  $name =




  public  $networks = array()




  private  $personality = array()




  public  $progress =




  public  $status =




  public  $tenant_id =




  public  $updated =




  protected  static $url_resource = 'servers'




  public  $user_id =




Documentation was generated by phpDocumentor 2.0.0b6 .

Namespaces

Packages