provisioned_guests.tx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!-- Generated by the tCMS Post Type Wizard. Regenerating this type will overwrite any hand edits. -->
  2. <div class="post <: $style :> <: $tiled ? 'tile' : '' :>">
  3. : if ( !$post.addpost ) {
  4. : if ( $post.unreachable ) {
  5. <h3 class='blogtitles'><: $post.title :></h3>
  6. <div class="postData responsive-text">
  7. Could not reach this hypervisor: <: $post.state :>
  8. </div>
  9. : } else {
  10. <h3 class='blogtitles'>
  11. <: $post.title :>
  12. <span class="tag guest-state guest-<: $post.is_active ? 'up bg-green' : 'down bg-red' :>"><: $post.state :></span>
  13. : if ( $post.is_self ) {
  14. <span class="guest-state guest-self tag" title="the server tCMS is running on">dom0</span>
  15. : }
  16. : if ( !$post.has_recipe ) {
  17. <span class="tag guest-state" title="no recipes.d entry for this guest">unprovisioned</span>
  18. : }
  19. : # Nothing waits on the process which reprovisions, so its own
  20. : # status file is the only account of it there is.
  21. : if ( $post.reprovision_state ) {
  22. <span class="tag guest-state reprovision-<: $post.reprovision_state :>"
  23. title="<: $post.reprovision_by ? 'asked for by ' ~ $post.reprovision_by : '' :>">
  24. <: $post.reprovision_status :>
  25. </span>
  26. : }
  27. </h3>
  28. <div class="postData responsive-text" id="postData-<: $post.id :>">
  29. : # Declared private in the sidecar, so a reader who cannot edit
  30. : # never receives it -- there is nothing here to remember to guard.
  31. : if ( $post.preview ) {
  32. <a href="<: $post.preview :>" class="undecorated" title="console of <: $post.title :>">
  33. <img src="<: $post.preview :>" class="responsive-img guest-screenshot" alt="console of <: $post.title :>" loading="lazy" />
  34. </a>
  35. <br />
  36. : }
  37. on <: $post.hypervisor_title :> &mdash; <: $post.vcpus :> vCPU
  38. : if ( $can_edit && $post.recipe ) {
  39. <details class="guest-recipe">
  40. <summary>Recipe &mdash; <: $post.recipe_path :></summary>
  41. <pre class="guest-recipe-body"><: $post.recipe :></pre>
  42. </details>
  43. : }
  44. : if ( $can_edit && $post.reprovision_log ) {
  45. <details class="guest-reprovision-log">
  46. <summary>
  47. Last reprovision &mdash; <: $post.reprovision_status :>
  48. : if ( $post.reprovision_exit ) {
  49. (exit <: $post.reprovision_exit :>)
  50. : }
  51. </summary>
  52. <pre class="guest-recipe-body"><: $post.reprovision_log :></pre>
  53. : if ( $post.reprovision_log_href ) {
  54. <a href="<: $post.reprovision_log_href :>" class="coolbutton" target="_blank" rel="noopener">Read the whole log</a>
  55. : }
  56. </details>
  57. : }
  58. : if ( $can_edit ) {
  59. <br />
  60. <form class="Submissions guest-actions" action="/guest/act" method="POST">
  61. <input type="hidden" name="hypervisor" value="<: $post.hypervisor :>" />
  62. <input type="hidden" name="guest" value="<: $post.domain :>" />
  63. <input type="hidden" name="to" value="<: $route :>" />
  64. : # Trog::DataSource::Virt::act() refuses these for the
  65. : # server drawing the page. Not offering them is not the guard.
  66. : # (A semicolon in a Kolon comment ends the statement, so do not.)
  67. : if ( !$post.is_self ) {
  68. : if ( $post.is_active ) {
  69. <button class="coolbutton" type="submit" name="action" value="poweroff">Power Off</button>
  70. : } else {
  71. <button class="coolbutton" type="submit" name="action" value="poweron">Power On</button>
  72. : }
  73. : }
  74. <button class="coolbutton" type="submit" name="action" value="snapshot">Snapshot</button>
  75. : if ( !$post.is_self ) {
  76. <button class="coolbutton guest-destroy" type="submit" name="action" value="destroy"
  77. onclick="return confirm('Destroy <: $post.title :>? This stops the guest immediately.');">Destroy</button>
  78. : }
  79. </form>
  80. : # Separate form, because this one carries a passphrase and has
  81. : # no business sharing a submit with the buttons above.
  82. : # can_reprovision is false while one is running, so this is
  83. : # the only thing drawn for a guest mid-provision.
  84. : if ( $post.is_reprovisioning ) {
  85. <p class="guest-reprovisioning">
  86. Reprovisioning now
  87. : if ( $post.reprovision_by ) {
  88. &mdash; started by <: $post.reprovision_by :>
  89. : }
  90. : if ( $post.reprovision_log_href ) {
  91. &mdash; <a href="<: $post.reprovision_log_href :>" target="_blank" rel="noopener">watch the log</a>
  92. : }
  93. </p>
  94. : }
  95. : if ( $post.can_reprovision ) {
  96. <form class="Submissions guest-reprovision" action="/guest/reprovision" method="POST" autocomplete="off">
  97. <input type="hidden" name="guest" value="<: $post.domain :>" />
  98. <input type="hidden" name="to" value="<: $route :>" />
  99. : # The passphrase is asked for in the popover rather than
  100. : # sat in the page, so nothing is typed until Reprovision is
  101. : # pressed, and the confirmation is a button you have to hit
  102. : # rather than a confirm() nobody reads. The popover stays
  103. : # inside the form, so the passphrase is submitted with it.
  104. : # popovertarget as well as the command attributes, since a
  105. : # browser which has popover but not invoker commands would
  106. : # otherwise have no way to open this at all. Where both are
  107. : # understood the command wins and the target is ignored, so
  108. : # they do not fight.
  109. <button class="coolbutton guest-destroy" type="button"
  110. command="show-popover" commandfor="reprovision-<: $post.id :>"
  111. popovertarget="reprovision-<: $post.id :>" popovertargetaction="show">Reprovision</button>
  112. : # A browser old enough to have neither draws this inline and
  113. : # submits it, which is the form this replaced, minus the
  114. : # confirmation.
  115. <div popover id="reprovision-<: $post.id :>" class="guest-reprovision-popover">
  116. <p class="guest-reprovision-warning">
  117. Reprovision <: $post.title :>?
  118. This destroys the guest and builds it again from its recipe.
  119. Anything on it the recipe does not describe will not come back.
  120. </p>
  121. <label>
  122. Secrets passphrase
  123. <input required autofocus class="cooltext" type="password" name="passphrase" autocomplete="off"
  124. title="the provisioner asks for this on stdin; it is used for this run and not stored" />
  125. </label>
  126. <div class="guest-reprovision-actions">
  127. <button class="coolbutton" type="button"
  128. command="hide-popover" commandfor="reprovision-<: $post.id :>"
  129. popovertarget="reprovision-<: $post.id :>" popovertargetaction="hide">Cancel</button>
  130. <button class="coolbutton guest-destroy" type="submit">Reprovision it</button>
  131. </div>
  132. </div>
  133. </form>
  134. : }
  135. : }
  136. </div>
  137. : }
  138. : }
  139. </div>