Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Server\Control;
- class ControlDoNothing
- implements Type\ControlHandler
- {
- /**
- * @var IpmiServerContract
- */
- private $server;
- /**
- * @var IpmiClientDetails
- */
- private $clientDetails;
- /**
- * ControlDoNothing constructor.
- *
- * @param IpmiClientDetails $clientDetails
- */
- public function __construct(IpmiClientDetails $clientDetails)
- {
- $this->clientDetails = $clientDetails;
- }
- /**
- * @param IpmiServerContract $server
- *
- * @return \App\Server\Control\Type\ControlHandler
- */
- public function connect(IpmiServerContract $server)
- {
- $this->server = $server;
- return $this;
- }
- /**
- * Set server power to off.
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function powerOff()
- {
- return $this;
- }
- /**
- * @param string $type
- *
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function power($type)
- {
- return $this;
- }
- /**
- * Reset server power.
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function powerReset()
- {
- return $this;
- }
- /**
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function resetBmc()
- {
- return $this;
- }
- /**
- * Set a temporary boot device, which will only apply to next boot.
- *
- * @param string $dev
- *
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function setTemporaryBootDevice($dev)
- {
- return $this;
- }
- /**
- * Set a temporary boot flag, which will only apply to next boot.
- *
- * @param string $dev
- *
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function setTemporaryBootFlag($dev)
- {
- return $this;
- }
- /**
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function pxeBoot()
- {
- return $this;
- }
- /**
- * @return bool
- */
- public function isPowerOn()
- {
- return true;
- }
- /**
- * Set a permanent boot device,
- * which will last across all future boots
- * (until changed via IPMI or BIOS).
- *
- * @param string $dev
- *
- * @return \App\Server\Control\Type\ControlHandler
- * @throws UnknownResponse
- */
- public function setPermanentBootDevice($dev)
- {
- return $this;
- }
- /**
- * @param string $username
- * @param string $password
- *
- * @return \App\Server\Control\Type\ControlHandler
- */
- public function addUser($username = 'client', $password = null)
- {
- $details = $this->getClientDetails();
- $details->setPassword($password ?: str_random(10));
- $details->setUsername($username);
- $this->server->setIpmiClientDetails($details);
- return $this;
- }
- /**
- * @return int
- */
- public function getUserId()
- {
- return 1;
- }
- /**
- * @param string $password
- *
- * @return \App\Server\Control\Type\ControlHandler
- */
- public function resetUserPass(&$password = null)
- {
- return $this;
- }
- /**
- * @return \App\Server\Control\Type\ControlHandler
- */
- public function resetUserPerms()
- {
- return $this;
- }
- /**
- * @return \App\Server\Control\Type\ControlHandler
- */
- public function deleteUser()
- {
- $details = $this->getClientDetails();
- $details->setPassword(null);
- $details->setUsername(null);
- $this->server->setIpmiClientDetails($details);
- return $this;
- }
- /**
- * @return IpmiClientDetails
- */
- public function getClientDetails()
- {
- return $this->clientDetails;
- }
- }
Add Comment
Please, Sign In to add comment