Skip to content

Commit

Permalink
Add new name param on container migrate & fix empty device bug (close #7
Browse files Browse the repository at this point in the history
, #6)
  • Loading branch information
turtle0x1 committed Jan 6, 2019
1 parent b0bdc02 commit 96fbcf1
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Endpoint/Containers.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,17 @@ public function copy($name, $copyName, array $options = [], $wait = false)
* @param bool $wait Wait for operation to finish
* @return object
*/
public function migrate(\Opensaucesystems\Lxd\Client $destination, $name, $wait = false)
{
return $destination->containers->create($name, $this->initMigration($name), $wait);
public function migrate(
\Opensaucesystems\Lxd\Client $destination,
$name,
string $newName = "",
$wait = false
) {
if (empty($newName)) {
$newName = $name;
}

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

/**
Expand All @@ -364,11 +372,11 @@ public function initMigration($name)
$container = $this->info($name);
$url = $this->client->getUrl().'/'.$this->client->getApiVersion().'/operations/'.$migration['id'];

return [

$settings = [
'name' => $name,
'architecture' => $container['architecture'],
'config' => $container['config'],
'devices' => $container['devices'],
'epehemeral' => $container['ephemeral'],
'profiles' => $container['profiles'],
'source' => [
Expand All @@ -379,6 +387,12 @@ public function initMigration($name)
'secrets' => $migration['metadata'],
]
];

if (!empty($container["devices"])) {
$settings["devices"] = $container["devices"];
}

return $settings;
}

/**
Expand Down

0 comments on commit 96fbcf1

Please sign in to comment.