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()); } }