| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- /* * ********************************************************************
- * proxmoxCloud product developed. (2017-01-20)
- * *
- *
- * 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\models;
- use MGProvision\Proxmox\v2 as proxmox;
- /**
- * Description of Snapshot
- *
- * @author Pawel Kopec <pawelk@modulesgarden.com>
- * @version 1.0.0
- * @deprecated 2.7.0
- */
- class SnapshotKvm extends AbstractObject
- {
- private $path;
- protected $name;
- protected $description;
- protected $snaptime;
- protected $parent;
- protected $vmstate;
- public function getName()
- {
- return $this->name;
- }
- public function getDescription()
- {
- return $this->description;
- }
- public function getSnaptime()
- {
- return $this->snaptime;
- }
- public function getParent()
- {
- return $this->parent;
- }
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- public function setDescription($description)
- {
- $this->description = $description;
- return $this;
- }
- public function setSnaptime($snaptime)
- {
- $this->snaptime = $snaptime;
- return $this;
- }
- public function setParent($parent)
- {
- $this->parent = $parent;
- return $this;
- }
- public function getVmstate()
- {
- return $this->vmstate;
- }
- public function setVmstate($vmstate)
- {
- $this->vmstate = $vmstate;
- return $this;
- }
- public function setPath($path)
- {
- if (!preg_match('/\/snapshot/', $path))
- {
- throw new proxmox\ProxmoxApiException(sprintf("Snapshot Path ('%s') is not valid", $path));
- }
- $this->path = $path;
- return $this;
- }
- public function create()
- {
- if (empty($this->path))
- throw new proxmox\ProxmoxApiException('Snapshot [path] - property is missing and it is not optional');
- $request = array(
- "snapname" => $this->getName(),
- "description" => $this->getDescription(),
- "vmstate" => $this->getVmstate()
- );
- return $this->api()->post($this->path, $request);
- }
- public function update()
- {
- if (empty($this->path))
- throw new proxmox\ProxmoxApiException('Snapshot [path] - property is missing and it is not optional');
- return $this->api()->put($this->path . "/config", array("description" => $this->getDescription()));
- }
- public function rollback()
- {
- if (empty($this->path))
- throw new proxmox\ProxmoxApiException('Snapshot [path] - property is missing and it is not optional');
- return $this->api()->post($this->path . '/rollback');
- }
- public function delete()
- {
- if (empty($this->path))
- throw new proxmox\ProxmoxApiException('Snapshot [path] - property is missing and it is not optional');
- return $this->api()->delete($this->path);
- }
- public function getAttributes()
- {
- return array(
- "name" => $this->getName(),
- "date" => date("Y:m:d H:i:s", $this->snaptime),
- "description" => $this->getDescription(),
- "snaptime" => $this->getSnaptime(),
- "parent" => $this->getParent(),
- "vmstate" => $this->getVmstate(),
- );
- }
- }
|