@@ -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,31 @@ 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 a field from the first host, 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 `Value v -> v | _ -> default
232
+ )
233
+
207
234
let bond_record rpc session_id bond =
208
235
let _ref = ref bond in
209
236
let empty_record =
@@ -1506,6 +1533,44 @@ let pool_record rpc session_id pool =
1506
1533
)
1507
1534
~get_map: (fun () -> (x () ).API. pool_license_server)
1508
1535
()
1536
+ ; make_field ~name: " ssh-enabled"
1537
+ ~get: (fun () ->
1538
+ get_consistent_field_or_default ~rpc ~session_id
1539
+ ~getter: Client.Host. get_ssh_enabled ~transform: string_of_bool
1540
+ ~default: inconsistent
1541
+ )
1542
+ ()
1543
+ ; make_field ~name: " ssh-enabled-timeout"
1544
+ ~get: (fun () ->
1545
+ get_consistent_field_or_default ~rpc ~session_id
1546
+ ~getter: Client.Host. get_ssh_enabled_timeout
1547
+ ~transform: Int64. to_string ~default: inconsistent
1548
+ )
1549
+ ~set: (fun value ->
1550
+ let minutes = safe_i64_of_string " ssh-enabled-timeout" value in
1551
+ let seconds = Int64. mul minutes 60L in
1552
+ Client.Pool. set_ssh_enabled_timeout ~rpc ~session_id ~self: pool
1553
+ ~value: seconds
1554
+ )
1555
+ ()
1556
+ ; make_field ~name: " ssh-expiry"
1557
+ ~get: (fun () ->
1558
+ get_consistent_field_or_default ~rpc ~session_id
1559
+ ~getter: Client.Host. get_ssh_expiry ~transform: Date. to_rfc3339
1560
+ ~default: inconsistent
1561
+ )
1562
+ ()
1563
+ ; make_field ~name: " console-idle-timeout"
1564
+ ~get: (fun () ->
1565
+ get_consistent_field_or_default ~rpc ~session_id
1566
+ ~getter: Client.Host. get_console_idle_timeout
1567
+ ~transform: Int64. to_string ~default: inconsistent
1568
+ )
1569
+ ~set: (fun value ->
1570
+ Client.Pool. set_console_idle_timeout ~rpc ~session_id ~self: pool
1571
+ ~value: (Int64. of_string value)
1572
+ )
1573
+ ()
1509
1574
]
1510
1575
}
1511
1576
@@ -3265,6 +3330,28 @@ let host_record rpc session_id host =
3265
3330
; make_field ~name: " last-update-hash"
3266
3331
~get: (fun () -> (x () ).API. host_last_update_hash)
3267
3332
()
3333
+ ; make_field ~name: " ssh-enabled"
3334
+ ~get: (fun () -> string_of_bool (x () ).API. host_ssh_enabled)
3335
+ ()
3336
+ ; make_field ~name: " ssh-enabled-timeout"
3337
+ ~get: (fun () -> Int64. to_string (x () ).API. host_ssh_enabled_timeout)
3338
+ ~set: (fun value ->
3339
+ let minutes = safe_i64_of_string " ssh-enabled-timeout" value in
3340
+ let seconds = Int64. mul minutes 60L in
3341
+ Client.Host. set_ssh_enabled_timeout ~rpc ~session_id ~self: host
3342
+ ~value: seconds
3343
+ )
3344
+ ()
3345
+ ; make_field ~name: " ssh-expiry"
3346
+ ~get: (fun () -> Date. to_rfc3339 (x () ).API. host_ssh_expiry)
3347
+ ()
3348
+ ; make_field ~name: " console-idle-timeout"
3349
+ ~get: (fun () -> Int64. to_string (x () ).API. host_console_idle_timeout)
3350
+ ~set: (fun value ->
3351
+ Client.Host. set_console_idle_timeout ~rpc ~session_id ~self: host
3352
+ ~value: (safe_i64_of_string " console-idle-timeout" value)
3353
+ )
3354
+ ()
3268
3355
]
3269
3356
}
3270
3357
0 commit comments