Parcourir la source

disable cpu downgrade on running VM

andre il y a 4 ans
Parent
commit
9e4d9af53b
1 fichiers modifiés avec 18 ajouts et 3 suppressions
  1. 18 3
      app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

+ 18 - 3
app/UI/VmUpdate/Sections/Qemu/GeneralSection.php

@@ -93,9 +93,24 @@ class GeneralSection extends BaseSection
         }
         //vcpus
         if($this->configuration()->isPermissionVcpus() || $this->configuration()->isCalculateSocketsAndCores()){
-            $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
-            $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
-            $field->setDescription('description');
+
+            logModuleCall(
+                'proxmoxCloud',
+                __FUNCTION__,
+                $vm->config(),
+                'Debug',
+                $this->configuration()
+            );
+
+            if(!$vm->isRunning()) {
+                $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
+                $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
+                $field->setDescription('description');
+            } else {
+                $field = new Range('vcpus',$this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free());
+                $field->addValidator(new NumberValidator($this->resourceManager->vcpus()->getMin(), $this->resourceManager->vcpus()->free(),true));
+                $field->setDescription('description');
+            }
             $this->addField($field);
         }
         //cpu priority