|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OpenStack; |
|
4
|
|
|
|
|
5
|
|
|
use OpenStack\Common\Service\Builder; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* This class is the primary entry point for working with the SDK. It allows for the easy creation |
|
9
|
|
|
* of OpenStack services. |
|
10
|
|
|
* |
|
11
|
|
|
* @package OpenStack |
|
12
|
|
|
*/ |
|
13
|
|
|
class OpenStack |
|
14
|
|
|
{ |
|
15
|
|
|
/** @var Builder */ |
|
16
|
|
|
private $builder; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param array $options User-defined options |
|
20
|
|
|
* |
|
21
|
|
|
* $options['username'] = (string) Your OpenStack username [REQUIRED] |
|
22
|
|
|
* ['password'] = (string) Your OpenStack password [REQUIRED] |
|
23
|
|
|
* ['tenantId'] = (string) Your tenant ID [REQUIRED if tenantName omitted] |
|
24
|
|
|
* ['tenantName'] = (string) Your tenant name [REQUIRED if tenantId omitted] |
|
25
|
|
|
* ['authUrl'] = (string) The Keystone URL [REQUIRED] |
|
26
|
|
|
* ['debug'] = (bool) Whether to enable HTTP logging [OPTIONAL] |
|
27
|
|
|
*/ |
|
28
|
6 |
|
public function __construct(array $options = [], Builder $builder = null) |
|
29
|
|
|
{ |
|
30
|
6 |
|
$this->builder = $builder ?: new Builder($options); |
|
31
|
6 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Creates a new Compute v2 service. |
|
35
|
|
|
* |
|
36
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
37
|
|
|
* |
|
38
|
|
|
* @return \OpenStack\Compute\v2\Service |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function computeV2(array $options = []) |
|
41
|
|
|
{ |
|
42
|
1 |
|
$defaults = ['catalogName' => 'nova', 'catalogType' => 'compute']; |
|
43
|
1 |
|
return $this->builder->createService('Compute', 2, array_merge($defaults, $options)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Creates a new Networking v2 service. |
|
48
|
|
|
* |
|
49
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
50
|
|
|
* |
|
51
|
|
|
* @return \OpenStack\Networking\v2\Service |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function networkingV2(array $options = []) |
|
54
|
|
|
{ |
|
55
|
1 |
|
$defaults = ['catalogName' => 'neutron', 'catalogType' => 'network']; |
|
56
|
1 |
|
return $this->builder->createService('Networking', 2, array_merge($defaults, $options)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Creates a new Identity v2 service. |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
63
|
|
|
* |
|
64
|
|
|
* @return \OpenStack\Identity\v2\Service |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function identityV2(array $options = []) |
|
67
|
|
|
{ |
|
68
|
1 |
|
$defaults = ['catalogName' => false, 'catalogType' => false]; |
|
69
|
1 |
|
return $this->builder->createService('Identity', 2, array_merge($defaults, $options)); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Creates a new Identity v3 service. |
|
74
|
|
|
* |
|
75
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
76
|
|
|
* |
|
77
|
|
|
* @return \OpenStack\Identity\v3\Service |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function identityV3(array $options = []) |
|
80
|
|
|
{ |
|
81
|
1 |
|
$defaults = ['catalogName' => false, 'catalogType' => false]; |
|
82
|
1 |
|
return $this->builder->createService('Identity', 3, array_merge($defaults, $options)); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Creates a new Object Store v1 service. |
|
87
|
|
|
* |
|
88
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
89
|
|
|
* |
|
90
|
|
|
* @return \OpenStack\ObjectStore\v1\Service |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function objectStoreV1(array $options = []) |
|
93
|
|
|
{ |
|
94
|
1 |
|
$defaults = ['catalogName' => 'swift', 'catalogType' => 'object-store']; |
|
95
|
1 |
|
return $this->builder->createService('ObjectStore', 1, array_merge($defaults, $options)); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Creates a new Block Storage v2 service. |
|
100
|
|
|
* |
|
101
|
|
|
* @param array $options Options that will be used in configuring the service. |
|
102
|
|
|
* |
|
103
|
|
|
* @return \OpenStack\BlockStorage\v2\Service |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function blockStorageV2(array $options = []) |
|
106
|
|
|
{ |
|
107
|
1 |
|
$defaults = ['catalogName' => 'cinderv2', 'catalogType' => 'volumev2']; |
|
108
|
1 |
|
return $this->builder->createService('BlockStorage', 2, array_merge($defaults, $options)); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|