Skip to content

Commit 3dd64ec

Browse files
committed
Added support for using container snapshot as source for migration
1 parent 3a7d413 commit 3dd64ec

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All Notable changes to `php-lxd` will be documented in this file.
44

55
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
66

7+
## [0.12.2]
8+
9+
## Added
10+
- Support for using container snapshot as source for migration
11+
712
## [0.12.1]
813

914
### Added

src/Endpoint/Containers.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,26 @@ public function migrate(
367367
*/
368368
public function initMigration($name)
369369
{
370-
$migration = $this->post($this->getEndpoint().$name, ['migration' => true]);
370+
$containerName = "";
371+
372+
if (strpos($name, "/") !== false) {
373+
$parts = explode("/", $name);
374+
$partsLength = count($parts);
375+
if ($partsLength == 0 || $partsLength > 2) {
376+
throw new \Exception("Snapshot name format not correct", 1);
377+
}
378+
$containerName = $parts[0];
379+
$container = $this->snapshots->info($containerName, $parts[1]);
380+
} else {
381+
$containerName = $name;
382+
$container = $this->info($name);
383+
}
384+
385+
$migration = $this->post($this->getEndpoint().$containerName, ['migration' => true]);
386+
371387
$host = $this->client->host->info();
372-
$container = $this->info($name);
373-
$url = $this->client->getUrl().'/'.$this->client->getApiVersion().'/operations/'.$migration['id'];
374388

389+
$url = $this->client->getUrl().'/'.$this->client->getApiVersion().'/operations/'.$migration['id'];
375390

376391
$settings = [
377392
'name' => $name,

0 commit comments

Comments
 (0)