| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Services\Cloud;
- use MGProvision\Proxmox\v2\models\HaResource;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
- use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
- class HighAvailabilityClusterService
- {
- use ProductService;
- use ApiService;
- use WhmcsParams;
- public function delete()
- {
- $haResurce = new HaResource();
- $haResurce->setSid(sl('Vm')->getVm()->getVmid())
- ->setType(sl('Vm')->getVm()->getVirtualization() == "lxc" ? "ct" : "vm");
- $haResurce->setApi($this->api());
- if ($haResurce->exist())
- {
- $haResurce->delete();
- }
- return $this;
- }
- public function create()
- {
- $haResurce = new HaResource();
- $haResurce->setSid(sl('Vm')->getVm()->getVmid())
- ->setState($this->configuration()->getClusterState())
- ->setType(sl('Vm')->getVm()->getVirtualization() == "lxc" ? "ct" : "vm")
- ->setGroup($this->configuration()->getClusterGroup())
- ->setMaxRelocate($this->configuration()->getClusterMaxRelocate())
- ->setMaxRestart($this->configuration()->getClusterMaxRestart())
- ->create();
- }
- public function exist(){
- $haResurce = new HaResource();
- $haResurce->setSid(sl('Vm')->getVm()->getVmid())
- ->setType(sl('Vm')->getVm()->getVirtualization() == "lxc" ? "ct" : "vm");
- $haResurce->setApi($this->api());
- return $haResurce->exist();
- }
- public function isConfigured(){
- return $this->configuration()->getClusterState() &&
- is_numeric($this->configuration()->getClusterMaxRelocate()) &&
- is_numeric($this->configuration()->getClusterMaxRestart());
- }
- }
|