Skip to content

Commit 5ff27a4

Browse files
author
Jamie Hannaford
committed
Add deprecation and redirect links to existing docs
1 parent baef47e commit 5ff27a4

Some content is hidden

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

66 files changed

+166
-8007
lines changed

doc/services/compute/servers.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,42 @@ Updatable attributes
204204
| accessIPv6 | The IP version 6 address. |
205205
+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
206206

207+
208+
Updating the access IP address(es)
209+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210+
211+
For example, you may have a private cloud with internal addresses in the
212+
10.1.x range. However, you can access a server via a firewall device at
213+
address 50.57.94.244. In this case, you can change the ``accessIPv4``
214+
attribute to point to the firewall:
215+
216+
.. code-block:: php
217+
218+
$server->update(array('accessIPv4' => '50.57.94.244'));
219+
220+
When a client application retrieves the server’s information, it will
221+
know that it needs to use the ``accessIPv4`` address to connect to the
222+
server, and *not* the IP address assigned to one of the network
223+
interfaces.
224+
225+
226+
Retrieving the server’s IP address
227+
----------------------------------
228+
229+
The ``Server::ip()`` method is used to retrieve the server’s IP address.
230+
It has one optional parameter: the format (either IPv4 or IPv6) of the
231+
address to return (by default, it returns the IPv4 address):
232+
233+
.. code-block:: php
234+
235+
// IPv4
236+
echo $server->ip();
237+
echo $server->ip(4);
238+
239+
// IPv6
240+
echo $server->ip(6);
241+
242+
207243
Delete server
208244
-------------
209245

docs/getting-started-openstack.md

Lines changed: 2 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -1,201 +1,5 @@
11
# Installing the SDK
22

3-
You must install through Composer, because this library has a few dependencies:
3+
Our docs have moved! Please visit the below link:
44

