-
Notifications
You must be signed in to change notification settings - Fork 282
/
datamodel.ml
8495 lines (8040 loc) · 309 KB
/
datamodel.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
* Copyright (C) 2006-2009 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
(** Data Model and Message Specification for Xen Management Tools *)
open Datamodel_types
open Lifecycle
open Datamodel_common
open Datamodel_roles
let errors = Datamodel_errors.errors
let messages = Datamodel_errors.messages
let roles_all = roles_all
let api_version_major = Datamodel_common.api_version_major
let api_version_minor = Datamodel_common.api_version_minor
module Session = struct
let login =
call ~flags:[] ~name:"login_with_password" ~in_product_since:rel_rio
~doc:
"Attempt to authenticate the user, returning a session reference if \
successful"
~result:(Ref _session, "reference of newly created session")
~versioned_params:
[
{
param_type= String
; param_name= "uname"
; param_doc= "Username for login."
; param_release= rio_release
; param_default= None
}
; {
param_type= String
; param_name= "pwd"
; param_doc= "Password for login."
; param_release= rio_release
; param_default= None
}
; {
param_type= String
; param_name= "version"
; param_doc= "Client API version."
; param_release= miami_release
; param_default= Some (VString "1.1")
}
; {
param_type= String
; param_name= "originator"
; param_doc=
"Key string for distinguishing different API users sharing the \
same login name."
; param_release= clearwater_release
; param_default= Some (VString "")
}
]
~errs:[Api_errors.session_authentication_failed; Api_errors.host_is_slave]
~secret:true
~allowed_roles:_R_ALL (*any static role can try to create a user session*)
()
let slave_login =
call ~flags:[] ~name:"slave_login"
~doc:
"Attempt to authenticate to the pool master by presenting the slave's \
host ref and pool secret"
~result:(Ref _session, "ID of newly created session")
~params:
[
(Ref _host, "host", "Host id of slave")
; (SecretString, "psecret", "Pool secret")
]
~in_oss_since:None ~in_product_since:rel_rio ~secret:true
~hide_from_docs:true ~allowed_roles:_R_POOL_ADMIN
(*system can create a slave session !!! *) ()
let slave_local_login =
call ~flags:[] ~in_product_since:rel_miami ~name:"slave_local_login"
~doc:
"Authenticate locally against a slave in emergency mode. Note the \
resulting sessions are only good for use on this host."
~result:(Ref _session, "ID of newly created session")
~params:[(SecretString, "psecret", "Pool secret")]
~in_oss_since:None ~secret:true ~hide_from_docs:true
~allowed_roles:_R_POOL_ADMIN (*system can create a slave session*) ()
let slave_local_login_with_password =
call ~flags:[] ~in_product_since:rel_miami
~name:"slave_local_login_with_password"
~doc:
"Authenticate locally against a slave in emergency mode. Note the \
resulting sessions are only good for use on this host."
~result:(Ref _session, "ID of newly created session")
~params:
[
(String, "uname", "Username for login.")
; (String, "pwd", "Password for login.")
]
~in_oss_since:None ~secret:true
~allowed_roles:_R_POOL_ADMIN (*only root can do an emergency slave login*)
()
let create_from_db_file =
call
~lifecycle:[(Published, rel_dundee, "")]
~name:"create_from_db_file"
~params:[(String, "filename", "Database dump filename.")]
~result:(Ref _session, "ID of newly created session")
~in_oss_since:None ~allowed_roles:_R_LOCAL_ROOT_ONLY ()
let local_logout =
call ~flags:[`Session] ~in_product_since:rel_miami ~name:"local_logout"
~doc:"Log out of local session." ~params:[] ~in_oss_since:None
~allowed_roles:_R_POOL_ADMIN (*system can destroy a local session*) ()
let logout =
call ~flags:[`Session] ~in_product_since:rel_rio ~name:"logout"
~doc:"Log out of a session" ~params:[] ~allowed_roles:_R_ALL
(*any role can destroy a known user session*) ()
let change_password =
call ~flags:[`Session] ~name:"change_password"
~doc:
"Change the account password; if your session is authenticated with \
root privileges then the old_pwd is validated and the new_pwd is set \
regardless"
~params:
[
(String, "old_pwd", "Old password for account")
; (String, "new_pwd", "New password for account")
]
~in_product_since:rel_rio ~in_oss_since:None
~allowed_roles:_R_LOCAL_ROOT_ONLY
(*not even pool-admin can change passwords, only root*) ()
let get_all_subject_identifiers =
call ~name:"get_all_subject_identifiers"
~doc:
"Return a list of all the user subject-identifiers of all existing \
sessions"
~result:
( Set String
, "The list of user subject-identifiers of all existing sessions"
)
~params:[] ~in_product_since:rel_george ~in_oss_since:None
~allowed_roles:_R_ALL ()
let logout_subject_identifier =
call ~name:"logout_subject_identifier"
~doc:
"Log out all sessions associated to a user subject-identifier, except \
the session associated with the context calling this function"
~params:
[
( String
, "subject_identifier"
, "User subject-identifier of the sessions to be destroyed"
)
]
~in_product_since:rel_george ~in_oss_since:None ~allowed_roles:_R_POOL_OP
()
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303
~persist:PersistNothing ~gen_constructor_destructor:false ~name:_session
~descr:"A session" ~gen_events:false ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_ADMIN
~messages:
[
login
; logout
; change_password
; slave_login
; slave_local_login
; slave_local_login_with_password
; create_from_db_file
; local_logout
; get_all_subject_identifiers
; logout_subject_identifier
]
~contents:
[
uid _session
; field ~qualifier:DynamicRO ~ty:(Ref _host) "this_host"
"Currently connected host"
; field ~qualifier:DynamicRO ~ty:(Ref _user) "this_user"
"Currently connected user"
; field ~qualifier:DynamicRO ~ty:DateTime "last_active"
"Timestamp for last time session was active"
; field ~qualifier:DynamicRO ~ty:Bool ~in_oss_since:None "pool"
"True if this session relates to a intra-pool login, false \
otherwise"
; field ~in_product_since:rel_miami ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"
; field ~in_product_since:rel_george ~qualifier:DynamicRO
~default_value:(Some (VBool false)) ~ty:Bool "is_local_superuser"
"true iff this session was created using local superuser \
credentials"
; field ~in_product_since:rel_george ~qualifier:DynamicRO
~default_value:(Some (VRef null_ref)) ~ty:(Ref _subject) "subject"
"references the subject instance that created the session. If a \
session instance has is_local_superuser set, then the value of \
this field is undefined."
; field ~in_product_since:rel_george ~qualifier:DynamicRO
~default_value:(Some (VDateTime (Date.of_float 0.)))
~ty:DateTime "validation_time"
"time when session was last validated"
; field ~in_product_since:rel_george ~qualifier:DynamicRO
~default_value:(Some (VString "")) ~ty:String "auth_user_sid"
"the subject identifier of the user that was externally \
authenticated. If a session instance has is_local_superuser set, \
then the value of this field is undefined."
; field ~in_product_since:rel_midnight_ride ~qualifier:DynamicRO
~default_value:(Some (VString "")) ~ty:String "auth_user_name"
"the subject name of the user that was externally authenticated. \
If a session instance has is_local_superuser set, then the value \
of this field is undefined."
; field ~in_product_since:rel_midnight_ride ~qualifier:StaticRO
~default_value:(Some (VSet [])) ~ty:(Set String) "rbac_permissions"
"list with all RBAC permissions for this session"
; field ~in_product_since:rel_midnight_ride ~qualifier:DynamicRO
~ty:(Set (Ref _task)) "tasks"
"list of tasks created using the current session"
; field ~in_product_since:rel_midnight_ride ~qualifier:StaticRO
~default_value:(Some (VRef null_ref)) ~ty:(Ref _session) "parent"
"references the parent session that created this session"
; field ~in_product_since:rel_clearwater ~qualifier:DynamicRO
~default_value:(Some (VString "")) ~ty:String "originator"
"a key string provided by a API user to distinguish itself from \
other users sharing the same login name"
; field ~in_product_since:"21.2.0" ~qualifier:DynamicRO
~default_value:(Some (VBool false)) ~ty:Bool "client_certificate"
"indicates whether this session was authenticated using a client \
certificate"
]
()
end
module Task = struct
(* NB: the status 'cancelling' is not being used, nor should it ever be used. It should be purged from here! *)
let status_type =
Enum
( "task_status_type"
, [
("pending", "task is in progress")
; ("success", "task was completed successfully")
; ("failure", "task has failed")
; ("cancelling", "task is being cancelled")
; ("cancelled", "task has been cancelled")
]
)
let cancel =
call ~name:"cancel" ~in_product_since:rel_rio
~doc:
"Request that a task be cancelled. Note that a task may fail to be \
cancelled and may complete or fail normally and note that, even when \
a task does cancel, it might take an arbitrary amount of time."
~params:[(Ref _task, "task", "The task")]
~errs:[Api_errors.operation_not_allowed]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can cancel any tasks, others can cancel only owned tasks *)
()
let create =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:rel_rio
~name:"create"
~doc:"Create a new task object which must be manually destroyed."
~params:
[
(String, "label", "short label for the new task")
; (String, "description", "longer description for the new task")
]
~result:(Ref _task, "The reference of the created task object")
~allowed_roles:_R_READ_ONLY (* any subject can create tasks *) ()
let destroy =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:rel_rio
~name:"destroy" ~doc:"Destroy the task object"
~params:[(Ref _task, "self", "Reference to the task object")]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can destroy any tasks, others can destroy only owned tasks *)
()
let set_status =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:rel_falcon
~name:"set_status" ~doc:"Set the task status"
~params:
[
(Ref _task, "self", "Reference to the task object")
; (status_type, "value", "task status value to be set")
]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can set status for any tasks, others can set status only for owned tasks *)
()
let set_progress =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:rel_stockholm
~name:"set_progress" ~doc:"Set the task progress"
~params:
[
(Ref _task, "self", "Reference to the task object")
; (Float, "value", "Task progress value to be set")
]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can set status for any tasks, others can set status only for owned tasks *)
()
let set_result =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:"21.3.0"
~name:"set_result" ~doc:"Set the task result"
~params:
[
(Ref _task, "self", "Reference to the task object")
; (String, "value", "Task result to be set")
]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can set result for any tasks, others can set result only for owned tasks *)
()
let set_error_info =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:"21.3.0"
~name:"set_error_info" ~doc:"Set the task error info"
~params:
[
(Ref _task, "self", "Reference to the task object")
; (Set String, "value", "Task error info to be set")
]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can set error_info for any tasks, others can set error_info only for owned tasks *)
()
let set_resident_on =
call ~flags:[`Session] ~in_oss_since:None ~in_product_since:"21.3.0"
~name:"set_resident_on" ~doc:"Set the resident on field"
~params:
[
(Ref _task, "self", "Reference to the task object")
; (Ref _host, "value", "Resident on to be set")
]
~allowed_roles:_R_READ_ONLY
(* POOL_OP can set resident_on for any tasks, others can set error_info only for owned tasks *)
()
(* this permission allows to destroy any task, instead of only the owned ones *)
let extra_permission_task_destroy_any = "task.destroy/any"
let task_allowed_operations =
Enum ("task_allowed_operations", List.map operation_enum [cancel; destroy])
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303
~persist:PersistNothing ~gen_constructor_destructor:false ~name:_task
~descr:"A long-running asynchronous task" ~gen_events:true ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP
~messages:
[
create
; destroy
; cancel
; set_status
; set_progress
; set_result
; set_error_info
]
~contents:
([
uid _task
; namespace ~name:"name" ~contents:(names oss_since_303 DynamicRO) ()
]
@ allowed_and_current_operations task_allowed_operations
@ [
field ~qualifier:DynamicRO ~ty:DateTime "created"
"Time task was created"
; field ~qualifier:DynamicRO ~ty:DateTime "finished"
"Time task finished (i.e. succeeded or failed). If task-status \
is pending, then the value of this field has no meaning"
; field ~qualifier:DynamicRO ~ty:status_type "status"
"current status of the task"
; field ~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:(Ref _session) "session" "the session that created the task"
; field ~qualifier:DynamicRO ~ty:(Ref _host) "resident_on"
"the host on which the task is running"
; field ~qualifier:DynamicRO ~ty:Float "progress"
"This field contains the estimated fraction of the task which is \
complete. This field should not be used to determine whether \
the task is complete - for this the status field of the task \
should be used."
; field ~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:Int "externalpid"
"If the task has spawned a program, the field record the PID of \
the process that the task is waiting on. (-1 if no waiting \
completion of an external program )"
; field ~in_oss_since:None ~internal_deprecated_since:rel_boston
~internal_only:true ~qualifier:DynamicRO ~ty:Int "stunnelpid"
"If the task has been forwarded, this field records the pid of \
the stunnel process spawned to manage the forwarding connection"
; field ~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:Bool "forwarded"
"True if this task has been forwarded to a slave"
; field ~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:(Ref _host) "forwarded_to"
"The host to which the task has been forwarded"
; field ~qualifier:DynamicRO ~ty:String "type"
"if the task has completed successfully, this field contains the \
type of the encoded result (i.e. name of the class whose \
reference is in the result field). Undefined otherwise."
; field ~qualifier:DynamicRO ~ty:String "result"
"if the task has completed successfully, this field contains the \
result value (either Void or an object reference). Undefined \
otherwise."
; field ~qualifier:DynamicRO ~ty:(Set String) "error_info"
"if the task has failed, this field contains the set of \
associated error strings. Undefined otherwise."
; field ~in_product_since:rel_miami ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"
~map_keys_roles:
[
("applies_to", _R_VM_OP)
; ("XenCenterUUID", _R_VM_OP)
; ("XenCenterMeddlingActionTitle", _R_VM_OP)
]
; (* field ~ty:(Set(Ref _alert)) ~in_product_since:rel_miami ~qualifier:DynamicRO "alerts" "all alerts related to this task"; *)
field ~qualifier:DynamicRO ~in_product_since:rel_orlando
~default_value:(Some (VRef "")) ~ty:(Ref _task) "subtask_of"
"Ref pointing to the task this is a substask of."
; field ~qualifier:DynamicRO ~in_product_since:rel_orlando
~ty:(Set (Ref _task)) "subtasks"
"List pointing to all the substasks."
; field ~qualifier:DynamicRO ~in_product_since:rel_dundee ~ty:String
~default_value:
(Some
(VString (Sexplib0.Sexp.to_string Backtrace.(sexp_of_t empty))
)
)
"backtrace" "Function call trace for debugging."
]
)
()
end
(** Many of the objects need to record IO bandwidth *)
let iobandwidth =
let msg = "Disabled and replaced by RRDs" in
[
field ~persist:false ~qualifier:DynamicRO ~ty:Float
~default_value:(Some (VFloat 0.)) "read_kbs" "Read bandwidth (KiB/s)"
~lifecycle:
[
(Published, rel_rio, "")
; (Deprecated, rel_tampa, "Dummy transition")
; (Removed, rel_tampa, msg)
]
; field ~persist:false ~qualifier:DynamicRO ~ty:Float
~default_value:(Some (VFloat 0.)) "write_kbs" "Write bandwidth (KiB/s)"
~lifecycle:
[
(Published, rel_rio, "")
; (Deprecated, rel_tampa, "Dummy transition")
; (Removed, rel_tampa, msg)
]
]
(** Human users *)
module User = struct
let t =
(* DEPRECATED in favor of subject *)
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303
~persist:PersistEverything ~gen_constructor_destructor:true ~name:_user
~descr:"A user of the system" ~gen_events:false
~lifecycle:
[
(Published, rel_rio, "A user of the system")
; (Deprecated, rel_george, "Deprecated in favor of subject")
]
~doccomments:[] ~messages_default_allowed_roles:_R_POOL_ADMIN ~messages:[]
~contents:
[
uid _user
; field ~qualifier:StaticRO "short_name" "short name (e.g. userid)"
; field "fullname" "full name"
; field ~in_product_since:rel_orlando ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"
]
()
end
(* Management of host crash dumps. Note that this would be neater if crashes were stored in
VDIs like VM crashes, however the nature of a host crash dump is that the dom0 has crashed
and has no access to any fancy storage drivers or tools. Plus a host is not guaranteed to
have any SRs at all. *)
module Host_crashdump = struct
let destroy =
call ~name:"destroy"
~doc:"Destroy specified host crash dump, removing it from the disk."
~in_oss_since:None ~in_product_since:rel_rio
~params:[(Ref _host_crashdump, "self", "The host crashdump to destroy")]
~allowed_roles:_R_POOL_OP ()
let upload =
call ~name:"upload"
~doc:"Upload the specified host crash dump to a specified URL"
~in_oss_since:None ~in_product_since:rel_rio
~params:
[
(Ref _host_crashdump, "self", "The host crashdump to upload")
; (String, "url", "The URL to upload to")
; (Map (String, String), "options", "Extra configuration operations")
]
~allowed_roles:_R_POOL_OP ()
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:None
~persist:PersistEverything ~gen_constructor_destructor:false
~name:_host_crashdump ~gen_events:true
~descr:"Represents a host crash dump" ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP ~messages:[destroy; upload]
~contents:
[
uid ~in_oss_since:None _host_crashdump
; field ~in_oss_since:None ~qualifier:StaticRO ~ty:(Ref _host) "host"
"Host the crashdump relates to"
; field ~in_oss_since:None ~qualifier:DynamicRO ~ty:DateTime "timestamp"
"Time the crash happened"
; field ~in_oss_since:None ~qualifier:DynamicRO ~ty:Int "size"
"Size of the crashdump"
; field ~qualifier:StaticRO ~ty:String ~in_oss_since:None
~internal_only:true "filename" "filename of crash dir"
; field ~in_product_since:rel_miami ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"
]
()
end
(* New Ely pool update mechanism *)
module Pool_update = struct
let livepatch_status =
Enum
( "livepatch_status"
, [
( "ok_livepatch_complete"
, "An applicable live patch exists for every required component"
)
; ( "ok_livepatch_incomplete"
, "An applicable live patch exists but it is not sufficient"
)
; ("ok", "There is no applicable live patch")
]
)
let after_apply_guidance =
Enum
( "update_after_apply_guidance"
, [
( "restartHVM"
, "This update requires HVM guests to be restarted once applied."
)
; ( "restartPV"
, "This update requires PV guests to be restarted once applied."
)
; ( "restartHost"
, "This update requires the host to be restarted once applied."
)
; ( "restartXAPI"
, "This update requires XAPI to be restarted once applied."
)
]
)
let introduce =
call ~name:"introduce" ~doc:"Introduce update VDI" ~in_oss_since:None
~in_product_since:rel_ely
~params:[(Ref _vdi, "vdi", "The VDI which contains a software update.")]
~result:(Ref _pool_update, "the introduced pool update")
~allowed_roles:_R_POOL_OP ()
let precheck =
call ~name:"precheck"
~doc:"Execute the precheck stage of the selected update on a host"
~in_oss_since:None ~in_product_since:rel_ely
~params:
[
(Ref _pool_update, "self", "The update whose prechecks will be run")
; (Ref _host, "host", "The host to run the prechecks on.")
]
~result:(livepatch_status, "The precheck pool update")
~allowed_roles:_R_POOL_OP
~forward_to:(HostExtension "pool_update.precheck") ()
let apply =
call ~name:"apply" ~doc:"Apply the selected update to a host"
~in_oss_since:None ~in_product_since:rel_ely
~params:
[
(Ref _pool_update, "self", "The update to apply")
; (Ref _host, "host", "The host to apply the update to.")
]
~allowed_roles:_R_POOL_OP ~forward_to:(HostExtension "pool_update.apply")
()
let pool_apply =
call ~name:"pool_apply"
~doc:"Apply the selected update to all hosts in the pool"
~in_oss_since:None ~in_product_since:rel_ely
~params:[(Ref _pool_update, "self", "The update to apply")]
~allowed_roles:_R_POOL_OP ()
let pool_clean =
call ~name:"pool_clean"
~doc:
"Removes the update's files from all hosts in the pool, but does not \
revert the update"
~in_oss_since:None ~in_product_since:rel_ely
~params:[(Ref _pool_update, "self", "The update to clean up")]
~allowed_roles:_R_POOL_OP ()
let destroy =
call ~name:"destroy"
~doc:"Removes the database entry. Only works on unapplied update."
~in_oss_since:None ~in_product_since:rel_ely
~params:[(Ref _pool_update, "self", "The update to destroy")]
~allowed_roles:_R_POOL_OP ()
let attach =
call ~name:"attach" ~hide_from_docs:true ~doc:"Attach the pool update VDI"
~in_oss_since:None ~in_product_since:rel_ely
~versioned_params:
[
{
param_type= Ref _pool_update
; param_name= "self"
; param_doc= "The update to be attached"
; param_release= ely_release
; param_default= None
}
; {
param_type= Bool
; param_name= "use_localhost_proxy"
; param_doc= "Use the localhost proxy"
; param_release= naples_release
; param_default= Some (VBool false)
}
]
~result:(String, "The file URL of pool update")
~allowed_roles:_R_POOL_OP ()
let detach =
call ~name:"detach" ~hide_from_docs:true ~doc:"Detach the pool update VDI"
~in_oss_since:None ~in_product_since:rel_ely
~params:[(Ref _pool_update, "self", "The update to be detached")]
~allowed_roles:_R_POOL_OP ()
let resync_host =
call ~name:"resync_host" ~hide_from_docs:true
~doc:"Resync the applied updates of the host" ~in_oss_since:None
~in_product_since:rel_ely
~params:[(Ref _host, "host", "The host to resync the applied updates")]
~allowed_roles:_R_POOL_OP ()
let t =
create_obj ~in_db:true ~in_product_since:rel_ely ~in_oss_since:None
~persist:PersistEverything ~gen_constructor_destructor:false
~gen_events:true ~name:_pool_update
~descr:"Pool-wide updates to the host software" ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP
~messages:
[
introduce
; precheck
; apply
; pool_apply
; pool_clean
; destroy
; attach
; detach
; resync_host
]
~contents:
[
uid ~in_oss_since:None _pool_update
; namespace ~name:"name" ~contents:(names None StaticRO) ()
; field ~in_product_since:rel_ely ~default_value:(Some (VString ""))
~in_oss_since:None ~qualifier:StaticRO ~ty:String "version"
"Update version number"
; field ~in_product_since:rel_ely
~default_value:(Some (VInt Int64.zero)) ~in_oss_since:None
~qualifier:StaticRO ~ty:Int "installation_size"
"Size of the update in bytes"
; field ~in_product_since:rel_ely ~default_value:(Some (VString ""))
~in_oss_since:None ~qualifier:StaticRO ~ty:String "key"
"GPG key of the update"
; field ~in_product_since:rel_ely ~default_value:(Some (VSet []))
~in_oss_since:None ~qualifier:StaticRO
~ty:(Set after_apply_guidance) "after_apply_guidance"
"What the client should do after this update has been applied."
; field ~in_oss_since:None ~qualifier:StaticRO ~ty:(Ref _vdi) "vdi"
"VDI the update was uploaded to"
; field ~in_product_since:rel_ely ~in_oss_since:None
~qualifier:DynamicRO ~ty:(Set (Ref _host)) "hosts"
"The hosts that have applied this update."
; field ~in_product_since:rel_inverness ~default_value:(Some (VMap []))
~in_oss_since:None
~ty:(Map (String, String))
"other_config" "additional configuration"
; field ~in_product_since:rel_inverness
~default_value:(Some (VBool false)) ~in_oss_since:None
~qualifier:StaticRO ~ty:Bool "enforce_homogeneity"
"Flag - if true, all hosts in a pool must apply this update"
]
()
end
(* New Miami pool patching mechanism *)
module Pool_patch = struct
let after_apply_guidance =
Enum
( "after_apply_guidance"
, [
( "restartHVM"
, "This patch requires HVM guests to be restarted once applied."
)
; ( "restartPV"
, "This patch requires PV guests to be restarted once applied."
)
; ( "restartHost"
, "This patch requires the host to be restarted once applied."
)
; ( "restartXAPI"
, "This patch requires XAPI to be restarted once applied."
)
]
)
let apply =
call ~name:"apply"
~doc:"Apply the selected patch to a host and return its output"
~in_oss_since:None ~in_product_since:rel_miami
~params:
[
(Ref _pool_patch, "self", "The patch to apply")
; (Ref _host, "host", "The host to apply the patch too")
]
~result:(String, "the output of the patch application process")
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let precheck =
call ~name:"precheck"
~doc:
"Execute the precheck stage of the selected patch on a host and return \
its output"
~in_oss_since:None ~in_product_since:rel_miami
~params:
[
(Ref _pool_patch, "self", "The patch whose prechecks will be run")
; (Ref _host, "host", "The host to run the prechecks on")
]
~result:(String, "the output of the patch prechecks")
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let clean =
call ~name:"clean" ~doc:"Removes the patch's files from the server"
~in_oss_since:None ~in_product_since:rel_miami
~params:[(Ref _pool_patch, "self", "The patch to clean up")]
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let clean_on_host =
call ~name:"clean_on_host"
~doc:"Removes the patch's files from the specified host"
~in_oss_since:None ~in_product_since:rel_tampa
~params:
[
(Ref _pool_patch, "self", "The patch to clean up")
; (Ref _host, "host", "The host on which to clean the patch")
]
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let pool_clean =
call ~name:"pool_clean"
~doc:
"Removes the patch's files from all hosts in the pool, but does not \
remove the database entries"
~in_oss_since:None ~in_product_since:rel_tampa
~params:[(Ref _pool_patch, "self", "The patch to clean up")]
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let destroy =
call ~name:"destroy"
~doc:
"Removes the patch's files from all hosts in the pool, and removes the \
database entries. Only works on unapplied patches."
~in_oss_since:None ~in_product_since:rel_miami
~params:[(Ref _pool_patch, "self", "The patch to destroy")]
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let pool_apply =
call ~name:"pool_apply"
~doc:
"Apply the selected patch to all hosts in the pool and return a map of \
host_ref -> patch output"
~in_oss_since:None ~in_product_since:rel_miami
~params:[(Ref _pool_patch, "self", "The patch to apply")]
~allowed_roles:_R_POOL_OP ~internal_deprecated_since:rel_ely ()
let t =
create_obj ~in_db:true ~in_product_since:rel_miami ~in_oss_since:None
~internal_deprecated_since:(Some rel_ely) ~persist:PersistEverything
~gen_constructor_destructor:false ~gen_events:true ~name:_pool_patch
~descr:"Pool-wide patches" ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP
~messages:
[apply; pool_apply; precheck; clean; pool_clean; destroy; clean_on_host]
~contents:
[
uid ~in_oss_since:None _pool_patch
; namespace ~name:"name" ~contents:(names None StaticRO) ()
; field ~in_product_since:rel_miami ~default_value:(Some (VString ""))
~in_oss_since:None ~qualifier:StaticRO ~ty:String "version"
"Patch version number"
; field ~in_product_since:rel_miami ~default_value:(Some (VString ""))
~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:String "filename" "Filename of the patch"
; field ~in_product_since:rel_miami
~default_value:(Some (VInt Int64.zero)) ~in_oss_since:None
~qualifier:DynamicRO ~ty:Int "size" "Size of the patch"
; field ~in_product_since:rel_miami ~default_value:(Some (VBool false))
~in_oss_since:None ~qualifier:DynamicRO ~ty:Bool "pool_applied"
"This patch should be applied across the entire pool"
; field ~in_product_since:rel_miami ~in_oss_since:None
~qualifier:DynamicRO ~ty:(Set (Ref _host_patch)) "host_patches"
"This hosts this patch is applied to."
; field ~in_product_since:rel_miami ~default_value:(Some (VSet []))
~in_oss_since:None ~qualifier:DynamicRO
~ty:(Set after_apply_guidance) "after_apply_guidance"
"What the client should do after this patch has been applied."
; field ~in_product_since:rel_ely ~default_value:(Some (VRef null_ref))
~in_oss_since:None ~qualifier:StaticRO ~ty:(Ref _pool_update)
"pool_update" "A reference to the associated pool_update object"
; field ~in_product_since:rel_miami ~default_value:(Some (VMap []))
~in_oss_since:None
~ty:(Map (String, String))
"other_config" "additional configuration"
]
()
end
(* Management of host patches. Just like the crash dumps it would be marginally neater if
the patches were stored as VDIs. *)
module Host_patch = struct
let destroy =
call ~name:"destroy"
~doc:
"Destroy the specified host patch, removing it from the disk. This \
does NOT reverse the patch"
~in_oss_since:None ~in_product_since:rel_rio
~params:[(Ref _host_patch, "self", "The patch to destroy")]
~internal_deprecated_since:rel_miami ~allowed_roles:_R_POOL_OP ()
let apply =
call ~name:"apply" ~doc:"Apply the selected patch and return its output"
~in_oss_since:None ~in_product_since:rel_rio
~params:[(Ref _host_patch, "self", "The patch to apply")]
~result:(String, "the output of the patch application process")
~internal_deprecated_since:rel_miami ~allowed_roles:_R_POOL_OP ()
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:None
~internal_deprecated_since:(Some rel_ely) ~persist:PersistEverything
~gen_constructor_destructor:false ~name:_host_patch ~gen_events:true
~descr:"Represents a patch stored on a server" ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP ~messages:[destroy; apply]
~contents:
[
uid ~in_oss_since:None _host_patch
; namespace ~name:"name" ~contents:(names None StaticRO) ()
; field ~in_oss_since:None ~qualifier:StaticRO ~ty:String "version"
"Patch version number"
; field ~in_oss_since:None ~qualifier:StaticRO ~ty:(Ref _host) "host"
"Host the patch relates to"
; field ~in_oss_since:None ~internal_only:true ~qualifier:DynamicRO
~ty:String "filename" "Filename of the patch"
; field ~in_oss_since:None ~qualifier:DynamicRO ~ty:Bool "applied"
"True if the patch has been applied"
; field ~in_oss_since:None ~qualifier:DynamicRO ~ty:DateTime
"timestamp_applied" "Time the patch was applied"
; field ~in_oss_since:None ~qualifier:DynamicRO ~ty:Int "size"
"Size of the patch"
; field ~in_product_since:rel_miami ~in_oss_since:None
~qualifier:StaticRO ~ty:(Ref _pool_patch)
~default_value:(Some (VRef "")) "pool_patch" "The patch applied"
; field ~in_product_since:rel_miami ~default_value:(Some (VMap []))
~in_oss_since:None
~ty:(Map (String, String))
"other_config" "additional configuration"
]
()
end
module Host_metrics = struct
let host_metrics_memory =
let field = field ~ty:Int in
[
field ~qualifier:DynamicRO "total" "Total host memory (bytes)"
~doc_tags:[Memory]
; field "free" "Free host memory (bytes)" ~default_value:(Some (VInt 0L))
~lifecycle:
[
(Published, rel_rio, "")
; (Deprecated, rel_midnight_ride, "Will be disabled in favour of RRD")
; (Removed, rel_tampa, "Disabled in favour of RRD")
]
~qualifier:DynamicRO ~doc_tags:[Memory]
]
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303
~persist:PersistEverything ~gen_constructor_destructor:false
~name:_host_metrics ~descr:"The metrics associated with a host"
~gen_events:true ~doccomments:[]
~messages_default_allowed_roles:_R_POOL_OP ~messages:[]
~contents:
[
uid _host_metrics
; namespace ~name:"memory" ~contents:host_metrics_memory ()
; field ~qualifier:DynamicRO ~ty:Bool ~in_oss_since:None "live"
"Pool master thinks this host is live"
; field ~qualifier:DynamicRO ~ty:DateTime "last_updated"
"Time at which this information was last updated"
; field ~in_product_since:rel_orlando ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"
]
()
end
(** HostCPU *)
module Host_cpu = struct
let t =
create_obj ~in_db:true ~in_product_since:rel_rio ~in_oss_since:oss_since_303
~persist:PersistEverything ~gen_constructor_destructor:false
~name:_hostcpu ~descr:"A physical CPU" ~gen_events:true
~lifecycle:
[
(Published, rel_rio, "A physical CPU")
; ( Deprecated
, rel_midnight_ride
, "Deprecated in favour of the Host.cpu_info field"
)
]
~doccomments:[] ~messages_default_allowed_roles:_R_POOL_OP ~messages:[]
~contents:
[
uid _hostcpu
; field ~qualifier:DynamicRO ~ty:(Ref _host) "host"
"the host the CPU is in"
; field ~qualifier:DynamicRO ~ty:Int "number"
"the number of the physical CPU within the host"
; field ~qualifier:DynamicRO ~ty:String "vendor"
"the vendor of the physical CPU"
; field ~qualifier:DynamicRO ~ty:Int "speed"
"the speed of the physical CPU"
; field ~qualifier:DynamicRO ~ty:String "modelname"
"the model name of the physical CPU"
; field ~qualifier:DynamicRO ~ty:Int "family"
"the family (number) of the physical CPU"
; field ~qualifier:DynamicRO ~ty:Int "model"
"the model number of the physical CPU"
; field ~qualifier:DynamicRO ~ty:String "stepping"
"the stepping of the physical CPU"
; field ~qualifier:DynamicRO ~ty:String "flags"
"the flags of the physical CPU (a decoded version of the features \
field)"
; field ~qualifier:DynamicRO ~ty:String "features"
"the physical CPU feature bitmap"
; field ~qualifier:DynamicRO ~persist:false ~ty:Float "utilisation"
"the current CPU utilisation"
; field ~in_product_since:rel_orlando ~default_value:(Some (VMap []))
~ty:(Map (String, String))
"other_config" "additional configuration"