| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS product developed. (2016-11-15)
- * *
- *
- * 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;
- /**
- * Description of Task
- *
- * @author Pawel Kopec <pawelk@modulesgarden.com>
- * @version 1.0.0
- */
- class Task extends AbstractObject
- {
- protected $starttime;
- protected $pstart;
- protected $id;
- protected $exitstatus;
- protected $pid;
- protected $user;
- protected $node;
- protected $upid;
- protected $type;
- protected $status;
- protected $endtime;
- private $path;
- public function getStarttime()
- {
- return $this->starttime;
- }
- public function getPstart()
- {
- return $this->pstart;
- }
- public function getId()
- {
- return $this->id;
- }
- public function getExitstatus()
- {
- return $this->exitstatus;
- }
- public function getPid()
- {
- return $this->pid;
- }
- public function getUser()
- {
- return $this->user;
- }
- public function getNode()
- {
- return $this->node;
- }
- public function getUpid()
- {
- return $this->upid;
- }
- public function getType()
- {
- return $this->type;
- }
- public function getStatus()
- {
- return $this->status;
- }
- public function isRunning()
- {
- return $this->status === "running";
- }
- public function isFalied()
- {
- return $this->exitstatus && $this->exitstatus !== "OK";
- }
- public function isDone()
- {
- return $this->exitstatus === "OK";
- }
- public function setStarttime($starttime)
- {
- $this->starttime = $starttime;
- return $this;
- }
- public function setPstart($pstart)
- {
- $this->pstart = $pstart;
- return $this;
- }
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- public function setExitstatus($exitstatus)
- {
- $this->exitstatus = $exitstatus;
- return $this;
- }
- public function setPid($pid)
- {
- $this->pid = $pid;
- return $this;
- }
- public function setUser($user)
- {
- $this->user = $user;
- return $this;
- }
- public function setNode($node)
- {
- $this->node = $node;
- return $this;
- }
- public function setUpid($upid)
- {
- $this->upid = $upid;
- return $this;
- }
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
- public function setStatus($status)
- {
- $this->status = $status;
- return $this;
- }
- public function getEndtime()
- {
- return $this->endtime;
- }
- public function setEndtime($endtime)
- {
- $this->endtime = $endtime;
- return $this;
- }
- public function getStartDate()
- {
- return date('Y-m-d H:i:s', $this->starttime);
- }
- public function getEndDate()
- {
- return date('Y-m-d H:i:s', $this->endtime);
- }
- public function setPath($path)
- {
- if (!preg_match('/\/tasks\//', $path))
- {
- throw new proxmox\ProxmoxApiException(sprintf("Task Path ('%s') is not valid", $path));
- }
- $this->path = $path;
- }
- public function delete()
- {
- if (empty($this->path))
- throw new proxmox\ProxmoxApiException('Task [path] - property is missing and it is not optional');
- return $this->api()->delete($this->path);
- }
- public function description()
- {
- return ucwords(str_replace(array("vz", "qm"), array("VM {$this->getId()} - ", "CT {$this->getId()} - "), $this->getType()));
- }
- public function getAttributes(){
- return [
- "id" => $this->getId(),
- "starttime" => $this->getStarttime(),
- "endtime" => $this->getEndtime(),
- "pstart" => $this->getPstart(),
- "exitstatus" => $this->getExitstatus(),
- "pid" => $this->getPid(),
- "node" => $this->getNode(),
- "upid"=> $this->getUpid(),
- "type" => $this->getType(),
- "status" => $this->getStatus(),
- ];
- }
- }
|