Agent.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxAddon product developed. (Nov 8, 2018)
  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 MGProvision\Proxmox\v2\models;
  20. /**
  21. * Description of Agent
  22. *
  23. * @author Pawel Kopec <pawelk@modulesgardne.com>
  24. */
  25. class Agent extends AbstractObject
  26. {
  27. protected $path;
  28. public function getPath()
  29. {
  30. return $this->path;
  31. }
  32. public function setPath($path)
  33. {
  34. $this->path = $path;
  35. return $this;
  36. }
  37. public function fsfreezeFreeze()
  38. {
  39. return $this->api()->post($this->getPath() . '/fsfreeze-freeze');
  40. }
  41. public function fsfreezeStatus()
  42. {
  43. return $this->api()->post($this->getPath() . '/fsfreeze-status');
  44. }
  45. public function fsfreezeThaw()
  46. {
  47. return $this->api()->post($this->getPath() . '/fsfreeze-thaw');
  48. }
  49. public function fstrim()
  50. {
  51. return $this->api()->post($this->getPath() . '/fstrim');
  52. }
  53. public function getFsinfo()
  54. {
  55. return $this->api()->get($this->getPath() . '/get-fsinfo');
  56. }
  57. public function getHostname()
  58. {
  59. return $this->api()->get($this->getPath() . '/get-host-name');
  60. }
  61. public function getMemoryBlockInfo()
  62. {
  63. return $this->api()->get($this->getPath() . '/get-memory-block-info');
  64. }
  65. public function getMemoryBlocks()
  66. {
  67. return $this->api()->get($this->getPath() . '/get-memory-blocks');
  68. }
  69. public function getOsinfo()
  70. {
  71. return $this->api()->get($this->getPath() . '/get-osinfo');
  72. }
  73. public function getIime()
  74. {
  75. return $this->api()->get($this->getPath() . '/get-time');
  76. }
  77. public function getIimezone()
  78. {
  79. return $this->api()->get($this->getPath() . '/get-timezone');
  80. }
  81. public function getUsers()
  82. {
  83. return $this->api()->get($this->getPath() . '/get-users');
  84. }
  85. public function getVcpus()
  86. {
  87. return $this->api()->get($this->getPath() . '/get-vcpus');
  88. }
  89. public function info()
  90. {
  91. return $this->api()->get($this->getPath() . '/info');
  92. }
  93. public function networkGetInterfaces()
  94. {
  95. return $this->api()->get($this->getPath() . '/network-get-interfaces');
  96. }
  97. public function ping()
  98. {
  99. return $this->api()->post($this->getPath() . '/ping');
  100. }
  101. public function shutdown()
  102. {
  103. return $this->api()->post($this->getPath() . '/shutdown');
  104. }
  105. public function suspendDisk()
  106. {
  107. return $this->api()->post($this->getPath() . '/suspend-disk');
  108. }
  109. public function suspendHybrid()
  110. {
  111. return $this->api()->post($this->getPath() . '/suspend-hybrid');
  112. }
  113. public function suspendRam()
  114. {
  115. return $this->api()->post($this->getPath() . '/suspend-ram');
  116. }
  117. /**
  118. * @param $command| The command as a list of program + arguments
  119. * @return array|bool
  120. */
  121. public function exec($command){
  122. return $this->api()->post($this->getPath() . '/exec', ['command' => $command]);
  123. }
  124. public function setUserPassword($username, $password, $crypted=null){
  125. $parameters = ['username' => $username, "password" => $password ];
  126. if(is_bool($crypted)){
  127. $parameters['crypted'] = $crypted;
  128. }
  129. return $this->api()->post($this->getPath() . '/set-user-password', $parameters);
  130. }
  131. }