Skip to content

Commit 5b5d0d9

Browse files
committed
Add samples for security group and security group rule
1 parent b8669e3 commit 5b5d0d9

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup;
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' => [
15+
'project' => [
16+
'id' => '{projectId}'
17+
]
18+
]
19+
]);
20+
21+
$networkingExtSecGroup = $openstack->networkingV2ExtSecGroups();
22+
23+
/** @var SecurityGroup $securityGroup */
24+
$securityGroup = $networkingExtSecGroup->createSecurityGroupRule([
25+
'name' => 'New SecGroup',
26+
'description' => 'Foo Barrr'
27+
]);
28+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup;
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' => [
15+
'project' => [
16+
'id' => '{projectId}'
17+
]
18+
]
19+
]);
20+
21+
$networkingExtSecGroup = $openstack->networkingV2ExtSecGroups();
22+
23+
/** @var SecurityGroup $securityGroup */
24+
$securityGroup = $networkingExtSecGroup->createSecurityGroupRule([
25+
'direction' => 'ingress', //ingress or egress
26+
'protocol' => 'tcp', //tcp, udp, icmp
27+
'securityGroupId' => '{securityGroupUUID}',
28+
'portRangeMin' => '123',
29+
'portRangeMax' => '456',
30+
'remoteIpPrefix' => '10.0.0.0/24', //Optional
31+
//'remoteGroupId' => '{remoteSecurityGroupId}'
32+
]);
33+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use OpenStack\Networking\v2\Extensions\SecurityGroups\Models\SecurityGroup;
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' => [
15+
'project' => [
16+
'id' => '{projectId}'
17+
]
18+
]
19+
]);
20+
21+
$networkingExtSecGroup = $openstack->networkingV2ExtSecGroups();
22+
23+
$securityGroup = $networkingExtSecGroup->getSecurityGroup('{id}');
24+
$securityGroup->delete();
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' => [
13+
'project' => [
14+
'id' => '{projectId}'
15+
]
16+
]
17+
]);
18+
19+
$networkingExtSecGroup = $openstack->networkingV2ExtSecGroups();
20+
21+
$secRule = $networkingExtSecGroup->getSecurityGroupRule('{uuid}');
22+
$secRule->delete();

0 commit comments

Comments
 (0)