Skip to content

Commit

Permalink
clone VM's to target storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Dec 15, 2023
1 parent 5ff2abe commit 157a306
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions app/Repositories/Proxmox/Server/ProxmoxServerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public function getState()
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'server' => $this->server->vmid,
])
->get('/api2/json/nodes/{node}/qemu/{server}/status/current')
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'server' => $this->server->vmid,
])
->get('/api2/json/nodes/{node}/qemu/{server}/status/current')
->json();

return ServerStateData::fromRaw($this->getData($response));
}
Expand All @@ -35,16 +35,17 @@ public function create(Template $template)
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'template' => $template->vmid,
])
->post('/api2/json/nodes/{node}/qemu/{template}/clone', [
'target' => $this->node->cluster,
'newid' => $this->server->vmid,
'full' => true,
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'template' => $template->vmid,
])
->post('/api2/json/nodes/{node}/qemu/{template}/clone', [
'storage' => $this->node->vm_storage,
'target' => $this->node->cluster,
'newid' => $this->server->vmid,
'full' => true,
])
->json();

return $this->getData($response);
}
Expand All @@ -59,12 +60,12 @@ public function delete()
'purge' => true,
],
])
->withUrlParameters([
'node' => $this->node->cluster,
'server' => $this->server->vmid,
])
->delete('/api2/json/nodes/{node}/qemu/{server}')
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'server' => $this->server->vmid,
])
->delete('/api2/json/nodes/{node}/qemu/{server}')
->json();

return $this->getData($response);
}
Expand All @@ -74,12 +75,12 @@ public function addUser(RealmType $realmType, string $userId, string $roleId)
Assert::isInstanceOf($this->server, Server::class);

$response = $this->getHttpClient()
->put('/api2/json/access/acl', [
'path' => '/vms/'.$this->server->vmid,
'users' => $userId.'@'.$realmType->value,
'roles' => $roleId,
])
->json();
->put('/api2/json/access/acl', [
'path' => '/vms/' . $this->server->vmid,
'users' => $userId . '@' . $realmType->value,
'roles' => $roleId,
])
->json();

return $this->getData($response);
}
Expand Down

0 comments on commit 157a306

Please sign in to comment.