PHP Cloud Server implementation for RackSpace (tm)

THIS SOFTWARE IS PROVIDED "AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

\Cloud\Server\Exception
package Cloud
version 0.3
license bsd
author Aleksey Korzun
link http://github.com/AlekseyKorzun/php-cloudservers/
link http://www.alekseykorzun.com

 Methods

Class constructor

__construct(string $username, string $key, string $location) 

Parameters

$username

string

user id that will be used for API

$key

string

key that was generated by Rackspace

$location

string

location of API use wish to use

Exceptions

\Cloud\Server\Exception

Create a new back-up schedule for a server

addBackupSchedule(int $serverId, string $weekly, string $daily, bool $isEnabled) : bool

Parameters

$serverId

int

id of a server this back-up schedule is intended for

$weekly

string

day of the week this back-up should run, look at $backupSchedules array and/or documentation for valid parameters

$daily

string

time of the day this back-up should run, look at $backupSchedules array and/or documentation for valid parameters

$isEnabled

bool

should this scheduled back-up be enabled or disabled, default is set to enabled.

Exceptions

\Cloud\Server\Exception

Returns

booltrue on success and false on failure

Adds file to inject while creating new server

addServerFile(string $file, string $content) : string[]

Parameters

$file

string

full file path where file will be put (/etc/motd,etc)

$content

string

content of the file (Welcome to my server, etc)

Returns

string[]returns array of all files pending injection

Add a server to shared ip group

addSharedIpGroup(string $name, int $serverId) : mixed

Parameters

$name

string

name of shared ip group you are creating

$serverId

int

id of server you wish to add to this group

Returns

mixedreturns json string containing id of created shared ip group or false on failure

Perform authentication

authenticate() : string | bool

Returns

stringboolreturns recieved token or false on failure

Confirm resize of server

confirmResize(int $serverId) : bool

Parameters

$serverId

int

id of server this confirmation is for

Returns

boolreturns true on success or false on fail

Creates a new image of server

createImage(string $name, int $serverId) : mixed

Parameters

$name

string

name of new image

$serverId

int

server id for which you wish to base this image on

Returns

mixedreturns json string containing details of created image or false on failure

Creates a new server on the cloud

createServer(string $name, int $imageRefId, int $flavorRefId, int $groupId) : mixed

Parameters

$name

string

server name, must be unique

$imageRefId

int

server image you wish to use

$flavorRefId

int

server flavor you wish to use

$groupId

int

optional group id of server cluster

Returns

mixedreturns json string of server's configuration or false on failure

Deletes scheduled back-up for specific server

deleteBackupSchedule(int $serverId) : bool

Parameters

$serverId

int

id of server you wish to delete all scheduled back-ups for

Returns

boolreturns true on success or false on failure

Delete server

deleteServer(int $serverId) : bool

Parameters

$serverId

int

id of server you wish to delete

Returns

boolreturns true on success or false on fail

Delete shared IP group

deleteSharedIpGroup(int $groupId) : bool

Parameters

$groupId

int

id of group you wish to delete

Returns

boolreturns true on success and false on failure

Disable debugging output

disableDebug() 

Enables debugging output

enableDebug() 

Retrieve back-up schedule for a specific server

getBackupSchedule(int $serverId) : mixed

Parameters

$serverId

int

id of server you wish to retrieve back-up schedule for

Returns

mixedreturns json string of current back-up schedule or false on failure

Retrieves details regarding specific server flavor

getFlavor(string $flavorRefId) : mixed

Parameters

$flavorRefId

string

id of a flavor you wish to retrieve details for

Returns

mixedreturns JSON string containing details for requested flavor or false on failure

Retrieves all of the available server flavors

getFlavors(bool $isDetailed) : mixed

Parameters

$isDetailed

bool

requested detailed description of server flavors

Returns

mixedreturns json string containing available server configurations or false on failure

Retrieves details of specific image

getImage(string $imageRefId) : \Cloud\json

Parameters

$imageRefId

string

id of image you wish to retrieve details for

Returns

\Cloud\jsonstring containing details of requested image

Retrieves all of the available images

