@@ -18,51 +18,8 @@ Contents:
1818<a name =" auth " ></a >
1919Authentication
2020--------------
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).
2721
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.
6623
6724
6825<a name =" compute " ></a >
@@ -77,27 +34,15 @@ These examples all assume a connection object `$conn` created using either the
7734To connect to a Compute instance, you need to specify the name of the service,
7835the region, and the URL type:
7936
80- $compute = $conn->Compute ('cloudServersOpenStack', 'DFW', 'publicURL');
37+ $compute = $conn->computeService ('cloudServersOpenStack', 'DFW', 'publicURL');
8138
8239This 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:
8943
90- $conn->SetDefaults('Compute', 'cloudServersOpenStack', 'DFW', 'publicURL' );
44+ $compute = $ conn->computeService( );
9145
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.
10146
10247### Working with lists (the Collection object)
10348
@@ -116,7 +61,7 @@ Collections have four primary methods:
11661The following examples display the lists of flavors, images, and servers
11762for a compute object:
11863
119- $flavorlist = $compute->FlavorList ();
64+ $flavorlist = $compute->flavorList ();
12065 $flavorlist->Sort(); // The default sort key is 'id'
12166 while($flavor = $flavorlist->Next())
12267 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
261206create or manage virtual networks, you must have a Compute connection:
262207
263208 $cloud = new Rackspace(...);
264- $compute = $cloud->Compute (...);
209+ $compute = $cloud->computeService (...);
265210
266211The following examples assume the use of the ` $compute ` object.
267212
@@ -341,49 +286,43 @@ Quick Reference - Cloud Databases (database as a service)
341286
342287### Connecting to the Database service
343288
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 :
346291
347- $cloud = new OpenCloud\Rackspace('https://... ', array(...) );
292+ $databaseService = $client->databaseService('cloudDatabases ', 'DFW', 'publicURL' );
348293
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:
352295
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();
358297
359298### Creating a database service instance
360299
361- $instance = $dbaas ->Instance(); // empty Instance
300+ $instance = $databaseService ->Instance(); // empty Instance
362301 $instance->name = 'InstanceName';
363302 $instance->flavor = $dbaas->Flavor(1); // small
364303 $instance->volume->size = 2; // 2GB disk
365304 $instance->Create(); // create it
366305
367306### Retrieve an existing instance
368307
369- $instance = $dbaas ->Instance({INSTANCE-ID});
308+ $instance = $databaseService ->Instance({INSTANCE-ID});
370309
371310### List all instances
372311
373- $instlist = $dbaas->InstanceList ();
374- while($instance = $instlist->Next ()) {
312+ $instances = $databaseService->instanceList ();
313+ while ($instance = $instances->next ()) {
375314 printf("%s (%s)\n", $instance->id, $instance->name);
376315 }
377316
378317### Delete an instance
379318
380- $instance->Delete ();
319+ $instance->delete ();
381320
382321### Performing instance actions
383322
384323#### Restart
385324
386- $instance->Restart ();
325+ $instance->restart ();
387326
388327#### Resize
389328
@@ -467,26 +406,9 @@ The `databases` attribute of a user contains a list of all the database
467406Quick Reference - Cloud Block Storage (Cinder)
468407----------------------------------------------
469408Cloud 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 ` :
471410
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');
490412
491413### Volume Types
492414
@@ -497,7 +419,7 @@ either be `SSD` (solid state disk: expensive, high-performance) or
497419#### Listing volume types
498420The ` VolumeTypeList ` method returns a Collection of VolumeType objects:
499421
500- $vtlist = $dallas ->VolumeTypeList();
422+ $vtlist = $volumeService ->VolumeTypeList();
501423 while($vt = $vtlist->Next())
502424 printf("%s %s\n", $vt->id, $vt->Name());
503425
@@ -508,7 +430,7 @@ This lists the volume types and their IDs.
508430If you know the ID of a volume type, use the ` VolumeType ` method to retrieve
509431information on it:
510432
511- $volumetype = $dallas ->VolumeType(1);
433+ $volumetype = $volumeService ->VolumeType(1);
512434
513435### Working with Volumes
514436
@@ -523,7 +445,7 @@ the volume type is recommended.
523445
524446Example:
525447
526- $myvolume = $dallas ->Volume(); // an empty volume object
448+ $myvolume = $volumeService ->Volume(); // an empty volume object
527449 $response = $myvolume->Create(array(
528450 'size' => 200,
529451 'volume_type' => $dallas->VolumeType(1),
@@ -537,7 +459,7 @@ a `VolumeType` object.
537459
538460The ` VolumeList ` method returns a Collection of Volume objects:
539461
540- $volumes = $dallas ->VolumeList();
462+ $volumes = $volumeService ->VolumeList();
541463 $volumes->Sort('display_name');
542464 while($vol = $volumes->Next())
543465 print $vol->Name()."\n";
@@ -549,7 +471,7 @@ This lists all the volumes associated with your account.
549471If you specify an ID on the ` Volume ` method, it retrieves information on
550472the specified volume:
551473
552- $myvolume = $dallas ->Volume('0d0f90209...');
474+ $myvolume = $volumeService ->Volume('0d0f90209...');
553475 printf("volume size = %d\n", $myvolume->size);
554476
555477#### To delete a volume
@@ -569,7 +491,7 @@ the snapshot.
569491A ` Snapshot ` object is created from the Cloud Block Storage service. However,
570492it is associated with a volume, and you must specify a volume to create one:
571493
572- $snapshot = $dallas ->Snapshot(); // empty Snapshot object
494+ $snapshot = $volumeService ->Snapshot(); // empty Snapshot object
573495 $snapshot->Create(array(
574496 'display_name' => 'Name that snapshot',
575497 'volume_id' => $volume->id));
@@ -578,15 +500,15 @@ it is associated with a volume, and you must specify a volume to create one:
578500
579501The ` SnapshotList ` method returns a Collection of Snapshot objects:
580502
581- $snaplist = $dallas ->SnapshotList();
503+ $snaplist = $volumeService ->SnapshotList();
582504 while($snap = $snaplist->Next())
583505 printf("[%s] %s\n", $snap->id, $snap->Name());
584506
585507#### To get details on a single snapshot
586508
587509To retrieve a single Snapshot, specify its ID on the ` Snapshot ` method:
588510
589- $snapshot = $dallas ->Snapshot({snapshot-id});
511+ $snapshot = $volumeService ->Snapshot({snapshot-id});
590512
591513#### To delete a snapshot
592514
@@ -603,8 +525,8 @@ a server so that the server can use the volume.
603525
604526Syntax:
605527
606- $server = $compute ->Server({server-id});
607- $volume = $dallas ->Volume({volume-id});
528+ $server = $computeService ->Server({server-id});
529+ $volume = $volumeService ->Volume({volume-id});
608530 $server->AttachVolume($volume, {mount-point})
609531
610532` {server-id} ` and ` {volume-id} ` are the IDs of the server and volume,
@@ -617,16 +539,16 @@ parameter.
617539
618540Example:
619541
620- $server = $compute ->Server('010d092...');
621- $volume = $dallas ->Volume('39d0f0...');
542+ $server = $computeService ->Server('010d092...');
543+ $volume = $volumeService ->Volume('39d0f0...');
622544 $server->AttachVolume($volume); // uses the 'auto' mount point
623545
624546#### To detach a volume from a server
625547
626548Syntax:
627549
628- $server = $compute ->Server({server-id});
629- $volume = $dallas ->Volume({volume-id});
550+ $server = $computeService ->Server({server-id});
551+ $volume = $volumeService ->Volume({volume-id});
630552 $server->DetachVolume($volume);
631553
632554<a name =" CLB " ></a >
@@ -639,17 +561,8 @@ dynamically. It is not currently part of the OpenStack project.
639561Cloud Block Storage is available only via a ` Rackspace `
640562connection using the ` LoadBalancerService ` method:
641563
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(...);
653566
654567This creates a connection to the ` cloudLoadBalancers ` service
655568in the ` ORD ` (Chicago) region.
@@ -686,12 +599,7 @@ Cloud DNS lets you manage your domain names via a simple interface. To connect
686599to Cloud DNS:
687600
688601 $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(...);
695603
696604### Service-Level Methods
697605
0 commit comments