1 | <?php |
||
28 | class Openstack implements Simulator |
||
29 | { |
||
30 | use Clearable; |
||
31 | |||
32 | /** |
||
33 | * OpenStack identify url |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $authUrl; |
||
38 | |||
39 | /** |
||
40 | * OpenStack region |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $region; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $username; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $password; |
||
55 | |||
56 | /** |
||
57 | * Object Store container name |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $containerName; |
||
62 | |||
63 | /** |
||
64 | * OpenStack service name |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $serviceName; |
||
69 | |||
70 | /** |
||
71 | * Max stream upload size, files over this size have to be uploaded as Dynamic Large Objects |
||
72 | * |
||
73 | * @var int |
||
74 | */ |
||
75 | protected $maxStreamUploadSize = 5368709120; |
||
76 | |||
77 | /** |
||
78 | * Path where to copy the backup without leading or trailing slashes. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $path = ''; |
||
83 | |||
84 | /** |
||
85 | * Path where to copy the backup still containing possible date placeholders. |
||
86 | * |
||
87 | * @var string |
||
88 | */ |
||
89 | protected $pathRaw = ''; |
||
90 | |||
91 | /** |
||
92 | * @var Container |
||
93 | */ |
||
94 | protected $container; |
||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getPath(): string |
||
103 | |||
104 | /** |
||
105 | * (non-PHPDoc) |
||
106 | * |
||
107 | * @see \phpbu\App\Backup\Sync::setup() |
||
108 | * @param array $config |
||
109 | * @throws \phpbu\App\Backup\Sync\Exception |
||
110 | * @throws \phpbu\App\Exception |
||
111 | */ |
||
112 | 9 | public function setup(array $config) |
|
136 | |||
137 | /** |
||
138 | * Make sure all mandatory keys are present in given config. |
||
139 | * |
||
140 | * @param array $config |
||
141 | * @param array $keys |
||
142 | * @throws Exception |
||
143 | */ |
||
144 | 9 | protected function validateConfig(array $config, array $keys) |
|
152 | |||
153 | /** |
||
154 | * Execute the sync. |
||
155 | * |
||
156 | * @see \phpbu\App\Backup\Sync::sync() |
||
157 | * @param \phpbu\App\Backup\Target $target |
||
158 | * @param \phpbu\App\Result $result |
||
159 | * @throws \phpbu\App\Backup\Sync\Exception |
||
160 | * @throws \OpenStack\Common\Error\BadResponseError |
||
161 | */ |
||
162 | public function sync(Target $target, Result $result) |
||
191 | |||
192 | /** |
||
193 | * Simulate the sync execution. |
||
194 | * |
||
195 | * @param \phpbu\App\Backup\Target $target |
||
196 | * @param \phpbu\App\Result $result |
||
197 | */ |
||
198 | 1 | public function simulate(Target $target, Result $result) |
|
211 | |||
212 | /** |
||
213 | * Creates collector for OpenStack. |
||
214 | * |
||
215 | * @param \phpbu\App\Backup\Target $target |
||
216 | * @return \phpbu\App\Backup\Collector |
||
217 | */ |
||
218 | protected function createCollector(Target $target): Collector |
||
222 | |||
223 | /** |
||
224 | * @param \OpenStack\ObjectStore\v1\Service $service |
||
225 | * @param \phpbu\App\Result $result |
||
226 | * @return \OpenStack\ObjectStore\v1\Models\Container |
||
227 | * @throws \OpenStack\Common\Error\BadResponseError |
||
228 | */ |
||
229 | protected function getOrCreateContainer(ObjectStoreService $service, Result $result) |
||
237 | |||
238 | /** |
||
239 | * Get the upload path |
||
240 | * |
||
241 | * @param \phpbu\App\Backup\Target $target |
||
242 | * @return string |
||
243 | */ |
||
244 | 2 | public function getUploadPath(Target $target) |
|
248 | |||
249 | /** |
||
250 | * @param \phpbu\App\Result $result |
||
251 | * @return void |
||
252 | * @throws \OpenStack\Common\Error\BadResponseError |
||
253 | */ |
||
254 | protected function connect(Result $result) |
||
273 | } |
||
274 |