Bladeren bron

roland snapshot handling

root 4 jaren geleden
bovenliggende
commit
760c27759d
4 gewijzigde bestanden met toevoegingen van 15 en 30 verwijderingen
  1. 6 12
      v2/AbstractApi.php
  2. 2 4
      v2/models/AbstractVm.php
  3. 6 13
      v2/models/SnapshotKvm.php
  4. 1 1
      v2/repository/SnapshotRepository.php

+ 6 - 12
v2/AbstractApi.php

@@ -361,10 +361,8 @@ abstract class AbstractApi
         unset($prox_ch);
 
         // ModulesGarden
-        if ($this->whmcsDebugMode)
-        {
-            if (function_exists('logModuleCall'))
-            {
+        if ($this->whmcsDebugMode)     {
+            if (function_exists('logModuleCall'))   {
                 logModuleCall(
                         "proxmoxVPS", $action_path, $http_method . " https://{$this->pve_hostname}:{$this->port}/api2/json" . $action_path . "\n" . print_r($put_post_parameters, true), '', sprintf("HTTP %s %s",$this->httpCode, $action_response), array($this->pve_username, $this->pve_password)
                 );
@@ -577,18 +575,14 @@ abstract class AbstractApi
      * @param string $action_path
      * @return boolean | array
      */
-    public function delete($action_path)
-    {
-        if (!$this->constructor_success)
-        {
+    public function delete($action_path)   {
+        if (!$this->constructor_success)  {
             return false;
         }
 
         # We run this if we haven't queried for cluster nodes as yet, and cache it in the object.
-        if ($this->pve_cluster_node_list == null)
-        {
-            if ($this->reload_node_list() === false)
-            {
+        if ($this->pve_cluster_node_list == null)     {
+            if ($this->reload_node_list() === false)  {
                 return false;
             }
         }

+ 2 - 4
v2/models/AbstractVm.php

@@ -128,8 +128,7 @@ abstract class AbstractVm extends AbstractObject implements \MGProvision\Proxmox
         return $this->api()->delete("/nodes/{$this->node}/{$this->getVirtualization()}/{$this->vmid}");
     }
 
-    public function restart()
-    {
+    public function restart()  {
 
         $status = $this->status(true);
         if ($status['status'] == "running")
@@ -150,8 +149,7 @@ abstract class AbstractVm extends AbstractObject implements \MGProvision\Proxmox
         return $this->start();
     }
 
-    public function getVmid()
-    {
+    public function getVmid()  {
         return $this->vmid;
     }
 

+ 6 - 13
v2/models/SnapshotKvm.php

@@ -96,8 +96,7 @@ class SnapshotKvm extends AbstractObject
     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));
         }
 
@@ -105,8 +104,7 @@ class SnapshotKvm extends AbstractObject
         return $this;
     }
 
-    public function create()
-    {
+    public function create() {
 
         if (empty($this->path))
             throw new proxmox\ProxmoxApiException('Snapshot [path] - property is missing and it is not optional');
@@ -119,32 +117,27 @@ class SnapshotKvm extends AbstractObject
         return $this->api()->post($this->path, $request);
     }
 
-    public function update()
-    {
+    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()
-    {
+    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()
-    {
-
+    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(),

+ 1 - 1
v2/repository/SnapshotRepository.php

@@ -96,7 +96,7 @@ class SnapshotRepository extends AbstractRepository
             $temp = $this->api()->get($path);
 
             foreach ($temp as $snap)   {
-                $entityObj     = new Snapshot();
+                $entityObj  = new Snapshot();
                 $entityObj->setAttributes($snap);
                 $entityObj->setPath(sprintf("{$path}/%s", $snap['name']));
                 if ($this->ignoreCurrent && $snap['name'] == "current")  {