RecoveryVmDumpService.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Jan 23, 2019)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\ProxmoxAddon\App\Services;
  20. use ModulesGarden\ProxmoxAddon\App\Models\RecoveryVm;
  21. /**
  22. * Description of RecoveryVmDumpService
  23. *
  24. * @author Pawel Kopec <pawelk@modulesgardne.com>
  25. */
  26. class RecoveryVmDumpService
  27. {
  28. public function generate()
  29. {
  30. $data = [];
  31. $date = date("Y-m-d H:i:s");
  32. $data[] = 'Recovery VM Dump: ' . $date;
  33. $data[] = "";
  34. foreach (RecoveryVm::get() as $recoveryVm)
  35. {
  36. /* @var $recoveryVm RecoveryVm */
  37. try
  38. {
  39. $data[] = "[ID] #{$recoveryVm->id}";
  40. $data[] = "[LAST UPDATE] {$recoveryVm->last_update}";
  41. $data[] = "[HOSTING ID] #{$recoveryVm->service_id}";
  42. $data[] = "[CLIENT] #{$recoveryVm->client_id} {$recoveryVm->hosting->client->firstname} {$recoveryVm->hosting->client->lastname}";
  43. $data[] = "[NODE] {$recoveryVm->node}";
  44. $data[] = "[VMID] {$recoveryVm->vmid}";
  45. $data[] = "[VIRTUALIZATION] {$recoveryVm->virtualization}";
  46. $data[] = "[CONFIG]: ";
  47. $data[] = $recoveryVm->config;
  48. $data[] = "";
  49. $data[] = "[STATUS]: ";
  50. $data[] = $recoveryVm->status;
  51. $data[] = "";
  52. $data[] = "[DNS]: ";
  53. $data[] = $recoveryVm->dns;
  54. $data[] = "";
  55. $data[] = "-------------------------------------------------------------------";
  56. $data[] = "";
  57. }
  58. catch (\Exception $ex)
  59. {
  60. }
  61. }
  62. return implode("\r\n", $data);
  63. }
  64. }