@@ -18,51 +18,8 @@ Contents:
18
18
<a name =" auth " ></a >
19
19
Authentication
20
20
--------------
21
- Before you can use any of the cloud services, you must authenticate
22
- using a connection object. This object establishes a relationship
23
- between a user and a single Keystone identity endpoint URL. There are
24
- two different connection services provided: OpenStack and Rackspace
25
- (hopefully, there will be more in the future, and developers are
26
- encouraged to contribute theirs).
27
21
28
- To use the ** php-opencloud** library, use this ` require() ` statement in your
29
- script:
30
-
31
- require '/path/to/lib/php-opencloud.php';
32
-
33
- Once you've referenced the desired connection class, you can proceed
34
- to establish the connection. For OpenStack clouds, provide the
35
- username and password:
36
-
37
- $conn = new \OpenCloud\OpenStack(
38
- 'https://example.com/v2/identity',
39
- array(
40
- 'username' => 'your username',
41
- 'password' => 'your Keystone password',
42
- 'tenantName' => 'your tenant (project) name'
43
- ));
44
-
45
- (Note that the ` tenantName ` value may not be required for all installations.)
46
-
47
- If you are using Rackspace's authentication, you need to pass your
48
- API key and tenant ID instead:
49
-
50
- $conn = new \OpenCloud\Rackspace(
51
- 'https://example.com/v2/identity',
52
- array(
53
- 'username' => 'your username',
54
- 'apiKey' => 'your API key',
55
- 'tenantName' => 'your tenant name'
56
- ));
57
-
58
- Note that the ` Rackspace ` class will also permit ` username ` /` password `
59
- authentication as well, but the ` apiKey ` method is preferred.
60
- The ` tenantName ` argument is optional; if not provided, your access
61
- may be restricted because of ACLs on the account.
62
-
63
- The connection object can be re-used at will (so long as you're
64
- communicating with the same endpoint) and must be passed to other
65
- data objects.
22
+ Please see [ this section] ( https://github.com/rackspace/php-opencloud/blob/master/docs/getting-started.md#1-setup-the-client-and-pass-in-your-credentials ) about authenticating.
66
23
67
24
68
25
<a name =" compute " ></a >
@@ -77,27 +34,15 @@ These examples all assume a connection object `$conn` created using either the
77
34
To connect to a Compute instance, you need to specify the name of the service,
78
35
the region, and the URL type:
79
36
80
- $compute = $conn->Compute ('cloudServersOpenStack', 'DFW', 'publicURL');
37
+ $compute = $conn->computeService ('cloudServersOpenStack', 'DFW', 'publicURL');
81
38
82
39
This can get complicated, but you can simplify things by relying upon the
83
- default values. For example, the default URL type is ` 'publicURL' ` , so you
84
- can leave that off:
85
-
86
- $compute = $conn->Compute('cloudServersOpenStack', 'DFW');
87
-
88
- and you can set the defaults once and not have to change it:
40
+ default values. For example: the default service name for Rackspace Compute is ` cloudServersOpenStack ` , the default
41
+ region is ` DFW ` , and the default URL type is ` publicURL ` . So if your service matches this default criteria, you can
42
+ leave them out:
89
43
90
- $conn->SetDefaults('Compute', 'cloudServersOpenStack', 'DFW', 'publicURL' );
44
+ $compute = $ conn->computeService( );
91
45
92
- So this code:
93
-
94
- $compute = $conn->Compute();
95
-
96
- connects to the default service and region, while this one:
97
-
98
- $computeORD = $conn->Compute(NULL, 'ORD');
99
-
100
- connects to the same service, but on the ` 'ORD' ` endpoint.
101
46
102
47
### Working with lists (the Collection object)
103
48
@@ -116,7 +61,7 @@ Collections have four primary methods:
116
61
The following examples display the lists of flavors, images, and servers
117
62
for a compute object:
118
63
119
- $flavorlist = $compute->FlavorList ();
64
+ $flavorlist = $compute->flavorList ();
120
65
$flavorlist->Sort(); // The default sort key is 'id'
121
66
while($flavor = $flavorlist->Next())
122
67
printf("Flavor: %s RAM=%d\n", $flavor->name, $flavor->ram);
@@ -261,7 +206,7 @@ Cloud Networks is accessible via the `Compute` object. Thus, before you can
261
206
create or manage virtual networks, you must have a Compute connection:
262
207
263
208
$cloud = new Rackspace(...);
264
- $compute = $cloud->Compute (...);
209
+ $compute = $cloud->computeService (...);
265
210
266
211
The following examples assume the use of the ` $compute ` object.
267
212
@@ -341,49 +286,43 @@ Quick Reference - Cloud Databases (database as a service)
341
286
342
287
### Connecting to the Database service
343
288
344
- Cloud Databases is not part of OpenStack; the product is only available
345
- via a Rackspace connection :
289
+ To connect to Cloud Databases, you must use the ` OpenCloud\Database\Service ` object. Like the other
290
+ services, you must specify the service name ("cloudDatabases"), the region, and the URL type :
346
291
347
- $cloud = new OpenCloud\Rackspace('https://... ', array(...) );
292
+ $databaseService = $client->databaseService('cloudDatabases ', 'DFW', 'publicURL' );
348
293
349
- To connect to Cloud Databases, you use the ` DbService ` object. Like the other
350
- services, you must specify the service name ("cloudDatabases"),
351
- the region, and the URL type:
294
+ This can be simplified if you're happy using the defaults:
352
295
353
- $dbaas = $cloud->DbService('cloudDatabases','DFW','publicURL');
354
-
355
- This can be simplified by using the defaults:
356
-
357
- $dbaas = $cloud->DbService(NULL, 'DFW');
296
+ $databaseService = $cloud->databaseService();
358
297
359
298
### Creating a database service instance
360
299
361
- $instance = $dbaas ->Instance(); // empty Instance
300
+ $instance = $databaseService ->Instance(); // empty Instance
362
301
$instance->name = 'InstanceName';
363
302
$instance->flavor = $dbaas->Flavor(1); // small
364
303
$instance->volume->size = 2; // 2GB disk
365
304
$instance->Create(); // create it
366
305
367
306
### Retrieve an existing instance
368
307
369
- $instance = $dbaas ->Instance({INSTANCE-ID});
308
+ $instance = $databaseService ->Instance({INSTANCE-ID});
370
309
371
310
### List all instances
372
311
373
- $instlist = $dbaas->InstanceList ();
374
- while($instance = $instlist->Next ()) {
312
+ $instances = $databaseService->instanceList ();
313
+ while ($instance = $instances->next ()) {
375
314
printf("%s (%s)\n", $instance->id, $instance->name);
376
315
}
377
316
378
317
### Delete an instance
379
318
380
- $instance->Delete ();
319
+ $instance->delete ();
381
320
382
321
### Performing instance actions
383
322
384
323
#### Restart
385
324
386
- $instance->Restart ();
325
+ $instance->restart ();
387
326
388
327
#### Resize
389
328
@@ -467,26 +406,9 @@ The `databases` attribute of a user contains a list of all the database
467
406
Quick Reference - Cloud Block Storage (Cinder)
468
407
----------------------------------------------
469
408
Cloud Block Storage is a dynamic volume creation and management service
470
- built upon the OpenStack Cinder project.
409
+ built upon the OpenStack Cinder project. To use Block Storage, you must use the ` OpenCloud\Volume\Service ` :
471
410
472
- ### Connecting to Cloud Block Storage
473
- Cloud Block Storage is available on either the OpenStack or Rackspace
474
- connection using the ` VolumeService ` method:
475
-
476
- Assuming:
477
-
478
- $cloud = new Rackspace(...);
479
-
480
- Syntax:
481
-
482
- {variable} = $cloud->VolumeService({servicename}, {region}, {urltype});
483
-
484
- Example:
485
-
486
- $dallas = $cloud->VolumeService('cloudBlockStorage', 'DFW');
487
-
488
- This creates a connection to the ` cloudBlockStorage ` service (as it is
489
- called at Rackspace) in the ` DFW ` region.
411
+ $volumeService = $client->volumeService('cloudBlockStorage', 'DFW', 'publicURL');
490
412
491
413
### Volume Types
492
414
@@ -497,7 +419,7 @@ either be `SSD` (solid state disk: expensive, high-performance) or
497
419
#### Listing volume types
498
420
The ` VolumeTypeList ` method returns a Collection of VolumeType objects:
499
421
500
- $vtlist = $dallas ->VolumeTypeList();
422
+ $vtlist = $volumeService ->VolumeTypeList();
501
423
while($vt = $vtlist->Next())
502
424
printf("%s %s\n", $vt->id, $vt->Name());
503
425
@@ -508,7 +430,7 @@ This lists the volume types and their IDs.
508
430
If you know the ID of a volume type, use the ` VolumeType ` method to retrieve
509
431
information on it:
510
432
511
- $volumetype = $dallas ->VolumeType(1);
433
+ $volumetype = $volumeService ->VolumeType(1);
512
434
513
435
### Working with Volumes
514
436
@@ -523,7 +445,7 @@ the volume type is recommended.
523
445
524
446
Example:
525
447
526
- $myvolume = $dallas ->Volume(); // an empty volume object
448
+ $myvolume = $volumeService ->Volume(); // an empty volume object
527
449
$response = $myvolume->Create(array(
528
450
'size' => 200,
529
451
'volume_type' => $dallas->VolumeType(1),
@@ -537,7 +459,7 @@ a `VolumeType` object.
537
459
538
460
The ` VolumeList ` method returns a Collection of Volume objects:
539
461
540
- $volumes = $dallas ->VolumeList();
462
+ $volumes = $volumeService ->VolumeList();
541
463
$volumes->Sort('display_name');
542
464
while($vol = $volumes->Next())
543
465
print $vol->Name()."\n";
@@ -549,7 +471,7 @@ This lists all the volumes associated with your account.
549
471
If you specify an ID on the ` Volume ` method, it retrieves information on
550
472
the specified volume:
551
473
552
- $myvolume = $dallas ->Volume('0d0f90209...');
474
+ $myvolume = $volumeService ->Volume('0d0f90209...');
553
475
printf("volume size = %d\n", $myvolume->size);
554
476
555
477
#### To delete a volume
@@ -569,7 +491,7 @@ the snapshot.
569
491
A ` Snapshot ` object is created from the Cloud Block Storage service. However,
570
492
it is associated with a volume, and you must specify a volume to create one:
571
493
572
- $snapshot = $dallas ->Snapshot(); // empty Snapshot object
494
+ $snapshot = $volumeService ->Snapshot(); // empty Snapshot object
573
495
$snapshot->Create(array(
574
496
'display_name' => 'Name that snapshot',
575
497
'volume_id' => $volume->id));
@@ -578,15 +500,15 @@ it is associated with a volume, and you must specify a volume to create one:
578
500
579
501
The ` SnapshotList ` method returns a Collection of Snapshot objects:
580
502
581
- $snaplist = $dallas ->SnapshotList();
503
+ $snaplist = $volumeService ->SnapshotList();
582
504
while($snap = $snaplist->Next())
583
505
printf("[%s] %s\n", $snap->id, $snap->Name());
584
506
585
507
#### To get details on a single snapshot
586
508
587
509
To retrieve a single Snapshot, specify its ID on the ` Snapshot ` method:
588
510
589
- $snapshot = $dallas ->Snapshot({snapshot-id});
511
+ $snapshot = $volumeService ->Snapshot({snapshot-id});
590
512
591
513
#### To delete a snapshot
592
514
@@ -603,8 +525,8 @@ a server so that the server can use the volume.
603
525
604
526
Syntax:
605
527
606
- $server = $compute ->Server({server-id});
607
- $volume = $dallas ->Volume({volume-id});
528
+ $server = $computeService ->Server({server-id});
529
+ $volume = $volumeService ->Volume({volume-id});
608
530
$server->AttachVolume($volume, {mount-point})
609
531
610
532
` {server-id} ` and ` {volume-id} ` are the IDs of the server and volume,
@@ -617,16 +539,16 @@ parameter.
617
539
618
540
Example:
619
541
620
- $server = $compute ->Server('010d092...');
621
- $volume = $dallas ->Volume('39d0f0...');
542
+ $server = $computeService ->Server('010d092...');
543
+ $volume = $volumeService ->Volume('39d0f0...');
622
544
$server->AttachVolume($volume); // uses the 'auto' mount point
623
545
624
546
#### To detach a volume from a server
625
547
626
548
Syntax:
627
549
628
- $server = $compute ->Server({server-id});
629
- $volume = $dallas ->Volume({volume-id});
550
+ $server = $computeService ->Server({server-id});
551
+ $volume = $volumeService ->Volume({volume-id});
630
552
$server->DetachVolume($volume);
631
553
632
554
<a name =" CLB " ></a >
@@ -639,17 +561,8 @@ dynamically. It is not currently part of the OpenStack project.
639
561
Cloud Block Storage is available only via a ` Rackspace `
640
562
connection using the ` LoadBalancerService ` method:
641
563
642
- Assuming:
643
-
644
- $cloud = new Rackspace(...);
645
-
646
- Syntax:
647
-
648
- {variable} = $cloud->LoadBalancerService({servicename}, {region}, {urltype});
649
-
650
- Example:
651
-
652
- $chitown = $cloud->VolumeService('cloudLoadBalancers', 'ORD');
564
+ $client = new Rackspace(...);
565
+ $lbService = $client->loadBalancerService(...);
653
566
654
567
This creates a connection to the ` cloudLoadBalancers ` service
655
568
in the ` ORD ` (Chicago) region.
@@ -686,12 +599,7 @@ Cloud DNS lets you manage your domain names via a simple interface. To connect
686
599
to Cloud DNS:
687
600
688
601
$cloud = new Rackspace(...);
689
- $dns = $cloud->DNS({name}, {region}, {urltype});
690
-
691
- Omitted values use defaults; since Cloud DNS is regionless, this is usually
692
- sufficient:
693
-
694
- $dns = $cloud->DNS();
602
+ $dns = $cloud->dnsService(...);
695
603
696
604
### Service-Level Methods
697
605
0 commit comments