Explorar el Código

merge thurdata & 3.4.0

andre hace 4 años
padre
commit
3b1bbeb0b1

+ 3 - 1
v2/models/AbstractVm.php

@@ -278,7 +278,9 @@ abstract class AbstractVm extends AbstractObject implements \MGProvision\Proxmox
         $data['storage']  = $storage;
         $data['remove']   = $routing;
         if(is_numeric($maxFiles)){
-            $data['maxfiles'] = (int) $maxFiles;
+            if((int) $maxFiles > 0){
+                $data['maxfiles'] = (int) $maxFiles;
+            }
         }
         if ($compress)
             $data['compress'] = $compress;

+ 3 - 2
v2/models/BackupSchedule.php

@@ -210,9 +210,10 @@ class BackupSchedule extends AbstractObject
             "starttime" => $this->getStarttime(),
         );
         if($this->getMaxfiles()){
-            $data['maxfiles'] = (int) $this->getMaxfiles();
+            if((int) $this->getMaxfiles() > 0){
+                $data['maxfiles'] = (int) $this->getMaxfiles();
+            }
         }
-
         if ($this->getStorage())
             $data['storage'] = $this->getStorage();
 

+ 1 - 1
v2/models/CloudInitDrive.php

@@ -74,7 +74,7 @@ class CloudInitDrive extends AbstractObject {
     }
 
     public function mount(){
-        return $this->api()->put($this->getPath(),[$this->id => "{$this->storage}:cloudinit" ]);
+        return $this->api()->put($this->getPath(),[$this->id => "{$this->storage}:cloudinit,format=raw" ]);
     }
 
 }

+ 1 - 1
v2/models/HardDisk.php

@@ -333,7 +333,7 @@ class HardDisk extends AbstractObject{
         $config = [];
         $config[] = $this->getStorage().":".$this->getSize();
         $fields=['cache','discard','media','replicate','format','backup','mbps_rd','mbps_rd_max',
-            'mbps_wr','mbps_wr_max','iops_rd','iops_rd_max','iops_wr','iops_wr_max', 'iothread'];
+            'mbps_wr','mbps_wr_max','iops_rd','iops_rd_max','iops_wr','iops_wr_max', 'iothread', 'ssd'];
         $this->toConfig($fields, $config);
         $prameters = implode(",", $config);
         return $this->api()->put($this->getPath(), [$this->getId()=>  $prameters]);

+ 26 - 0
v2/models/Kvm.php

@@ -264,6 +264,32 @@ class Kvm extends AbstractVm implements \MGProvision\Proxmox\v2\interfaces\KvmIn
         return $disks;
     }
 
+    /**
+     * @return HardDisk[]
+     */
+    public function getUnusedHardDisks()
+    {
+        $disks  = array();
+        $config = $this->config(true);
+        foreach ($config as $id => $value)
+        {
+            if (in_array($id, ['hotplug','agent']))
+            {
+                continue;
+            }
+            if(!preg_match("/unused/", $id)){
+                continue;
+            }
+            if (!preg_match('/disk/', $value))
+            {
+                continue;
+            }
+            $hdd = (new HardDisk($id, $value))->setPath("/nodes/{$this->node}/qemu/{$this->vmid}/config");
+            $disks[] = $hdd;
+        }
+        return $disks;
+    }
+
     /**
      * 
      * @return HardDisk

+ 4 - 0
v2/models/Snapshot.php

@@ -104,6 +104,10 @@ class Snapshot extends AbstractObject
         return $this;
     }
 
+    public function getPath() {
+        return $this->path;
+    }
+        
     public function create()
     {