|
|
@@ -28,8 +28,7 @@ use MGProvision\Proxmox\v2 as proxmox;
|
|
|
* @author Pawel Kopec <pawelk@modulesgarden.com>
|
|
|
* @version 1.0.0
|
|
|
*/
|
|
|
-class Snapshot extends AbstractObject
|
|
|
-{
|
|
|
+class Snapshot extends AbstractObject {
|
|
|
private $path;
|
|
|
protected $name;
|
|
|
protected $description;
|
|
|
@@ -37,78 +36,71 @@ class Snapshot extends AbstractObject
|
|
|
protected $parent;
|
|
|
protected $vmstate;
|
|
|
|
|
|
- public function getName()
|
|
|
- {
|
|
|
+ public function getName(){
|
|
|
return $this->name;
|
|
|
}
|
|
|
|
|
|
- public function getDescription()
|
|
|
- {
|
|
|
+ public function getDescription() {
|
|
|
return $this->description;
|
|
|
}
|
|
|
|
|
|
- public function getSnaptime()
|
|
|
- {
|
|
|
+ public function getSnaptime() {
|
|
|
return $this->snaptime;
|
|
|
}
|
|
|
|
|
|
- public function getParent()
|
|
|
- {
|
|
|
+ public function getParent() {
|
|
|
return $this->parent;
|
|
|
}
|
|
|
|
|
|
- public function setName($name)
|
|
|
- {
|
|
|
+ public function setName($name) {
|
|
|
$this->name = $name;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function setDescription($description)
|
|
|
- {
|
|
|
+ public function setDescription($description) {
|
|
|
$this->description = $description;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function setSnaptime($snaptime)
|
|
|
- {
|
|
|
+ public function setSnaptime($snaptime) {
|
|
|
$this->snaptime = $snaptime;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function setParent($parent)
|
|
|
- {
|
|
|
+ public function setParent($parent) {
|
|
|
$this->parent = $parent;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getVmstate()
|
|
|
- {
|
|
|
+ public function getVmstate() {
|
|
|
return $this->vmstate;
|
|
|
}
|
|
|
|
|
|
- public function setVmstate($vmstate)
|
|
|
- {
|
|
|
+ public function setVmstate($vmstate) {
|
|
|
$this->vmstate = $vmstate;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function setPath($path)
|
|
|
- {
|
|
|
+ public function setPath($path) {
|
|
|
|
|
|
- if (!preg_match('/\/snapshot/', $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 getPath() {
|
|
|
+ return $this->path;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- public function create()
|
|
|
- {
|
|
|
+ public function create() {
|
|
|
|
|
|
- if (empty($this->path))
|
|
|
+ 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(),
|
|
|
@@ -119,32 +111,28 @@ class Snapshot extends AbstractObject
|
|
|
return $this->api()->post($this->path, $request);
|
|
|
}
|
|
|
|
|
|
- public function update()
|
|
|
- {
|
|
|
-
|
|
|
- if (empty($this->path))
|
|
|
+ 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))
|
|
|
+ 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))
|
|
|
+ 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()
|
|
|
- {
|
|
|
+ public function getAttributes() {
|
|
|
|
|
|
return array(
|
|
|
"name" => $this->getName(),
|