Skip to content

Commit 66950e8

Browse files
committed
Updating samples
1 parent 277fe32 commit 66950e8

13 files changed

+106
-12
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => ['project' => ['id' => '{projectId}']]
13+
]);
14+
15+
$compute = $openstack->computeV2(['region' => '{region}']);
16+
17+
$flavor = $compute->createFlavor([
18+
'name' => '{flavorName}',
19+
'ram' => 128,
20+
'vcpus' => 1,
21+
'swap' => 0,
22+
'disk' => 1,
23+
]);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => ['project' => ['id' => '{projectId}']]
13+
]);
14+
15+
$compute = $openstack->computeV2(['region' => '{region}']);
16+
17+
18+
$flavor = $compute->getFlavor(['id' => '{flavorId}']);
19+
$flavor->delete();

samples/compute/v2/keypairs/create.php renamed to samples/compute/v2/keypairs/create_keypair.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
$compute = $openstack->computeV2(['region' => '{region}']);
1616

1717
$data = [
18-
'name' => 'created_by_api',
19-
'publicKey' => 'ssh-rsa AAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3NAAAAB3N'
18+
'name' => '{name}',
19+
'publicKey' => '{publicKey}'
2020
];
2121

2222
/** @var \OpenStack\Compute\v2\Models\Keypair $keypair */

samples/compute/v2/keypairs/delete.php renamed to samples/compute/v2/keypairs/delete_keypair.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
$compute = $openstack->computeV2(['region' => '{region}']);
1616

1717
/** @var \OpenStack\Compute\v2\Models\Keypair $keypair */
18-
$keypair = $compute->getKeypair(['name' => 'name_of_keypair']);
18+
$keypair = $compute->getKeypair(['name' => '{name}']);
1919

2020
$keypair->delete();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
$openstack = new OpenStack\OpenStack([
6+
'authUrl' => '{authUrl}',
7+
'region' => '{region}',
8+
'user' => [
9+
'id' => '{userId}',
10+
'password' => '{password}'
11+
],
12+
'scope' => ['project' => ['id' => '{projectId}']]
13+
]);
14+
15+
$compute = $openstack->computeV2(['region' => '{region}']);
16+
17+
/** @var \OpenStack\Compute\v2\Models\Keypair $keypair */
18+
$keypair = $compute->getKeypair(['name' => '{name}']);
19+
20+
$keypair->retrieve();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use OpenStack\Compute\v2\Models\Keypair;
4+
5+
require 'vendor/autoload.php';
6+
7+
$openstack = new OpenStack\OpenStack([
8+
'authUrl' => '{authUrl}',
9+
'region' => '{region}',
10+
'user' => [
11+
'id' => '{userId}',
12+
'password' => '{password}'
13+
],
14+
'scope' => ['project' => ['id' => '{projectId}']]
15+
]);
16+
17+
$compute = $openstack->computeV2(['region' => '{region}']);
18+
19+
$keypairs = $compute->listKeypairs();
20+
21+
foreach($keypairs as $keypair)
22+
{
23+
/**@var Keypair $keypair */
24+
}

samples/compute/v2/servers/add_security_group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
'id' => '{serverId}',
2020
]);
2121

22-
$server->addSecurityGroup(['name' => 'secgroup name']);
22+
$server->addSecurityGroup(['name' => '{secGroupName}']);

samples/compute/v2/servers/attach_volume_attachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
$compute = $openstack->computeV2(['region' => '{region}']);
2020

2121
/**@var OpenStack\Compute\v2\Models\Server $server */
22-
$server = $compute->getServer(['id' => 'uuid']);
22+
$server = $compute->getServer(['id' => '{serverId}']);
2323

2424
/**@var VolumeAttachment $volumeAttachment*/
25-
$volumeAttachment = $server->attachVolume('{volume_uuid}');
25+
$volumeAttachment = $server->attachVolume('{volumeId}');

samples/compute/v2/servers/create_server.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
'imageId' => '{imageId}',
2121
'flavorId' => '{flavorId}',
2222

23+
// Required if multiple network is defined
24+
'networks' => [
25+
['uuid' => '{networkId}']
26+
],
27+
2328
// Optional
2429
'metadata' => ['foo' => 'bar'],
2530
'userData' => base64_encode('echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt')

samples/compute/v2/servers/dettach_volume_attachment.php renamed to samples/compute/v2/servers/detach_volume_attachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
$compute = $openstack->computeV2(['region' => '{region}']);
2020

2121
/**@var OpenStack\Compute\v2\Models\Server $server */
22-
$server = $compute->getServer(['id' => 'uuid']);
22+
$server = $compute->getServer(['id' => '{serverId}']);
2323

2424
//Must detach by volumeAttachment id
25-
$server->detachVolume($volumeAttachment->id);
25+
$server->detachVolume('{volumeAttachmentId}');

0 commit comments

Comments
 (0)