http://modulesgarden.com * CONTACT -> contact@modulesgarden.com * * * This software is furnished under a license and may be used and copied * only in accordance with the terms of such license and with the * inclusion of the above copyright notice. This software or any other * copies thereof may not be provided or otherwise made available to any * other person. No title to and ownership of the software is hereby * transferred. * * * ******************************************************************** */ namespace MGProvision\Proxmox\v2\repository; /** * Description of HaResource * * @author Pawel Kopec * @version 1.0.0 */ class HaResourceRepository extends AbstractRepository { private $type; public function findVm() { $this->type = "vm"; } public function findCt() { $this->type = "ct"; } public function findVirtualization($virtualization) { switch (strtolower($virtualization)) { case "lxc": $this->type = "ct"; break; case "qemu": case "kvm": $this->type = "vm"; break; default: throw new \Exception('Unknown virtualization type: ' . $virtualization); } return $this; } /** * * @return \MGProvision\Proxmox\v2\models\HaResource[] */ public function fetch() { $parameters = array(); if ($this->type) $parameters['type'] = $this->type; $resources = $this->api()->get("/cluster/ha/resources", $parameters); $data = array(); foreach ($resources as $resource) { $entity = new \MGProvision\Proxmox\v2\models\HaResource($resource['sid']); $entity->setAttributes($resource); $data[] = $entity; } unset($resources, $entity); return $data; } }