# Servers

A server board has a management controller of its own (a BMC): AMI MegaRAC on ASRock Rack,
Gigabyte and many others, iDRAC on Dell, iLO on HPE, OpenBMC. They share one interface,
Redfish, and qKVM speaks it. Add a server like a KVM: type the address of its controller,
with the controller's user name and password, and qKVM recognises it. *Find KVMs on my
network* finds controllers as well.

**A server's tile shows the server's screen**, as a KVM's does, where the controller runs AMI's
MegaRAC firmware (ASRock Rack, Gigabyte and many others). Redfish itself has no picture; the
screen is in the console that the controller's own web page opens, and qKVM takes it from there:

- It signs in to that page with the login saved for the controller and opens the console. The
  tile shows the screen; enlarged, **Control** takes the server's keyboard and mouse, and **Send
  keys**, **Type text** and **Ctrl+Alt+Del** work as they do for a KVM. These go to the server's
  own USB over the same console. A power command never goes that way: the power buttons are
  Redfish's, as below.
- It holds one of the controller's console seats (as a rule there are two) while somebody
  looks at the wall, and gives it back twenty seconds after nobody does.
- It keeps out of the way of whoever works at the console. Somebody who opens the controller's
  own console while the wall has it is let in at once, keys and all, and the wall goes on
  looking. Whatever a live line had down on the server is let go of first, and the line has the
  keyboard no more: it is told so within a second (`in_use`), and a key of its own meanwhile is
  refused the same way. Keys go only once the
  controller has said that the console is the wall's; a console that another session still
  holds is shown, and nothing is typed into it. When somebody has the console first, the controller asks them whether a newcomer
  may look; the wall does not leave that question on their screen. It leaves the moment it is
  told to wait, shows how the server is, says why, and looks again ten minutes later.
- A console is opened only where the controller says that the server's own monitor stays on
  while it is open: both of the two words it hands out with the console's pass
  (`automatic_off`, `local_monitor_off`) are said, and both are a plain no. A controller that
  says anything else (both on, or only one of the two off) or does not say is left alone, and
  the enlarged tile says which of these it is, and that there is no picture for it.
  Ten minutes later it is asked again, in case the setting was changed.
- A controller ends a console session in which no key was pressed for a while (half an hour,
  on the boards this was tried with), and a wall that only looks presses none. It opens the console again at
  once, and the tile keeps its picture for the moment that takes.
- The tile's footer says how large the screen is, how the server is and how warm. Enlarged,
  **Health** shows every temperature and every fan.
- The picture is read in Python, and what a controller sends is not believed. A text console
  costs next to nothing; a screen that changes all over (a video, a desktop being dragged
  about) takes seconds a frame on a desktop processor. The frames of two servers are read at
  a time and the others wait their turn, so busy screens slow each other's pictures and
  nothing else. No frame may be longer, or bring more, than a screen of its size could take
  twice over, and a screen larger than 2048 pixels either way is not shown.

