| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Jobs\Vps\NetworkRate;
- use ModulesGarden\ProxmoxAddon\App\Jobs\Vps\BaseJob;
- use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
- use ModulesGarden\ProxmoxAddon\App\Enum\Vps\ConfigurableOption;
- class MaximumVmRateJob extends BaseJob
- {
- use ProductService;
- public function handle($text = null)
- {
- $this->initParams();
- $this->initServices();
- $container = [];
- $rate = null;
- if ($this->getWhmcsConfigOption(ConfigurableOption::NETWORK_RATE,$this->configuration()->getRate()) &&
- $this->getWhmcsConfigOption(ConfigurableOption::NETWORK_RATE,$this->configuration()->getRate()) != "-1")
- {
- $rate = $this->getWhmcsConfigOption(ConfigurableOption::NETWORK_RATE,$this->configuration()->getRate()) ;
- }
- foreach ($this->vm()->getNetworkDevices($this->configuration()->getBridge()) as $entity)
- {
- $hash = $entity->getHashCode();
- if ($entity->getRate() != $rate)
- {
- $entity->setRate($rate);
- }
- if ($hash != $entity->getHashCode())
- {
- $container[$entity->getId()] = $entity->asConfig();
- }
- }
- if (!empty($container))
- {
- $this->vm()->updateConfig($container);
- }
- }
- }
|