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