3
* (c)2012 Rackspace Hosting. See COPYING for license details
8
require_once "php-opencloud.php";
11
* Relies upon environment variable settings — these are the same environment
12
* variables that are used by python-novaclient. Just make sure that they're
13
* set to the right values before running this test.
15
define('AUTHURL', RACKSPACE_US);
16
define('USERNAME', $_ENV['OS_USERNAME']);
17
define('TENANT', $_ENV['OS_TENANT_NAME']);
18
define('APIKEY', $_ENV['NOVA_API_KEY']);
20
define('VOLUMENAME', 'SampleVolume');
21
define('VOLUMESIZE', 100);
26
function step($msg,$p1=NULL,$p2=NULL,$p3=NULL) {
28
printf("\nStep %d. %s\n", ++$STEPCOUNTER, sprintf($msg,$p1,$p2,$p3));
30
function info($msg,$p1=NULL,$p2=NULL,$p3=NULL,$p4=NULL,$p5=NULL) {
31
printf(" %s\n", sprintf($msg,$p1,$p2,$p3,$p4,$p5));
33
define('TIMEFORMAT', 'r');
36
$rackspace = new \OpenCloud\Rackspace(AUTHURL,
37
array( 'username' => USERNAME,
38
'apiKey' => APIKEY ));
40
step('Connect to the Load Balancer Service');
41
$lbservice = $rackspace->LoadBalancerService('cloudLoadBalancers', 'DFW');
44
$adlist = $lbservice->AllowedDomainList();
45
while($ad = $adlist->Next()) {
46
info('Allowed domain: [%s]', $ad->Name());
51
$prolist = $lbservice->ProtocolList();
52
while($prot = $prolist->Next()) {
54
substr($prot->Name().'.....................',0,20), $prot->port);
59
$alist = $lbservice->AlgorithmList();
60
while($al = $alist->Next()) {
61
info(' %s', $al->Name());
64
// list load balancers
65
$list = $lbservice->LoadBalancerList();
67
step('Load balancers:');
68
while($lb = $list->Next()) {
69
info('[%s] %s in %s', $lb->id, $lb->Name(), $lb->Region());
70
info(' Status: [%s]', $lb->Status());
73
$list = $lb->NodeList();
74
if ($list->Size() == 0)
77
while($node = $list->Next()) {
78
info(' Node: [%s] %s:%d %s/%s',
79
$node->Id(), $node->address, $node->port,
80
$node->condition, $node->status);
85
$list = $lb->NodeEventList();
86
if ($list->Size() == 0)
87
info(' No node events');
89
while($event = $list->Next()) {
90
info(' * Event: %s (%s)',
91
$event->detailedMessage, $event->author);
97
$ssl = $lb->SSLTermination();
98
info(' SSL terminated');
99
} catch (OpenCloud\InstanceNotFound $e) {
100
info(' No SSL termination');
104
$list = $lb->MetadataList();
105
while($meta = $list->Next()) {
106
info(' [Metadata #%s] %s=%s',
107
$meta->Id(), $meta->key, $meta->value);
112
step('There are no load balancers');
115
$start = date('Y-m-d', time()-(3600*24*30));
116
$end = date('Y-m-d');
117
step('Billable Load Balancers from %s to %s', $start, $end);
118
$list = $lbservice->BillableLoadBalancerList(
120
array('startTime'=>$start, 'endTime'=>$end));
121
if ($list->Size() > 0) {
122
while($lb = $list->Next()) {
123
info('%10s %s', $lb->Id(), $lb->Name());
124
info('%10s created: %s', '', $lb->created->time);
134
info('...%s', $obj->Status());