Skip to content

Commit 931da64

Browse files
committed
Fixed bug with migrating container snapshots to another host (close #)
1 parent 3dd64ec commit 931da64

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-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.3]
8+
9+
## Fixed
10+
- Migrating snapshot of runnin container (#9)
11+
712
## [0.12.2]
813

914
## Added

src/Endpoint/Containers.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function migrate(
356356
$newName = $name;
357357
}
358358

359-
return $destination->containers->create($newName, $this->initMigration($name), $wait);
359+
return $destination->containers->create($newName, $this->initMigration($name, $newName), $wait);
360360
}
361361

362362
/**
@@ -365,7 +365,7 @@ public function migrate(
365365
* @param string $name Name of existing container
366366
* @return array
367367
*/
368-
public function initMigration($name)
368+
public function initMigration($name, $newName)
369369
{
370370
$containerName = "";
371371

@@ -377,12 +377,19 @@ public function initMigration($name)
377377
}
378378
$containerName = $parts[0];
379379
$container = $this->snapshots->info($containerName, $parts[1]);
380+
$containerName = $parts[0] . "/snapshots/". $parts[1];
380381
} else {
381382
$containerName = $name;
382383
$container = $this->info($name);
383384
}
384385

385-
$migration = $this->post($this->getEndpoint().$containerName, ['migration' => true]);
386+
387+
388+
$migration = $this->post($this->getEndpoint().$containerName, [
389+
'name'=>$newName,
390+
'migration' => true,
391+
'stateful'=>false
392+
]);
386393

387394
$host = $this->client->host->info();
388395

0 commit comments

Comments
 (0)