M2M7P0.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update\Patch;
  3. use Illuminate\Database\Capsule\Manager as DB;
  4. use ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update\DefaultPatch;
  5. use ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update\ProductConveter;
  6. use ModulesGarden\ProxmoxAddon\Core\Helper;
  7. /**
  8. * Description of M2M6P0
  9. *
  10. * @author <slawomir@modulesgarden.com>
  11. */
  12. class M2M7P0 extends DefaultPatch
  13. {
  14. public function execute()
  15. {
  16. if ($this->runSchema())
  17. {
  18. Helper\sl('logger')
  19. ->addDebug("Correctly installed update {$this->getVersion()} .", []);
  20. }
  21. else
  22. {
  23. Helper\sl('errorManager')
  24. ->addError(self::class, "Incorrectly installed update {$this->getVersion()} .", []);
  25. }
  26. $this->up();
  27. //import ip addresses
  28. $this->vmIpAddresses();
  29. //import key pairs
  30. $this->keyPairs();
  31. //import users
  32. $this->users();
  33. try
  34. {
  35. $productConveter = new ProductConveter();
  36. foreach (DB::table("proxmoxVPS_prodConfig")->get() as $row)
  37. {
  38. $setting = $productConveter->convert($row->setting, $row->value, $row->product_id);
  39. if (is_null($setting))
  40. {
  41. continue;
  42. }
  43. if ($productConveter->exist($setting))
  44. {
  45. continue;
  46. }
  47. $setting->save();
  48. }
  49. }
  50. catch (\Exception $ex)
  51. {
  52. }
  53. }
  54. }