5-
```bash
6-
# Install Composer
7-
curl -sS https://getcomposer.org/installer | php
8-
9-
# Require php-opencloud as a dependency
10-
php composer.phar require rackspace/php-opencloud:dev-master
11-
```
12-
13-
Once you have installed the library, you will need to load Composer's autoloader (which registers all the required
14-
namespaces):
15-
16-
```php
17-
require 'vendor/autoload.php';
18-
```
19-
20-
And you're good to go!
21-
22-
# Quick deep-dive: building some Nova instances
23-
24-
In this example, you will write code that will create a Nova instance running Ubuntu.
25-
26-
### 1. Setup the client and pass in your credentials
27-
28-
To authenticate against Keystone:
29-
30-
```php
31-
use OpenCloud\OpenStack;
32-
33-
$client = new OpenStack('http://my-openstack.com:35357/v2.0/', array(
34-
'username' => 'foo',
35-
'password' => 'bar',
36-
'tenantName' => 'baz'
37-
));
38-
```
39-
40-
You will need to substitute in the public URL endpoint for your Keystone service, as well as your `username`, `password`
41-
and `tenantName`. You can also specify your `tenantId` instead of `tenantName` if you prefer.
42-
43-
### 2. Pick what service you want to use
44-
45-
In this case, we want to use the Nova service:
46-
47-
```php
48-
$compute = $client->computeService('nova', 'regionOne');
49-
```
50-
51-
The first argument is the __name__ of the service as it appears in the OpenStack service catalog. For OpenStack users, this must be retrieved and entered in your code. If you are unsure how to retrieve the service name, follow these steps:
52-
53-
1. Setup the `$client` object, as above
54-
2. Copy and run this code:
55-
56-
```php
57-
$client->authenticate();
58-
59-
print_r($client->getCatalog()->getItems());
60-
```
61-
62-
3. This will output all the items in your service catalog. Go through the outputted list and find your service, making note of the "name" field. This is the name you will need to enter as the first argument. You will also be able to see the available regions.
63-
64-
The second argument is the region. The third and last argument is the type of URL; you may use either `publicURL` or `internalURL`.
65-
66-
### 3. Select your server image
67-
68-
Instances are based on "images", which are effectively just the type of operating system you want. Let's go through the
69-
list and find an Ubuntu one:
70-
71-
```php
72-
$images = $compute->imageList();
73-
foreach ($images as $image) {
74-
if (strpos($image->name, 'Ubuntu') !== false) {
75-
$ubuntu = $image;
76-
break;
77-
}
78-
}
79-
```
80-
81-
Alternatively, if you already know the image ID, you can do this much easier:
82-
83-
```php
84-
$ubuntu = $compute->image('868a0966-0553-42fe-b8b3-5cadc0e0b3c5');
85-
```
86-
87-
## 4. Select your flavor
88-
89-
There are different server specs - some which offer 1GB RAM, others which offer a much higher spec. The 'flavor' of an
90-
instance is its hardware configuration. So if you want a 2GB instance but don't know the ID, you have to traverse the list:
91-
92-
```php
93-
$flavors = $compute->flavorList();
94-
foreach ($flavors as $flavor) {
95-
if (strpos($flavor->name, '2GB') !== false) {
96-
$twoGbFlavor = $flavor;
97-
break;
98-
}
99-
}
100-
```
101-
102-
Again, it's much easier if you know the ID:
103-
104-
```php
105-
$twoGbFlavor = $compute->flavor('4');
106-
```
107-
108-
## 5. Thunderbirds are go!
109-
110-
Okay, you're ready to spin up a server:
111-
112-
```php
113-
$server = $compute->server();
114-
115-
try {
116-
$response = $server->create(array(
117-
'name' => 'My lovely server',
118-
'image' => $ubuntu,
119-
'flavor' => $twoGbFlavor
120-
));
121-
} catch (\Guzzle\Http\Exception\BadResponseException $e) {
122-
123-
// No! Something failed. Let's find out:
124-
125-
$responseBody = (string) $e->getResponse()->getBody();
126-
$statusCode = $e->getResponse()->getStatusCode();
127-
$headers = $e->getResponse()->getHeaderLines();
128-
129-
echo sprintf("Status: %s\nBody: %s\nHeaders: %s", $statusCode, $responseBody, implode(', ', $headers));
130-
}
131-
```
132-
133-
As you can see, you're creating a server called "My lovely server" - this will take a few minutes for the build to
134-
complete. You can always check the progress by logging into your Controller node and running:
135-
136-
`nova list`
137-
138-
You can also execute a polling function immediately after the `create` method that checks the build process:
139-
140-
```php
141-
use OpenCloud\Compute\Constants\ServerState;
142-
143-
$callback = function($server) {
144-
if (!empty($server->error)) {
145-
var_dump($server->error);
146-
exit;
147-
} else {
148-
echo sprintf(
149-
"Waiting on %s/%-12s %4s%%",
150-
$server->name(),
151-
$server->status(),
152-
isset($server->progress) ? $server->progress : 0
153-
);
154-
}
155-
};
156-
157-
$server->waitFor(ServerState::ACTIVE, 600, $callback);
158-
```
159-
So, the server will be polled until it is in an `ACTIVE` state, with a timeout of 600 seconds. When the poll happens, the
160-
callback function is executed - which in this case just logs some output.
161-
162-
# More fun with Nova
163-
164-
Once you've booted up your instance, you can use other API operations to monitor your Compute nodes. To list every
165-
node on record, you can execute:
166-
167-
```php
168-
$servers = $compute->serverList();
169-
170-
foreach ($servers as $server) {
171-
// do something with each server...
172-
echo $server->name, PHP_EOL;
173-
}
174-
```
175-
176-
or, if you know a particular instance ID you can retrieve its details:
177-
178-
```php
179-
$server = $compute->server('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx');
180-
```
181-
182-
allowing you to update its properties:
183-
184-
```php
185-
$server->update(array(
186-
'name' => 'New server name'
187-
));
188-
```
189-
190-
or delete it entirely:
191-
192-
```php
193-
$server->delete();
194-
```
195-
196-
# Next steps
197-
198-
Consult our [documentation](https://github.com/rackspace/php-opencloud/tree/master/docs/userguide) about other services
199-
you can use, like [Keystone](https://github.com/rackspace/php-opencloud/tree/master/docs/userguide/Identity) or
200-
[Swift](https://github.com/rackspace/php-opencloud/tree/master/docs/userguide/ObjectStore). If you have any questions or
201-
troubles, feel free to e-mail [email protected] or open a Github issue with details.
5+
https://doc.php-opencloud.com/en/latest/getting-started-with-openstack.html

0 commit comments

Comments
 (0)