getImages($isDetailed) : mixed

Parameters

$isDetailed

Returns

mixedreturns json string of available images or false on failure

Retrieves current API limits

getLimits() : mixed

Returns

mixedjson string containing current limits or false on failure

Retrieves configuration details for specific server

getServer(int $serverId) : mixed

Parameters

$serverId

int

id of server this action is performed for

Returns

mixedjson string containing server details or false on failure

Get IP's assigned to server

getServerIp(int $serverId, string $type) : mixed

Parameters

$serverId

int

id of server you wish to retrieve ips for

$type

string

type of addresses to retrieve could be private/public or false for both types.

Returns

mixedreturns json string of server addresses or false of failure

Retrieves currently available servers

getServers(bool $isDetailed) : mixed

Parameters

$isDetailed

bool

should API return more detailed server descriptions for available servers

Returns

mixedjson string containing current servers or false on failure

Retrieve details for specific IP group

getSharedIpGroup(int $groupId) : mixed

Parameters

$groupId

int

id of specific shared group you wish to retrieve details for

Returns

mixedreturns json string containing details about requested group or false on failure

Retrieve all the available shared IP groups

getSharedIpGroups(bool $isDetailed) : mixed

Parameters

$isDetailed

bool

should response contain an array of servers group has

Returns

mixedreturns json string of groups or false on failure

Get authentication token

getToken() : mixed

Returns

mixedreturn authentication token or false on failure

Reboots server

rebootServer(int $serverId, string $type) : bool

Parameters

$serverId

int

id of server you wish to reboot

$type

string

specify what kind of reboot you wish to perform

Returns

boolreturns true on success or false on fail

Rebuild server using another server image

rebuildServer(int $serverId, int $imageRefId) : bool

Parameters

$serverId

int

id of server you wish to rebuild

$imageRefId

int

id of server image you wish to use for this rebuild

Returns

boolreturns true on success or false on fail

Resize server to another flavor (server configuration)

resizeServer(int $serverId, int $flavorRefId) : bool

Parameters

$serverId

int

id of server you wish to resize

$flavorRefId

int

id of a flavor you wish to use as a starting point

Returns

boolreturns true on success or false on fail

Revert resize changes

revertResize(int $serverId) : bool

Parameters

$serverId

int

id of server you wish to revert resize for

Returns

boolreturns true on success or false on fail

Set authentication token

setToken(string $tokenId) 

Parameters

$tokenId

string

token you wish to set

Share servers IP address

shareServerIp(int $serverId, string $serverIp, int $groupId, int $doConfigure) : bool

Parameters

$serverId

int

id of server this action is performed for

$serverIp

string

IP you wish to unshare

$groupId

int

optional group id of shared server

$doConfigure

int

automaticly configure server

Returns

boolreturns true on success or false on failure

Removes a shared server IP from server

unshareServerIp(int $serverId, string $serverIp) : bool

Parameters

$serverId

int

id of server this action is performed for

$serverIp

string

IP you wish to unshare

Returns

boolreturns true on success or false on failure

Update server's name and password

updateServer(int $serverId, string $name, string $password) : mixed

Parameters

$serverId

int

id of server you wish to update

$name

string

new server name

$password

string

new server password

Returns

mixedreturns false on failure or server configuration on success

Performs cURL requests (POST,PUT,DELETE,GET) required by API.

request(string $method) 

Parameters

$method

string

HTTP method that will be used for current request

Exceptions

\Cloud\Server\Exception

 Properties

 

$attempts : int
 

$authUris : string[]
 

$backupSchedules : string[]
 

$enableDebug : bool
 

$files : string[]
 

$location : string
 

$request : string
 

$resource : string
 

$response : string
 

$responseCode : int
 

$serverUri : string
 

$servers : string[]
 

$key : string
 

$token : string
 

$username : string

 Constants

 

Retry limit for authentication

ATTEMPT_LIMIT : int
 

Authentication method

METHOD_AUTH : int
 

Delete method

METHOD_DELETE : int
 

Post method

METHOD_POST : int
 

Put method

METHOD_PUT : int
 

User agent for our client

USER_AGENT : string