@@ -20,6 +20,8 @@ let nullref = Ref.string_of Ref.null
20
20
21
21
let nid = " <not in database>"
22
22
23
+ let inconsistent = " <inconsistent>"
24
+
23
25
let unknown_time = " <unknown time>"
24
26
25
27
let string_of_float f = Printf. sprintf " %.3f" f
@@ -204,6 +206,37 @@ let get_pbds_host rpc session_id pbds =
204
206
let get_sr_host rpc session_id record =
205
207
get_pbds_host rpc session_id record.API. sR_PBDs
206
208
209
+ (* * Get consistent field from all hosts, or return a default value if the field
210
+ is not the same on all hosts. *)
211
+ let get_consistent_field_or_default ~rpc ~session_id ~getter ~transform ~default
212
+ =
213
+ match Client.Host. get_all ~rpc ~session_id with
214
+ | [] ->
215
+ default
216
+ | hosts -> (
217
+ let result =
218
+ List. fold_left
219
+ (fun acc host ->
220
+ match acc with
221
+ | `Inconsistent ->
222
+ `Inconsistent
223
+ | `NotSet ->
224
+ `Value (getter ~rpc ~session_id ~self: host |> transform)
225
+ | `Value v ->
226
+ let current = getter ~rpc ~session_id ~self: host |> transform in
227
+ if v = current then `Value v else `Inconsistent
228
+ )
229
+ `NotSet hosts
230
+ in
231
+ match result with
232
+ | `Value v ->
233
+ v
234
+ | `Inconsistent ->
235
+ default
236
+ | `NotSet ->
237
+ default
238
+ )
239
+
207
240
let bond_record rpc session_id bond =
208
241
let _ref = ref bond in
209
242
let empty_record =
@@ -1506,6 +1539,42 @@ let pool_record rpc session_id pool =
1506
1539
)
1507
1540
~get_map: (fun () -> (x () ).API. pool_license_server)
1508
1541
()
1542
+ ; make_field ~name: " ssh-enabled"
1543
+ ~get: (fun () ->
1544
+ get_consistent_field_or_default ~rpc ~session_id
1545
+ ~getter: Client.Host. get_ssh_enabled ~transform: string_of_bool
1546
+ ~default: inconsistent
1547
+ )
1548
+ ()
1549
+ ; make_field ~name: " ssh-enabled-timeout"
1550
+ ~get: (fun () ->
1551
+ get_consistent_field_or_default ~rpc ~session_id
1552
+ ~getter: Client.Host. get_ssh_enabled_timeout
1553
+ ~transform: Int64. to_string ~default: inconsistent
1554
+ )
1555
+ ~set: (fun value ->
1556
+ Client.Pool. set_ssh_enabled_timeout ~rpc ~session_id ~self: pool
1557
+ ~value: (safe_i64_of_string " ssh-enabled-timeout" value)
1558
+ )
1559
+ ()
1560
+ ; make_field ~name: " ssh-expiry"
1561
+ ~get: (fun () ->
1562
+ get_consistent_field_or_default ~rpc ~session_id
1563
+ ~getter: Client.Host. get_ssh_expiry ~transform: Date. to_rfc3339
1564
+ ~default: inconsistent
1565
+ )
1566
+ ()
1567
+ ; make_field ~name: " console-idle-timeout"
1568
+ ~get: (fun () ->
1569
+ get_consistent_field_or_default ~rpc ~session_id
1570
+ ~getter: Client.Host. get_console_idle_timeout
1571
+ ~transform: Int64. to_string ~default: inconsistent
1572
+ )
1573
+ ~set: (fun value ->
1574
+ Client.Pool. set_console_idle_timeout ~rpc ~session_id ~self: pool
1575
+ ~value: (safe_i64_of_string " console-idle-timeout" value)
1576
+ )
1577
+ ()
1509
1578
]
1510
1579
}
1511
1580
@@ -3265,6 +3334,26 @@ let host_record rpc session_id host =
3265
3334
; make_field ~name: " last-update-hash"
3266
3335
~get: (fun () -> (x () ).API. host_last_update_hash)
3267
3336
()
3337
+ ; make_field ~name: " ssh-enabled"
3338
+ ~get: (fun () -> string_of_bool (x () ).API. host_ssh_enabled)
3339
+ ()
3340
+ ; make_field ~name: " ssh-enabled-timeout"
3341
+ ~get: (fun () -> Int64. to_string (x () ).API. host_ssh_enabled_timeout)
3342
+ ~set: (fun value ->
3343
+ Client.Host. set_ssh_enabled_timeout ~rpc ~session_id ~self: host
3344
+ ~value: (safe_i64_of_string " ssh-enabled-timeout" value)
3345
+ )
3346
+ ()
3347
+ ; make_field ~name: " ssh-expiry"
3348
+ ~get: (fun () -> Date. to_rfc3339 (x () ).API. host_ssh_expiry)
3349
+ ()
3350
+ ; make_field ~name: " console-idle-timeout"
3351
+ ~get: (fun () -> Int64. to_string (x () ).API. host_console_idle_timeout)
3352
+ ~set: (fun value ->
3353
+ Client.Host. set_console_idle_timeout ~rpc ~session_id ~self: host
3354
+ ~value: (safe_i64_of_string " console-idle-timeout" value)
3355
+ )
3356
+ ()
3268
3357
]
3269
3358
}
3270
3359
0 commit comments