Skip to content

Commit bc90480

Browse files
committed
Merge pull request #421 from rackspace/working
Merging working -> master in preparation for minor release
2 parents 805b8a8 + 49de886 commit bc90480

File tree

127 files changed

+6841
-708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+6841
-708
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ phpunit
3434
1. Make sure your [variables-order](http://www.php.net/manual/en/ini.core.php#ini.variables-order) is set to "EGCRS"
3535
2. Set your *PHP_OpenCloud_USERNAME* and *PHP_OpenCloud_API_KEY* variables
3636
3. Run: ```php tests/OpenCloud/Smoke/Runner.php```
37+
38+
## Conventions
39+
40+
* When working on a `Service` class (e.g. [`OpenCloud\Image\Service`](/lib/OpenCloud/Image/Service.php), name methods like so:
41+
42+
* Methods that return a single resource, say `Foo`, should be named `getFoo`. For example, [`getImage`](/lib/OpenCloud/Image/Service.php#L67).
43+
* Methods that return a collection of resources, say `Foo`, should be named `listFoos`. For example, [`listImages`](/lib/OpenCloud/Image/Service.php#L53).
44+
* Methods that create a new resource, say `Foo`, should be named `createFoo`. For example, [`createEntity`](/lib/OpenCloud/CloudMonitoring/Service.php#L105).
45+
46+
* When validating arguments to a method, please throw `\InvalidArgumentException` when an invalid argument is found. For example, see [here](/lib/OpenCloud/LoadBalancer/Resource/LoadBalancer.php#L212-L215).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ You can also find assistance via IRC on #rackspace at freenode.net.
6767
Contributing
6868
------------
6969
If you'd like to contribute to the project, or require help running the unit/acceptance tests, please view the
70-
[contributing guidelines](https://github.com/rackspace/php-opencloud/blob/master/CONTRIBUTING.md).
70+
[contributing guidelines](https://github.com/rackspace/php-opencloud/blob/master/CONTRIBUTING.md).

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "PHP SDK for Rackspace/OpenStack APIs",
44
"keywords": ["rackspace", "openstack", "opencloud", "swift", "nova"],
55
"type": "library",
6-
"license": "MIT",
6+
"license": "Apache-2.0",
77
"authors": [
88
{
99
"name": "Jamie Hannaford",
@@ -22,11 +22,11 @@
2222
},
2323
"require": {
2424
"php" : ">=5.3.3",
25-
"guzzle/http" : "~3.8"
25+
"guzzle/http" : "~3.8",
26+
"psr/log": "~1.0"
2627
},
2728
"require-dev" : {
2829
"guzzle/guzzle": "~3.8",
29-
"psr/log": "~1.0",
3030
"satooshi/php-coveralls": "0.6.*@dev"
3131
}
3232
}

docs/userguide/Compute/Server.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ RAX-SI:image_schedule|If scheduled images enabled or not. If the value is TRUE,
4747

4848
## Create server
4949

50-
There are a few parameter requirements when creating a server:
50+
### Using an image
51+
52+
There are a few parameter requirements when creating a server using an image:
5153

5254
* **name** - needs to be a string;
5355
- **flavor** - a `OpenCloud\Compute\Resource\Flavor` object, that is populated with the values of a real API flavor;
@@ -86,13 +88,53 @@ try {
8688

8789
It's always best to be defensive when executing functionality over HTTP; you can achieve this best by wrapping calls in a try/catch block. It allows you to debug your failed operations in a graceful and efficient manner.
8890

91+
### Using a bootable volume
92+
93+
There are a few parameter requirements when creating a server using a bootable volume:
94+
95+
* **name** - needs to be a string;
96+
* **flavor** - a `OpenCloud\Compute\Resource\Flavor` object, that is populated with the values of a real API flavor;
97+
* **volume** - a `OpenCloud\Volume\Resource\Volume` object, that is populated with the values of a real API volume;
98+
99+
Firstly we need to find our flavor and volume using their IDs.
100+
101+
```php
102+
$volumeService = $client->volumeService();
103+
$bootableVolume = $volumeService->volume('<ID OF A BOOTABLE VOLUME>');
104+
$flavor = $compute->flavor('<ID OF A FLAVOR>');
105+
```
106+
107+
Now we're ready to create our instance:
108+
109+
```php
110+
use OpenCloud\Compute\Constants\Network;
111+
112+
$server = $compute->server();
113+
114+
try {
115+
$response = $server->create(array(
116+
'name' => 'My lovely server',
117+
'volume' => $bootableVolume,
118+
'flavor' => $flavor
119+
));
120+
} catch (\Guzzle\Http\Exception\BadResponseException $e) {
121+
// No! Something failed. Let's find out:
122+
echo $e->getRequest() . PHP_EOL . PHP_EOL;
123+
echo $e->getResponse();
124+
}
125+
```
126+
127+
It's always best to be defensive when executing functionality over HTTP; you can achieve this best by wrapping calls in a try/catch block. It allows you to debug your failed operations in a graceful and efficient manner.
128+
89129
### Create parameters
90130

91131
Name|Description|Type|Required
92132
---|---|---|---
93133
name|The server name. The name that you specify in a create request becomes the initial host name of the server. After the server is built, if you change the server name in the API or change the host name directly, the names are not kept in sync.|string|Yes
94134
flavor|A populated `OpenCloud\Compute\Resource\Flavor` object representing your chosen flavor|object|Yes
95-
image|A populated `OpenCloud\Compute\Resource\Image` object representing your chosen image|object|Yes
135+
image|A populated `OpenCloud\Compute\Resource\Image` object representing your chosen image|object|No, if volume is specified
136+
volume|A populated `OpenCloud\Volume\Resource\Volume` object representing your chosen bootable volume|object|No, if image is specified
137+
volumeDeleteOnTermination|`true` if the bootable volume should be deleted when the server is terminated; `false`, otherwise|boolean|No; default = `false`
96138
OS-DCF:diskConfig|The disk configuration value. You can use two options: `AUTO` or `MANUAL`. <br><br>`AUTO` means the server is built with a single partition the size of the target flavor disk. The file system is automatically adjusted to fit the entire partition. This keeps things simple and automated. `AUTO` is valid only for images and servers with a single partition that use the EXT3 file system. This is the default setting for applicable Rackspace base images.<br><br>`MANUAL` means the server is built using whatever partition scheme and file system is in the source image. If the target flavor disk is larger, the remaining disk space is left unpartitioned. This enables images to have non-EXT3 file systems, multiple partitions, and so on, and enables you to manage the disk configuration.|string|No
97139
networks|An array of populated `OpenCloud\Compute\Resource\Network` objects that indicate which networks your instance resides in.|array|No
98140
metadata|An array of arbitrary data (key-value pairs) that adds additional meaning to your server.|array|No

docs/userguide/DNS/Domains.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ $domains = $service->domainList();
2727
$domains = $service->domainList(true);
2828
```
2929

30-
Please consult the [iterator documentation](docs/userguide/Iterators.md) for more information about iterators.
30+
Please consult the [iterator documentation](/docs/userguide/Iterators.md) for more information about iterators.
3131

3232
### Filter parameters
3333

@@ -214,7 +214,7 @@ $asyncResponse = $service->import($bind9Data);
214214

215215
## Modify domain
216216

217-
This call modifies DNS domain(s) attributes only. Only the TTL, email address and comment attributes of a domain can be modified. Records cannot be added, modified, or removed through this API operation - you will need to use the [add records](https://github.com/jamiehannaford/php-opencloud/blob/dns-docs/docs/userguide/DNS/Records.md#add-record), [modify records](https://github.com/jamiehannaford/php-opencloud/blob/dns-docs/docs/userguide/DNS/Records.md#modify-record) or [remove records](https://github.com/jamiehannaford/php-opencloud/blob/dns-docs/docs/userguide/DNS/Records.md#delete-record) operations respectively.
217+
This call modifies DNS domain(s) attributes only. Only the TTL, email address and comment attributes of a domain can be modified. Records cannot be added, modified, or removed through this API operation - you will need to use the [add records](/docs/userguide/DNS/Records.md#add-record), [modify records](/docs/userguide/DNS/Records.md#modify-record) or [remove records](/docs/userguide/DNS/Records.md#delete-record) operations respectively.
218218

219219
```php
220220
$domain->update(array(

docs/userguide/ObjectStore/USERGUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ $options = array(
356356

357357
$objects = $container->objectList($options);
358358
```
359-
[ [Get the executable PHP script for this example](/samples/ObjectStore/list-objects-with-params.php) ]
359+
[ [Get the executable PHP script for this example](/samples/ObjectStore/list-objects-with-prefix.php) ]
360360

361361
In general, the `objectList()` method described above takes an optional parameter (`$options` in the example above). This parameter is an associative array of various options. Here is a complete listing of keys that can be specified in the `$options` array:
362362

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Orchestration
2+
3+
**Orchestration** is a service that can be used to create and manage cloud
4+
resources. Examples of such resources are databases, load balancers,
5+
servers and software installed on them.
6+
7+
## Concepts
8+
9+
To use the Orchestration service effectively, you should understand several
10+
key concepts:
11+
12+
* **Template**: An Orchestration template is a JSON or YAML document that
13+
describes how a set of resources should be assembled to produce a working
14+
deployment. The template specifies what resources should be used, what
15+
attributes of these resources are parameterized and what information is
16+
output to the user when a template is instantiated.
17+
18+
* **Resource**: A resource is a template artifact that represents some component of your desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load balancer, some configuration management system, and so forth).
19+
20+
* **Stack**: A stack is a running instance of a template. When a stack is created,
21+
the resources specified in the template are created.
22+
23+
## Getting started
24+
25+
### 1. Instantiate an OpenStack or Rackspace client.
26+
27+
To use the Orchestration service, you must first instantiate a `OpenStack` or `Rackspace` client object.
28+
29+
* If you are working with an OpenStack cloud, instantiate an `OpenCloud\OpenStack` client as follows:
30+
31+
```php
32+
use OpenCloud\OpenStack;
33+
34+
$client = new OpenStack('<OPENSTACK CLOUD IDENTITY ENDPOINT URL>', array(
35+
'username' => '<YOUR OPENSTACK CLOUD ACCOUNT USERNAME>',
36+
'password' => '<YOUR OPENSTACK CLOUD ACCOUNT PASSWORD>'
37+
));
38+
```
39+
40+
* If you are working with the Rackspace cloud, instantiate a `OpenCloud\Rackspace` client as follows:
41+
42+
```php
43+
use OpenCloud\Rackspace;
44+
45+
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
46+
'username' => '<YOUR RACKSPACE CLOUD ACCOUNT USERNAME>',
47+
'apiKey' => '<YOUR RACKSPACE CLOUD ACCOUNT API KEY>'
48+
));
49+
```
50+
51+
### 2. Obtain an Orchestration service object from the client.
52+
All Orchestration operations are done via an _orchestration service object_. To
53+
instantiate this object, call the `orchestrationService` method on the `$client`
54+
object as shown in the following example:
55+
56+
```php
57+
$region = '<CLOUD REGION NAME>';
58+
$orchestrationService = $client->orchestrationService(null, $region);
59+
```
60+
61+
Any stacks and resources created with this `$orchestrationService` instance will
62+
be stored in the cloud region specified by `$region`.
63+
64+
### 3. Create a stack from a template.
65+
```php
66+
$stack = $orchestrationService->createStack(array(
67+
'name' => 'simple-lamp-setup',
68+
'templateUrl' => 'https://raw.githubusercontent.com/rackspace-orchestration-templates/lamp/master/lamp.yaml',
69+
'parameters' => array(
70+
'server_hostname' => 'web01',
71+
'image' => 'Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)'
72+
),
73+
'timeoutMins' => 5
74+
));
75+
```
76+
77+
[ [Get the executable PHP script for this example](/samples/Orchestration/quickstart.php) ]
78+
79+
## Next steps
80+
81+
Once you have created a stack, there is more you can do with it. See [complete user guide for orchestration](USERGUIDE.md).

0 commit comments

Comments
 (0)