| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\App\Jobs\Cloud\NetworkRate;
- use ModulesGarden\ProxmoxAddon\App\Jobs\BaseJob;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
- class MinimumVmRateJob extends BaseJob
- {
- use ProductService;
- public function handle($text = null)
- {
- $this->initParams();
- $this->initServices();
- $this->api();
- $this->initVm();
- $container = [];
- $rate = $this->configuration()->getMinimumRate();
- foreach (sl('Vm')->getVm()->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))
- {
- sl('Vm')->getVm()->updateConfig($container);
- }
- }
- }
|