Skip to content

Commit 40da3f1

Browse files
author
Jamie Hannaford
committed
Merge pull request #50 from haphan/master
[rfr] SSH Keys, Flavor, Add/remove SecGroup, Attach/Detach Volume
2 parents 3eb2800 + 8fa7be4 commit 40da3f1

Some content is hidden

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

47 files changed

+1626
-34
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();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use OpenStack\Compute\v2\Models\HypervisorStatistic;
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+
/** @var HypervisorStatistic $hypervisorStatistics */
20+
$hypervisorStatistics = $compute->getHypervisorStatistics();
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+
$data = [
18+
'name' => '{name}',
19+
'publicKey' => '{publicKey}'
20+
];
21+
22+
/** @var \OpenStack\Compute\v2\Models\Keypair $keypair */
23+
$keypair = $compute->createKeypair($data);
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->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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
/**@var Keypair $keypair */
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\Limit $limit */
18+
$limit = $compute->getLimits();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\Server $server */
18+
$server = $compute->getServer([
19+
'id' => '{serverId}',
20+
]);
21+
22+
$server->addSecurityGroup(['name' => '{secGroupName}']);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use OpenStack\BlockStorage\v2\Models\VolumeAttachment;
4+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup;
5+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroupRule;
6+
7+
require 'vendor/autoload.php';
8+
9+
$openstack = new OpenStack\OpenStack([
10+
'authUrl' => '{authUrl}',
11+
'region' => '{region}',
12+
'user' => [
13+
'id' => '{userId}',
14+
'password' => '{password}'
15+
],
16+
'scope' => ['project' => ['id' => '{projectId}']]
17+
]);
18+
19+
$compute = $openstack->computeV2(['region' => '{region}']);
20+
21+
/**@var OpenStack\Compute\v2\Models\Server $server */
22+
$server = $compute->getServer(['id' => '{serverId}']);
23+
24+
/**@var VolumeAttachment $volumeAttachment*/
25+
$volumeAttachment = $server->attachVolume('{volumeId}');

0 commit comments

Comments
 (0)