Guest User

Untitled

a guest
Dec 1st, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Server\Control;
  4.  
  5. class ControlDoNothing
  6. implements Type\ControlHandler
  7. {
  8. /**
  9. * @var IpmiServerContract
  10. */
  11. private $server;
  12.  
  13. /**
  14. * @var IpmiClientDetails
  15. */
  16. private $clientDetails;
  17.  
  18. /**
  19. * ControlDoNothing constructor.
  20. *
  21. * @param IpmiClientDetails $clientDetails
  22. */
  23. public function __construct(IpmiClientDetails $clientDetails)
  24. {
  25. $this->clientDetails = $clientDetails;
  26. }
  27.  
  28. /**
  29. * @param IpmiServerContract $server
  30. *
  31. * @return \App\Server\Control\Type\ControlHandler
  32. */
  33. public function connect(IpmiServerContract $server)
  34. {
  35. $this->server = $server;
  36.  
  37. return $this;
  38. }
  39.  
  40. /**
  41. * Set server power to off.
  42. * @return \App\Server\Control\Type\ControlHandler
  43. * @throws UnknownResponse
  44. */
  45. public function powerOff()
  46. {
  47. return $this;
  48. }
  49.  
  50. /**
  51. * @param string $type
  52. *
  53. * @return \App\Server\Control\Type\ControlHandler
  54. * @throws UnknownResponse
  55. */
  56. public function power($type)
  57. {
  58. return $this;
  59. }
  60.  
  61. /**
  62. * Reset server power.
  63. * @return \App\Server\Control\Type\ControlHandler
  64. * @throws UnknownResponse
  65. */
  66. public function powerReset()
  67. {
  68. return $this;
  69. }
  70.  
  71. /**
  72. * @return \App\Server\Control\Type\ControlHandler
  73. * @throws UnknownResponse
  74. */
  75. public function resetBmc()
  76. {
  77. return $this;
  78. }
  79.  
  80. /**
  81. * Set a temporary boot device, which will only apply to next boot.
  82. *
  83. * @param string $dev
  84. *
  85. * @return \App\Server\Control\Type\ControlHandler
  86. * @throws UnknownResponse
  87. */
  88. public function setTemporaryBootDevice($dev)
  89. {
  90. return $this;
  91. }
  92.  
  93. /**
  94. * Set a temporary boot flag, which will only apply to next boot.
  95. *
  96. * @param string $dev
  97. *
  98. * @return \App\Server\Control\Type\ControlHandler
  99. * @throws UnknownResponse
  100. */
  101. public function setTemporaryBootFlag($dev)
  102. {
  103. return $this;
  104. }
  105.  
  106. /**
  107. * @return \App\Server\Control\Type\ControlHandler
  108. * @throws UnknownResponse
  109. */
  110. public function pxeBoot()
  111. {
  112. return $this;
  113. }
  114.  
  115. /**
  116. * @return bool
  117. */
  118. public function isPowerOn()
  119. {
  120. return true;
  121. }
  122.  
  123. /**
  124. * Set a permanent boot device,
  125. * which will last across all future boots
  126. * (until changed via IPMI or BIOS).
  127. *
  128. * @param string $dev
  129. *
  130. * @return \App\Server\Control\Type\ControlHandler
  131. * @throws UnknownResponse
  132. */
  133. public function setPermanentBootDevice($dev)
  134. {
  135. return $this;
  136. }
  137.  
  138. /**
  139. * @param string $username
  140. * @param string $password
  141. *
  142. * @return \App\Server\Control\Type\ControlHandler
  143. */
  144. public function addUser($username = 'client', $password = null)
  145. {
  146. $details = $this->getClientDetails();
  147. $details->setPassword($password ?: str_random(10));
  148. $details->setUsername($username);
  149. $this->server->setIpmiClientDetails($details);
  150.  
  151. return $this;
  152. }
  153.  
  154. /**
  155. * @return int
  156. */
  157. public function getUserId()
  158. {
  159. return 1;
  160. }
  161.  
  162. /**
  163. * @param string $password
  164. *
  165. * @return \App\Server\Control\Type\ControlHandler
  166. */
  167. public function resetUserPass(&$password = null)
  168. {
  169. return $this;
  170. }
  171.  
  172. /**
  173. * @return \App\Server\Control\Type\ControlHandler
  174. */
  175. public function resetUserPerms()
  176. {
  177. return $this;
  178. }
  179.  
  180. /**
  181. * @return \App\Server\Control\Type\ControlHandler
  182. */
  183. public function deleteUser()
  184. {
  185. $details = $this->getClientDetails();
  186. $details->setPassword(null);
  187. $details->setUsername(null);
  188. $this->server->setIpmiClientDetails($details);
  189.  
  190. return $this;
  191. }
  192.  
  193. /**
  194. * @return IpmiClientDetails
  195. */
  196. public function getClientDetails()
  197. {
  198. return $this->clientDetails;
  199. }
  200. }
Add Comment
Please, Sign In to add comment