|
54 | 54 | }; |
55 | 55 | }; |
56 | 56 |
|
57 | | - portForwarding = |
| 57 | + portForwardingStorage = |
| 58 | + { config, lib, ... }: |
| 59 | + with lib; |
| 60 | + let |
| 61 | + cfg = config.openstack-testing; |
| 62 | + in |
| 63 | + { |
| 64 | + options.openstack-testing = { |
| 65 | + enable = mkEnableOption "Enable port forwarding." // { |
| 66 | + default = true; |
| 67 | + }; |
| 68 | + sshHostPort = mkOption { |
| 69 | + default = 2122; |
| 70 | + type = types.port; |
| 71 | + description = '' |
| 72 | + Host port to make the ssh server available. |
| 73 | + ''; |
| 74 | + }; |
| 75 | + }; |
| 76 | + config = mkIf cfg.enable { |
| 77 | + virtualisation.forwardPorts = [ |
| 78 | + { |
| 79 | + from = "host"; |
| 80 | + host.port = cfg.sshHostPort; |
| 81 | + guest.port = 22; |
| 82 | + } |
| 83 | + ]; |
| 84 | + }; |
| 85 | + }; |
| 86 | + |
| 87 | + portForwardingCompute = |
| 88 | + { config, lib, ... }: |
| 89 | + with lib; |
| 90 | + let |
| 91 | + cfg = config.openstack-testing; |
| 92 | + in |
| 93 | + { |
| 94 | + options.openstack-testing = { |
| 95 | + enable = mkEnableOption "Enable port forwarding." // { |
| 96 | + # If multiple nodes are used, a separate port must be assigned to each node; otherwise, collisions will occur. |
| 97 | + # We disable ssh port forwarding for compute nodes as default. |
| 98 | + default = false; |
| 99 | + }; |
| 100 | + sshHostPort = mkOption { |
| 101 | + type = types.port; |
| 102 | + description = '' |
| 103 | + Host port to make the ssh server available. |
| 104 | + ''; |
| 105 | + }; |
| 106 | + }; |
| 107 | + config = mkIf cfg.enable { |
| 108 | + virtualisation.forwardPorts = [ |
| 109 | + { |
| 110 | + from = "host"; |
| 111 | + host.port = cfg.sshHostPort; |
| 112 | + guest.port = 22; |
| 113 | + } |
| 114 | + ]; |
| 115 | + }; |
| 116 | + }; |
| 117 | + |
| 118 | + portForwardingController = |
58 | 119 | { config, lib, ... }: |
59 | 120 | with lib; |
60 | 121 | let |
|
92 | 153 | the configuration of the dashboard. |
93 | 154 | ''; |
94 | 155 | }; |
| 156 | + sshHostPort = mkOption { |
| 157 | + default = 2022; |
| 158 | + type = types.port; |
| 159 | + description = '' |
| 160 | + Host port to make the ssh server available. |
| 161 | + ''; |
| 162 | + }; |
95 | 163 | }; |
96 | 164 | config = mkIf cfg.enable { |
97 | 165 | virtualisation.forwardPorts = [ |
|
110 | 178 | host.port = cfg.vncProxyHostPort; |
111 | 179 | guest.port = 6080; |
112 | 180 | } |
| 181 | + { |
| 182 | + from = "host"; |
| 183 | + host.port = cfg.sshHostPort; |
| 184 | + guest.port = 22; |
| 185 | + } |
113 | 186 | ]; |
114 | 187 | }; |
115 | 188 | }; |
|
129 | 202 | { |
130 | 203 | imports = [ |
131 | 204 | common |
132 | | - portForwarding |
| 205 | + portForwardingController |
133 | 206 | ]; |
134 | 207 |
|
| 208 | + # this is an example how to enable / disable all port forwardings or change port numbers |
| 209 | + # openstack-testing.enable = true; |
| 210 | + # openstack-testing.sshHostPort = 1122; |
| 211 | + |
135 | 212 | virtualisation = { |
136 | 213 | cores = 4; |
137 | 214 | memorySize = 6144; |
|
144 | 221 | vlan = 2; |
145 | 222 | }; |
146 | 223 | }; |
147 | | - # enable ssh access |
148 | | - forwardPorts = [ |
149 | | - { |
150 | | - from = "host"; |
151 | | - host.port = 1122; |
152 | | - guest.port = 22; |
153 | | - } |
154 | | - ]; |
155 | 224 | }; |
156 | 225 |
|
157 | 226 | systemd.services.openstack-create-vm = { |
|
232 | 301 | testCompute = |
233 | 302 | { ... }: |
234 | 303 | { |
235 | | - imports = [ common ]; |
| 304 | + imports = [ |
| 305 | + common |
| 306 | + portForwardingCompute |
| 307 | + ]; |
| 308 | + |
| 309 | + # this is an example how to enable / disable all port forwardings or change port numbers |
| 310 | + # openstack-testing.enable = true; # enable / disable all port forwardings |
| 311 | + # openstack-testing.sshHostPort = 3022; |
236 | 312 |
|
237 | 313 | virtualisation = { |
238 | 314 | memorySize = 4096; |
|
271 | 347 | }; |
272 | 348 | }; |
273 | 349 | }; |
274 | | - |
275 | 350 | }; |
276 | 351 |
|
277 | 352 | testStorage = |
278 | 353 | { ... }: |
279 | 354 | { |
280 | 355 |
|
281 | | - imports = [ common ]; |
| 356 | + imports = [ |
| 357 | + common |
| 358 | + portForwardingStorage |
| 359 | + ]; |
| 360 | + |
| 361 | + # this is an example how to enable / disable all port forwardings or change port numbers |
| 362 | + # openstack-testing.enable = true; # enable / disable all port forwardings |
| 363 | + # openstack-testing.sshHostPort = 2022; |
282 | 364 |
|
283 | 365 | virtualisation = { |
284 | 366 | memorySize = 4096; |
|
296 | 378 | vlan = 2; |
297 | 379 | }; |
298 | 380 | }; |
299 | | - # enable ssh access |
300 | | - forwardPorts = [ |
301 | | - { |
302 | | - from = "host"; |
303 | | - host.port = 2022; |
304 | | - guest.port = 22; |
305 | | - } |
306 | | - ]; |
307 | 381 | }; |
308 | 382 |
|
309 | 383 | systemd.network = { |
|
0 commit comments