**Where the controller runs OpenBMC** with its KVM (its manager says so: a graphical console of
the KVM-over-IP kind), the screen comes from that console instead: a WebSocket on the controller,
`/kvm/0`, that carries the protocol of VNC, read by the same reader as a [VNC server](https://qkvm.com/docs/vnc-servers).
qKVM opens it with the Redfish session it holds already, so there is no second sign-in; it takes one
of the controller's four console seats while somebody looks, and gives it back a minute after nobody
does, and before the session it was opened with. The console asks for no password of its own; one
that does is sent nothing, since the only password here is the controller's. Keys, typed text and
keyboard and mouse over the live line go over that same console, as a VNC server's do (key events
by keysym, the pointer at a place in the screen's pixels), and OpenBMC's VNC server (obmc-ikvm)
turns them into the server's USB keyboard and absolute mouse. It makes each key event the key of
a US keyboard it is on and takes Shift only from the Shift key itself, so typed text goes with
Shift pressed around a capital or a sign, and a character the US layout has no key for is refused
(422 `invalid`) before anything is typed. It takes nothing from a viewer for
its first frames, about a second, so keys wait that long after the console opens. OpenBMC's web
server lets whoever may open the console type into it (an account with the right to configure
components or the manager): an account that may not is refused the console, picture and keys
together, and the tile says so. A controller whose VNC server has no USB keyboard to write to (a
build without one) takes the keys and they go nowhere, which nothing on the console tells qKVM.
This was built from the source of OpenBMC's web server and its VNC server and tried against a
stand-in; on OpenBMC's own image in QEMU only the console's sign-in could be tried, since that
image has no console (see [Limits](https://qkvm.com/docs/limits)).

On a controller of another make (iDRAC, iLO and the rest speak consoles of their own; an iDRAC's
own VNC server, where it is switched on, can be a tile of its own: see [VNC servers](https://qkvm.com/docs/vnc-servers)), and
whenever the screen cannot be had, the tile shows how the server is doing instead. That, and
what else a server's tile gives:

- Whether it is **on or off**, its **health** as the controller judges it, how warm its
  processors are and how many fans are running. Enlarged, every temperature and every fan,
  and which of them the controller is not happy with.
- **Power on** switches the server on and **Shut down** asks its operating system to shut
  down. A server that is already on, or already off, is left as it is and says so, which
  is what makes them safe to run on a whole selection: after a power cut, *Power on* brings
  back the servers that stayed off and does nothing to the ones that came back by
  themselves. (A KVM's power button cannot promise that: it presses a button, and what the
  press does depends on whether the computer is on.) **Hold power button** cuts the power,
  and **Press reset button** restarts it the hard way. **Restart controller** restarts the
  controller itself; the server keeps running. **Start into BIOS setup** tells the controller
  to boot the server into its firmware setup once (Redfish's `BootSourceOverrideTarget`
  "BiosSetup", for one boot) and then switches it on, or restarts it if it is on, so it comes
  up in its BIOS setup; the question before it names the server and says which. It is offered
  only where the controller says it allows that boot override, is for one server at a time
  (its large view opens to show the setup screen), not a bulk run, and is written in the log.
  A boot override another tool set (a network boot, or one for every boot) is not replaced,
  nor is a server touched that is switching on or shutting down just then: the button says so
  and does nothing (and where the override was set already before the press, that it still is).
  Once the override may be set, the button says whether it is: where the
  controller refuses the restart for certain, or its answer to the override itself is lost, the
  override is set back to off, so no ordinary boot lands in the setup (where it showed off already
  when it was set back, before a change of the press's that may still be made, that is said as a
  maybe); where the restart may
  have gone through (its answer lost, an error of the controller's own, or an answer a command
  does not have), or a server switched on is not seen to come on, it is left set and the
  button says so. The clearing reads first and leaves an override another tool has set by
  then (one set in the moment between that read and the clearing is not seen); an override
  that was set already before the press is left as it was, and said. A controller that takes
  the override, or its clearing, for later (202) is read until it shows it; where it shows
  that it did not keep the override, nothing is restarted (where it cannot be read, the
  restart goes out). Where it is read back, the power that read shows decides what goes out: a
  server switched on meanwhile (at its button, by another tool) is restarted, and one that began
  to change its state is left alone and the override cleared again. After a 204, which is what
  the board this was tried on answers, the change is not read back, and the power is read once
  before the power command, for five seconds at the most (a connection to ask on, waited for or
  made, included), and decides as above. That board
  answers no read for about a minute after the change: where that read gets no answer, the power
  read before the change decides, and a server read off then and switched on by somebody during
  the change is sent *On*, which a server that is on takes as nothing to do, so the button says
  done, nothing restarts, and the override waits for that server's next boot. A server switched
  on into its setup is waited for that minute and the usual 25 seconds
  after it before the button says it did not come on. A restart that the controller accepts is
  not seen done (the server is on
  before and after): the override stays set until the server boots, and the large view shows
  whether it did. A press that has not come to its restart within two minutes goes no further
  (where the restart would go on a new connection, with the time that connection may take to
  spare): nothing is restarted, and the override is cleared again. Nothing under way is cut off
  for that: a request is waited out within its own time, and a clearing goes to its end, so the
  answer can take several minutes on a controller that is slow at every step (some ten, and
  more where it has to be signed in to again or a read is asked again on the way). The page
  waits four, then says it had no answer and that the setup boot may be set; the activity log
  has how it ended.
- **Locator light on** lights the server up, front and back, for whoever is standing in
  front of the rack looking for it. The tile says so for as long as the light is on.
- **Virtual media**, for an admin: an ISO image of the folder named in *Settings > Server images*
  in the server's virtual CD-ROM drive, which its controller reads from qKVM while it is
  mounted, and the server started from it once or until it is unmounted (see
  [Virtual media](https://qkvm.com/docs/virtual-media)).
- **Open console** leads to the controller's own page, where its remote console is. Where
  the controller hands out a pass for that (AMI's does, on the boards whose maker left it
  in), the link leads straight into the console, signed in. See below for what that means.
- [Alerts](https://qkvm.com/docs/alerts) tell you when a server is switched off or comes back, when its
  controller stops answering, and when the controller reports a critical fault, with the
  names of the sensors behind it. A fault that comes and goes (a fan at its limit makes a
  controller call itself critical and well again every few seconds) is one problem: the tile
  stays on it, and "recovered" is said once it has stayed away for five minutes.

A few things are worth knowing:

- **Done means seen.** A controller answers "accepted" before anything has happened, and now
  and then nothing does. When a server is switched on, or its power cut, qKVM waits until it
  sees the server on, or off, and says so if it does not get to. A request to shut down is
  different: the system takes the time it takes, and the tile shows when it is off. Where no
  look at the server comes back in that time, the button says that it may have been done
  (`timeout`), not that it was not; so does a command the controller answers with an error of
  its own (a 5xx): only a refusal (a 4xx) says that nothing was done. A bulk run's *Retry
  failed* does not press those again.
- **A controller has its moments.** It is a small computer, and one in perfect health lets a
  request time out now and then, or answers errors for some seconds while its server starts
  or stops. The tile does not change for that. It does once the controller has given no
  proper answer for three quarters of a minute.
- **One sign-in, kept.** A controller allows only a few sessions at a time. qKVM signs in
  once, goes on using that session, and gives it back when the server is taken off the wall.
- **The server it was added for, and no other.** A controller's maker may put one certificate,
  and its key, on every board, and a rack often has one password: after a new lease another
  server's controller may answer at a tile's address, and its certificate does not tell it apart.
  So qKVM remembers two numbers when a server is added, and keeps them in an export file: the one
  its computer gives for itself (its UUID), and the one its controller's Redfish service gives in
  its service root, which anybody may read. Before the password goes to the controller (when
  qKVM signs in, and again when that session has run out) the service root is read and its
  number compared. Before every power button, the locator light, *Start into BIOS setup*, the
  console's own sign-in (the screen and the keys come through that console; asked again once that
  sign-in is done, before the console is opened) and *Open console*, the computer is read and its
  number compared, and the command goes only under the session that read came under: another
  server does not know that session, so what takes a command is the server that was asked. Every
  look compares too, so the tile never shows another server's power, name and sensors as this
  one's. Where another server answers, or one whose computer names no number where this one's
  did, nothing is sent to it (not the password where its controller's number differs; no command,
  no key, no console), and the tile says so from the moment that is seen until this server
  answers there again. If it is the server this tile is for now (another board, or its controller
  set back to its factory settings, which may give its service another number), edit the tile and
  type its password; saved without being checked (*Save anyway*, password or not), the tile keeps
  the server it was added for. A tile from qKVM 0.1 knows its server by the number it kept then
  and takes its controller's at the first look that finds the server to be this one (the root's
  number is taken only where the controller's manager, read under that session, names the same,
  as the service it hosts or as itself; a controller whose manager names neither is known by its
  computer's number alone);
  a tile with neither (one kept beside its twin) takes the first it sees, as a certificate is
  remembered on first contact. A board whose computer gives no number (all zeros) is known by its
  controller's alone; one that gives neither is not told apart this way.
- **A rejected password is left alone.** Controllers lock an account after a few failed
  logins, for you as well. A password that the device said no to is tried again after a
  minute, five minutes after that, a quarter of an hour after that, and from then on once
  an hour, however often the wall is looked at or signed in to meanwhile. A KVM and a
  JetKVM are treated the same, and the controller's own console is offered the password
  no sooner than that. Only a no counts. A sign-in that is answered with an error of the
  device's own, or not at all, says nothing about the password: it is tried again after
  ten seconds, then after twice as long each time, five minutes at the most. A JetKVM
  that says when to come back (it shuts an address out after five wrong passwords) is
  asked then, and no sooner than a minute. The console's web page has waits of its own
  after such a failure: half a minute, then one, two and five, and ten where asking
  again would change nothing. (A device that answers everything but its sign-in is shown
  as having a problem, not as offline.) Typing the password again tries at once: with
  *Update login* on a tile that says *Login failed*, in the device's own dialog
  otherwise. What was rejected is kept in memory: after a restart of qKVM it is tried
  once more. While it waits qKVM still asks twice a minute whether the device is there,
  without the password, so a machine that goes off meanwhile is shown as offline.
- **The account decides what works.** An account with the controller's read-only role is
  enough to show the state. The power buttons and the locator light need the operator or
  administrator role.
- **A console opened from the wall is signed in as that account.** The pass works once and
  goes to the browser of whoever clicked, nowhere else; that they went in is written to the
  activity log. Operators and admins of the wall can do this, viewers cannot, and an account
  limited to some machines only for those. If the people on your wall should not have what
  the controller's account has, give the wall a controller account that has less.
