| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS product developed. (2016-11-14)
- * *
- *
- * CREATED BY MODULESGARDEN -> 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 <pawelk@modulesgarden.com>
- * @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;
- }
- }
|