|
31 | 31 | ) |
32 | 32 | %> |
33 | 33 |
|
34 | | - <% disks = @server.lsblk.fetch("blockdevices").select { |disk| disk.fetch("type") == "disk" } %> |
35 | | - <% |
36 | | - disk_options = disks |
37 | | - .map do |disk| |
38 | | - partitions = disk.fetch("children", []).select { it.fetch("type").start_with?("part") } |
39 | | - raid = disk.fetch("children", []).find { it.fetch("type").start_with?("raid") }&.fetch("name") |
40 | | - suffix = raid ? "[RAID /dev/#{raid}]" : "[#{partitions.length} existing partition#{'s' if partitions.length != 1}]" |
41 | | - label = "/dev/#{disk['name']} (#{number_to_human_size(disk['size'])}) #{suffix}" |
42 | | - value = disk.fetch("wwn") |
| 34 | + <% if @server.is_a?(Server::HetznerDedicated) %> |
| 35 | + <% disks = @server.lsblk.fetch("blockdevices").select { |disk| disk.fetch("type") == "disk" } %> |
| 36 | + <% |
| 37 | + disk_options = disks |
| 38 | + .map do |disk| |
| 39 | + partitions = disk.fetch("children", []).select { it.fetch("type").start_with?("part") } |
| 40 | + raid = disk.fetch("children", []).find { it.fetch("type").start_with?("raid") }&.fetch("name") |
| 41 | + suffix = raid ? "[RAID /dev/#{raid}]" : "[#{partitions.length} existing partition#{'s' if partitions.length != 1}]" |
| 42 | + label = "/dev/#{disk['name']} (#{number_to_human_size(disk['size'])}) #{suffix}" |
| 43 | + value = disk.fetch("wwn") |
43 | 44 |
|
44 | | - [label, value] |
45 | | - end |
46 | | - .sort_by(&:first) |
47 | | - %> |
48 | | - <%= |
49 | | - f.select( |
50 | | - :bootstrap_disk_wwid, |
51 | | - disk_options, |
52 | | - { |
53 | | - prompt: "Select a disk to bootstrap", |
54 | | - # the first non raided disk should be selected by default |
55 | | - selected: disk_options.find { |label, _| label.exclude?("RAID") }&.last, |
56 | | - # raided disks should be disabled |
57 | | - disabled: disk_options.select { |label, _| label.include?("RAID") }.map(&:last), |
58 | | - }, |
59 | | - onchange: " |
60 | | - if(!this.value || parseInt(this.selectedOptions[0].innerText.split('[')[1][0]) == 0) |
61 | | - document.getElementById('bootstrap-warning').classList.add('hidden') |
62 | | - else |
63 | | - document.getElementById('bootstrap-warning').classList.remove('hidden') |
64 | | - ", |
65 | | - required: true, |
66 | | - label: "Bootstrap disk", |
67 | | - ) |
68 | | - %> |
| 45 | + [label, value] |
| 46 | + end |
| 47 | + .sort_by(&:first) |
| 48 | + %> |
| 49 | + <%= |
| 50 | + f.select( |
| 51 | + :bootstrap_disk_wwid, |
| 52 | + disk_options, |
| 53 | + { |
| 54 | + prompt: "Select a disk to bootstrap", |
| 55 | + # the first non raided disk should be selected by default |
| 56 | + selected: disk_options.find { |label, _| label.exclude?("RAID") }&.last, |
| 57 | + # raided disks should be disabled |
| 58 | + disabled: disk_options.select { |label, _| label.include?("RAID") }.map(&:last), |
| 59 | + }, |
| 60 | + onchange: " |
| 61 | + if(!this.value || parseInt(this.selectedOptions[0].innerText.split('[')[1][0]) == 0) |
| 62 | + document.getElementById('bootstrap-warning').classList.add('hidden') |
| 63 | + else |
| 64 | + document.getElementById('bootstrap-warning').classList.remove('hidden') |
| 65 | + ", |
| 66 | + required: true, |
| 67 | + label: "Bootstrap disk", |
| 68 | + ) |
| 69 | + %> |
69 | 70 |
|
70 | | - <p id="bootstrap-warning" class="bg-yellow-100 text-yellow-800 p-4 rounded mb-4 hidden border border-yellow-200"> |
71 | | - <strong>Warning:</strong> Existing partitions on the selected disk will be wiped. |
72 | | - </p> |
| 71 | + <p id="bootstrap-warning" class="bg-yellow-100 text-yellow-800 p-4 rounded mb-4 hidden border border-yellow-200"> |
| 72 | + <strong>Warning:</strong> Existing partitions on the selected disk will be wiped. |
| 73 | + </p> |
73 | 74 |
|
74 | | - <%# Trigger change event to show/hide the warning based on the initially selected disk %> |
75 | | - <script>document.getElementById("bootstrap_disk_wwid").dispatchEvent(new Event("change"))</script> |
| 75 | + <%# Trigger change event to show/hide the warning based on the initially selected disk %> |
| 76 | + <script>document.getElementById("bootstrap_disk_wwid").dispatchEvent(new Event("change"))</script> |
| 77 | + <% else %> |
| 78 | + <p class="bg-blue-100 text-blue-800 p-4 rounded mb-4 border border-blue-200"> |
| 79 | + <strong>Note:</strong> Talos will be installed to /dev/sda. Any existing partitions will be wiped. |
| 80 | + </p> |
| 81 | + <% end %> |
76 | 82 |
|
77 | 83 | <%= f.submit "Bootstrap!" %> |
78 | 84 | <% end %> |
|
0 commit comments