This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
/
nova_schemas.py
2378 lines (2308 loc) · 91.3 KB
/
nova_schemas.py
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
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import copy
from typing import Any
from nova.api.openstack.compute.schemas import flavors_extraspecs
from nova.api.openstack.compute.schemas import quota_sets
from nova.api.openstack.compute.schemas import remote_consoles
from nova.api.validation import parameter_types
# NOTE(gtema): This is a temporary location for schemas not currently defined
# in Nova. Once everything is stabilized those must be moved directly to Nova
LINK_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Links to the resources in question. See [API Guide / Links and References](https://docs.openstack.org/api-guide/compute/links_and_references.html) for more info.",
"properties": {
"href": {"type": "string", "format": "uri"},
"rel": {"type": "string"},
},
}
LINKS_SCHEMA: dict[str, Any] = {
"type": "array",
"description": "Links to the resources in question. See [API Guide / Links and References](https://docs.openstack.org/api-guide/compute/links_and_references.html) for more info.",
"items": copy.deepcopy(LINK_SCHEMA),
}
SERVER_TAGS_SCHEMA: dict[str, Any] = {
"description": "Server Tags",
"type": "object",
"properties": {
"tags": {
"type": "array",
"description": "A list of tags. The maximum count of tags in this list is 50.",
"items": {
"type": "string",
},
}
},
}
SERVER_TOPOLOGY_SCHEMA: dict[str, Any] = {
"description": "NUMA topology information for a server",
"type": "object",
"properties": {
"nodes": {
"description": "NUMA nodes information of a server",
"type": "array",
"items": {
"type": "object",
"description": "NUMA node information of a server",
"properties": {
"cpu_pinning": {
"type": "object",
"description": "The mapping of server cores to host physical CPU",
"additionalProperties": {
"type": "integer",
},
},
"vcpu_set": {
"type": "array",
"description": "A list of IDs of the virtual CPU assigned to this NUMA node.",
"items": {"type": "integer"},
},
"siblings": {
"type": "array",
"description": "A mapping of host cpus thread sibling.",
"items": {"type": "integer"},
},
"memory_mb": {
"type": "integer",
"description": "The amount of memory assigned to this NUMA node in MB.",
},
"host_node": {
"type": "integer",
"description": "The host NUMA node the virtual NUMA node is map to.",
},
"pagesize_kb": {
"type": ["integer", "null"],
"description": "The page size in KB of a server. This field is null if the page size information is not available.",
},
},
},
}
},
}
FLAVOR_EXTRA_SPEC_SCHEMA: dict[str, Any] = {
"minProperties": 1,
"maxProperties": 1,
"examples": {"JSON Request": {"hw:numa_nodes": "1"}},
**flavors_extraspecs.metadata,
}
FLAVOR_EXTRA_SPECS_SCHEMA: dict[str, Any] = flavors_extraspecs.metadata
FLAVOR_EXTRA_SPECS_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "A dictionary of the flavor’s extra-specs key-and-value pairs. It appears in the os-extra-specs’ “create” REQUEST body, as well as the os-extra-specs’ “create” and “list” RESPONSE body.",
"properties": {"extra_specs": flavors_extraspecs.metadata},
}
FLAVOR_SHORT_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"id": {"type": "string", "format": "uuid"},
"name": {"type": "string"},
"description": {"type": "string"},
"links": LINKS_SCHEMA,
},
}
FLAVOR_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The display name of a flavor.",
},
"id": {
"type": "string",
"description": "The ID of the flavor. While people often make this look like an int, this is really a string.",
"minLength": 1,
"maxLength": 255,
"pattern": "^(?! )[a-zA-Z0-9. _-]+(?<! )$",
},
"ram": {
"description": "The amount of RAM a flavor has, in MiB.",
**parameter_types.flavor_param_positive,
},
"vcpus": {
"description": "The number of virtual CPUs that will be allocated to the server.",
**parameter_types.flavor_param_positive,
},
"disk": {
"description": "The size of the root disk that will be created in GiB. If 0 the root disk will be set to exactly the size of the image used to deploy the instance. However, in this case the scheduler cannot select the compute host based on the virtual image size. Therefore, 0 should only be used for volume booted instances or for testing purposes. Volume-backed instances can be enforced for flavors with zero root disk via the os_compute_api:servers:create:zero_disk_flavor policy rule.",
**parameter_types.flavor_param_non_negative,
},
"OS-FLV-EXT-DATA:ephemeral": {
"description": "The size of the ephemeral disk that will be created, in GiB. Ephemeral disks may be written over on server state changes. So should only be used as a scratch space for applications that are aware of its limitations. Defaults to 0.",
**parameter_types.flavor_param_non_negative,
},
"swap": {
"description": "The size of a dedicated swap disk that will be allocated, in MiB. If 0 (the default), no dedicated swap disk will be created. Currently, the empty string (‘’) is used to represent 0. As of microversion 2.75 default return value of swap is 0 instead of empty string.",
**parameter_types.flavor_param_non_negative,
},
"rxtx_factor": {
"description": "The receive / transmit factor (as a float) that will be set on ports if the network backend supports the QOS extension. Otherwise it will be ignored. It defaults to 1.0.",
"type": ["number", "string"],
"pattern": r"^[0-9]+(\.[0-9]+)?$",
"minimum": 0,
"exclusiveMinimum": True,
"maximum": 3.40282e38,
},
"os-flavor-access:is_public": {
"description": "Whether the flavor is public (available to all projects) or scoped to a set of projects. Default is True if not specified.",
**parameter_types.boolean,
},
"extra_specs": FLAVOR_EXTRA_SPECS_SCHEMA,
"links": LINKS_SCHEMA,
},
"additionalProperties": False,
}
FLAVOR_CONTAINER_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Single flavor details",
"properties": {"flavor": copy.deepcopy(FLAVOR_SCHEMA)},
}
FLAVORS_LIST_SCHEMA: dict[str, Any] = {
"description": "Flavors list response",
"type": "object",
"properties": {
"flavors": {
"type": "array",
"items": copy.deepcopy(FLAVOR_SHORT_SCHEMA),
}
},
}
FLAVORS_LIST_DETAIL_SCHEMA: dict[str, Any] = {
"description": "Detailed flavors list response",
"type": "object",
"properties": {
"flavors": {"type": "array", "items": copy.deepcopy(FLAVOR_SCHEMA)}
},
}
FLAVOR_ACCESS_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"flavor_id": {"type": "string", "format": "uuid"},
"tenant_id": {"type": "string", "format": "uuid"},
},
}
FLAVOR_ACCESSES_SCHEMA: dict[str, Any] = {
"description": "A list of objects, each with the keys flavor_id and tenant_id.",
"type": "object",
"properties": {
"flavor_access": {
"type": "array",
"items": copy.deepcopy(FLAVOR_ACCESS_SCHEMA),
}
},
}
LIMITS_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Data structure that contains both absolute limits within a deployment.",
"properties": {
"absolute": {
"type": "object",
"properties": {
"maxServerGroupMembers": {
"type": "integer",
"description": "The number of allowed members for each server group.",
},
"maxServerGroups": {
"type": "integer",
"description": "The number of allowed server groups for each tenant.",
},
"maxServerMetamaxServerMeta": {
"type": "integer",
"description": "The number of allowed metadata items for each server.",
},
"maxTotalCores": {
"type": "integer",
"description": "The number of allowed server cores for each tenant.",
},
"maxTotalInstances": {
"type": "integer",
"description": "The number of allowed servers for each tenant.",
},
"maxTotalKeypairs": {
"type": "integer",
"description": "The number of allowed key pairs for each user.",
},
"maxTotalRAMSize": {
"type": "integer",
"description": "The amount of allowed server RAM, in MiB, for each tenant.",
},
"totalCoresUsed": {
"type": "integer",
"description": "The number of used server cores in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server cores are also included.",
},
"totalInstancesUsed": {
"type": "integer",
"description": "The number of servers in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved servers are also included.",
},
"totalRAMUsed": {
"type": "integer",
"description": "The amount of used server RAM in each tenant. If reserved query parameter is specified and it is not 0, the amount of reserved server RAM is also included.",
},
"totalServerGroupsUsed": {
"type": "integer",
"description": "The number of used server groups in each tenant. If reserved query parameter is specified and it is not 0, the number of reserved server groups are also included.",
},
},
"additionalProperties": {"type": "integer"},
},
},
}
AGGREGATE_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The host aggregate object",
"properties": {
"availability_zone": {
"type": "string",
"description": "The availability zone of the host aggregate.",
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was created.",
},
"deleted": {
"type": "boolean",
"description": "A boolean indicates whether this aggregate is deleted or not, if it has not been deleted, false will appear.",
},
"deleted_at": {
"type": ["string", "null"],
"format": "date-time",
"description": "The date and time when the resource was deleted. If the resource has not been deleted yet, this field will be null.",
},
"id": {
"type": "integer",
"description": "The ID of the host aggregate.",
},
"metadata": parameter_types.metadata,
"hosts": {
"type": "array",
"description": "A list of host ids in this aggregate.",
"items": {"type": "string"},
},
"updated_at": {
"type": ["string", "null"],
"format": "date-time",
"description": "The date and time when the resource was updated, if the resource has not been updated, this field will show as null.",
},
"uuid": {
"type": "string",
"format": "uuid",
"description": "The UUID of the host aggregate. New in version 2.41",
"x-openstack": {"min-ver": "2.41"},
},
},
}
AGGREGATE_CONTAINER_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Aggregate object.",
"properties": {"aggregate": copy.deepcopy(AGGREGATE_SCHEMA)},
}
AGGREGATE_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The list of existing aggregates.",
"properties": {
"aggregates": {
"type": "array",
"description": "The list of existing aggregates.",
"items": copy.deepcopy(AGGREGATE_SCHEMA),
}
},
}
VOLUME_SNAPSHOT_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "A partial representation of a snapshot that is used to create a snapshot.",
"properties": {
"snapshot": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "Its the same arbitrary string which was sent in request body.",
},
"volumeId": {
"type": "string",
"format": "uuid",
"description": "The source volume ID.",
},
},
}
},
}
AZ_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"zoneName": {
"type": "string",
"description": "The availability zone name.",
},
"zoneState": {
"type": "object",
"description": "The current state of the availability zone.",
"properties": {
"available": {
"type": "boolean",
"description": "Returns true if the availability zone is available.",
}
},
},
"hosts": {"type": "null", "description": "It is always null."},
},
}
AZ_DETAIL_SCHEMA: dict[str, Any] = copy.deepcopy(AZ_SCHEMA)
AZ_DETAIL_SCHEMA["properties"]["hosts"] = {
"type": "object",
"description": "An object containing a list of host information. The host information is comprised of host and service objects. The service object returns three parameters representing the states of the service: active, available, and updated_at.",
"examples": {
"JSON request": {
"conductor": {
"nova-conductor": {
"active": True,
"available": True,
"updated_at": None,
}
},
"scheduler": {
"nova-scheduler": {
"active": True,
"available": True,
"updated_at": None,
}
},
}
},
}
AZ_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"availabilityZoneInfo": {
"type": "array",
"description": "The list of availability zone information.",
"items": copy.deepcopy(AZ_SCHEMA),
}
},
}
AZ_LIST_DETAIL_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"availabilityZoneInfo": {
"type": "array",
"description": "The list of availability zone information.",
"items": copy.deepcopy(AZ_DETAIL_SCHEMA),
}
},
}
CONSOLE_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Show Console Connection Information Response",
"properties": {
"console": {
"type": "object",
"description": "The console object.",
"properties": {
"instance_uuid": {
"type": "string",
"format": "uuid",
"description": "The UUID of the server.",
},
"host": {
"type": "string",
"description": "The name or ID of the host.",
},
"port": {"type": "integer", "description": "The port number."},
"internal_access_path": {
"type": "string",
"description": "The id representing the internal access path.",
},
},
"required": ["instance_uuid", "port"],
}
},
}
REMOTE_CONSOLE_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Create Console Response",
"properties": {
"remote_console": {
"type": "object",
"description": "The remote console object.",
"properties": {
"protocol": {
"type": "string",
"enum": remote_consoles.create_v28["properties"][
"remote_console"
]["properties"]["protocol"]["enum"],
"description": "The protocol of remote console. The valid values are vnc, spice, rdp, serial and mks. The protocol mks is added since Microversion 2.8.",
},
"type": {
"type": "string",
"enum": remote_consoles.create_v28["properties"][
"remote_console"
]["properties"]["type"]["enum"],
"description": "The type of remote console. The valid values are novnc, rdp-html5, spice-html5, serial, and webmks. The type webmks is added since Microversion 2.8.",
},
"url": {
"type": "string",
"format": "uri",
"description": "The URL is used to connect the console.",
},
},
}
},
}
HYPERVISOR_SHORT_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The hypervisor object.",
"properties": {
"hypervisor_hostname": {
"type": "string",
"description": "The hypervisor host name provided by the Nova virt driver. For the Ironic driver, it is the Ironic node uuid.",
},
"id": {
"type": "string",
"description": "The id of the hypervisor. From version 2.53 it is a string as UUID",
},
"state": {
"type": "string",
"enum": ["up", "down"],
"description": "The state of the hypervisor.",
},
"status": {
"type": "string",
"enum": ["disabled", "enabled"],
"description": "The status of the hypervisor.",
},
"servers": {
"type": "array",
"description": "A list of server objects. This field has become mandatory in microversion 2.75. If no servers is on hypervisor then empty list is returned. New in version 2.53",
"x-openstack": {"min-ver": "2.53"},
"items": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuid",
"description": "The server ID.",
},
"name": {
"type": "string",
"description": "The server name.",
},
},
},
},
},
}
HYPERVISOR_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The hypervisor object.",
"properties": {
"cpu_info": {
"type": "object",
"description": "A dictionary that contains cpu information like arch, model, vendor, features and topology. The content of this field is hypervisor specific.",
"additionalProperties": True,
"x-openstack": {"max-ver": "2.87"},
},
"current_workload": {
"type": "integer",
"description": "The current_workload is the number of tasks the hypervisor is responsible for. This will be equal or greater than the number of active VMs on the system (it can be greater when VMs are being deleted and the hypervisor is still cleaning up). Available until version 2.87",
"x-openstack": {"max-ver": "2.87"},
},
"disk_available_least": {
"type": "integer",
"description": "The actual free disk on this hypervisor(in GiB). If allocation ratios used for overcommit are configured, this may be negative. This is intentional as it provides insight into the amount by which the disk is overcommitted. Available until version 2.87",
"x-openstack": {"max-ver": "2.87"},
},
"host_ip": {
"type": "string",
"format": "ip",
"description": "The IP address of the hypervisor’s host.",
},
"free_disk_gb": {
"type": "integer",
"description": "The free disk remaining on this hypervisor(in GiB). This does not take allocation ratios used for overcommit into account so this value may be negative. Available until version 2.87",
"x-openstack": {"max-ver": "2.87"},
},
"free_ram_mb": {
"type": "integer",
"description": "The free RAM in this hypervisor(in MiB). This does not take allocation ratios used for overcommit into account so this value may be negative. Available until version 2.87",
"x-openstack": {"max-ver": "2.87"},
},
"hypervisor_hostname": {
"type": "string",
"description": "The hypervisor host name provided by the Nova virt driver. For the Ironic driver, it is the Ironic node uuid.",
},
"hypervisor_type": {
"type": "string",
"description": "The hypervisor type.",
},
"hypervisor_version": {
"type": "integer",
"description": "The hypervisor version.",
},
"local_gb": {
"type": "integer",
"x-openstack": {
"max-ver": "2.87",
"description": "The disk in this hypervisor (in GiB). This does not take allocation ratios used for overcommit into account so there may be disparity between this and the used count.",
},
},
"local_gb_used": {
"type": "integer",
"x-openstack": {
"max-ver": "2.87",
"description": "The disk used in this hypervisor (in GiB).",
},
},
"memory_mb": {
"type": "integer",
"x-openstack": {
"max-ver": "2.87",
"description": "The memory of this hypervisor (in MiB). This does not take allocation ratios used for overcommit into account so there may be disparity between this and the used count.",
},
},
"memory_mb_used": {
"type": "integer",
"x-openstack": {
"max-ver": "2.87",
"description": "The memory used in this hypervisor (in MiB).",
},
},
"running_vms": {
"type": "integer",
"x-openstack": {
"max-ver": "2.87",
"description": "The number of running VMs on this hypervisor. ",
},
},
"service": {
"type": "object",
"description": "The hypervisor service object.",
"properties": {
"host": {
"type": "string",
"description": "The name of the host.",
},
"id": {
"type": ["integer", "string"],
"format": "uuid",
"description": "The id of the service.",
},
"disabled_reason": {
"type": ["string", "null"],
"description": "The disable reason of the service, null if the service is enabled or disabled without reason provided.",
},
},
},
"uptime": {
"type": "string",
"description": "The total uptime of the hypervisor and information about average load. Only reported for active hosts where the virt driver supports this feature.",
"x-openstack": {"min-ver": "2.87"},
},
"vcpus": {
"type": "integer",
"x-openstack": {"max-ver": "2.87"},
"description": "The number of vCPU in this hypervisor. This does not take allocation ratios used for overcommit into account so there may be disparity between this and the used count.",
},
"vcpus_used": {
"type": "integer",
"x-openstack": {"max-ver": "2.87"},
"description": "The number of vCPU used in this hypervisor.",
},
**HYPERVISOR_SHORT_SCHEMA["properties"],
},
}
HYPERVISOR_CONTAINER_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {"hypervisor": copy.deepcopy(HYPERVISOR_SCHEMA)},
}
HYPERVISOR_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"hypervisors": {
"type": "array",
"description": "An array of hypervisor information.",
"items": copy.deepcopy(HYPERVISOR_SHORT_SCHEMA),
},
"hypervisor_links": LINKS_SCHEMA,
},
}
HYPERVISOR_LIST_DETAIL_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"hypervisors": {
"type": "array",
"description": "An array of hypervisor information.",
"items": copy.deepcopy(HYPERVISOR_SCHEMA),
},
"hypervisor_links": LINKS_SCHEMA,
},
}
INSTANCE_USAGE_AUDIT_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The object of instance usage audit log information.",
"properties": {
"hosts_not_run": {
"type": "array",
"items": {"type": "string"},
"description": "A list of the hosts whose instance audit tasks have not run.",
},
"log": {
"type": "object",
"description": "The object of instance usage audit logs.",
},
"errors": {"type": "integer", "description": "The number of errors."},
"instances": {
"type": "integer",
"description": "The number of instances.",
},
"message": {
"type": "string",
"description": "The log message of the instance usage audit task.",
},
"state": {
"type": "string",
"enum": ["DONE", "RUNNING"],
"description": "The state of the instance usage audit task. DONE or RUNNING.",
},
"num_hosts": {
"type": "integer",
"description": "The number of the hosts.",
},
"num_hosts_done": {
"type": "integer",
"description": "The number of the hosts whose instance audit tasks have been done.",
},
"num_hosts_not_run": {
"type": "integer",
"description": "The number of the hosts whose instance audit tasks have not run.",
},
"num_hosts_running": {
"type": "integer",
"description": "The number of the hosts whose instance audit tasks are running.",
},
"overall_status": {
"type": "string",
"description": (
"The overall status of instance audit tasks."
"M of N hosts done. K errors."
"The M value is the number of hosts whose instance audit tasks have been done in the period. The N value is the number of all hosts. The K value is the number of hosts whose instance audit tasks cause errors. If instance audit tasks have been done at all hosts in the period, the overall status is as follows:"
"ALL hosts done. K errors."
),
},
"period_beginning": {
"type": "string",
"format": "date-time",
"description": "The beginning time of the instance usage audit period. For example, 2016-05-01 00:00:00.",
},
"period_ending": {
"type": "string",
"format": "date-time",
"description": "The ending time of the instance usage audit period. For example, 2016-06-01 00:00:00.",
},
"total_errors": {
"type": "integer",
"description": "The total number of instance audit task errors.",
},
"total_instances": {
"type": "integer",
"description": "The total number of VM instances in the period.",
},
},
}
KEYPAIR_SHORT_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Keypair object",
"properties": {
"name": {"type": "string", "description": "The name for the keypair"},
"public_key": {
"type": "string",
"description": "The keypair public key.",
},
"fingerprint": {
"type": "string",
"description": "The fingerprint for the keypair.",
},
"type": {
"type": "string",
"description": "The type of the keypair. Allowed values are ssh or x509.",
"x-openstack": {"min-ver": "2.2"},
},
},
}
KEYPAIR_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"keypairs": {
"type": "array",
"description": "Array of Keypair objects",
"items": {
"type": "object",
"properties": {
"keypair": copy.deepcopy(KEYPAIR_SHORT_SCHEMA),
},
},
},
"keypairs_links": copy.deepcopy(LINKS_SCHEMA),
},
}
KEYPAIR_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Keypair object",
"properties": {
"user_id": {
"type": "string",
"description": "The user_id for a keypair.",
},
"deleted": {
"type": "boolean",
"description": "A boolean indicates whether this keypair is deleted or not. The value is always false (not deleted).",
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was created.",
},
"deleted_at": {
"type": ["string", "null"],
"format": "date-time",
"description": "It is always null.",
},
"updated_at": {
"type": ["string", "null"],
"format": "date-time",
"description": "It is always null.",
},
"id": {"type": "integer", "description": "The keypair ID."},
**copy.deepcopy(KEYPAIR_SHORT_SCHEMA["properties"]),
},
}
KEYPAIR_CONTAINER_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Keypair object",
"properties": {"keypair": KEYPAIR_SCHEMA},
}
KEYPAIR_CREATED_SCHEMA: dict[str, Any] = copy.deepcopy(
KEYPAIR_CONTAINER_SCHEMA
)
KEYPAIR_CREATED_SCHEMA["properties"]["keypair"]["properties"][
"private_key"
] = {
"type": "string",
"description": "If you do not provide a public key on create, a new keypair will be built for you, and the private key will be returned during the initial create call. Make sure to save this, as there is no way to get this private key again in the future.",
"x-openstack": {"max-ver": "2.91"},
}
MIGRATION_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Migration object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was created.",
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was updated.",
},
"dest_compute": {
"type": "string",
"description": "The target compute for a migration.",
},
"dest_host": {
"type": "string",
"description": "The target host for a migration.",
},
"dest_node": {
"type": "string",
"description": "The target node for a migration.",
},
"id": {
"type": "integer",
"description": "The ID of the server migration.",
},
"instance_uuid": {
"type": "string",
"format": "uuid",
"description": "The UUID of the server.",
},
"new_instance_type_id": {
"type": "integer",
"description": "In resize case, the flavor ID for resizing the server. In the other cases, this parameter is same as the flavor ID of the server when the migration was started.",
},
"old_instance_type_id": {
"type": "integer",
"description": "The flavor ID of the server when the migration was started.",
},
"source_compute": {
"type": "string",
"description": "The source compute for a migration.",
},
"source_node": {
"type": "string",
"description": "The source node for a migration.",
},
"status": {
"type": "string",
"description": "The current status of the migration.",
},
"project_id": {
"type": ["string", "null"],
"description": "The ID of the project which initiated the server migration. The value may be null for older migration records.",
"x-openstack": {"min-ver": "2.80"},
},
"user_id": {
"type": ["string", "null"],
"description": "The ID of the user which initiated the server migration. The value may be null for older migration records.",
"x-openstack": {"min-ver": "2.80"},
},
"migration_type": {
"type": "string",
"enum": ["live-migration", "migration", "resize"],
"description": "The type of the server migration. This is one of live-migration, migration, resize and evacuation. New in version 2.23",
"x-openstack": {"min-ver": "2.23"},
},
"uuid": {
"type": "string",
"format": "uuid",
"description": "The UUID of the migration.",
"x-openstack": {"min-ver": "2.59"},
},
},
}
MIGRATION_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "List of migration objects",
"properties": {
"migrations": {
"type": "array",
"items": copy.deepcopy(MIGRATION_SCHEMA),
},
"migrations_links": {
"x-openstack": {"min-ver": "2.59"},
**copy.deepcopy(LINKS_SCHEMA),
},
},
}
SERVER_MIGRATION_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "Migration object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was created.",
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time when the resource was updated.",
},
"dest_compute": {
"type": "string",
"description": "The target compute for a migration.",
},
"dest_host": {
"type": "string",
"description": "The target host for a migration.",
},
"dest_node": {
"type": "string",
"description": "The target node for a migration.",
},
"id": {
"type": "integer",
"description": "The ID of the server migration.",
},
"source_compute": {
"type": "string",
"description": "The source compute for a migration.",
},
"source_node": {
"type": "string",
"description": "The source node for a migration.",
},
"status": {
"type": "string",
"description": "The current status of the migration.",
},
"project_id": {
"type": ["string", "null"],
"description": "The ID of the project which initiated the server migration. The value may be null for older migration records.",
"x-openstack": {"min-ver": "2.80"},
},
"user_id": {
"type": ["string", "null"],
"description": "The ID of the user which initiated the server migration. The value may be null for older migration records.",
"x-openstack": {"min-ver": "2.80"},
},
"uuid": {
"type": "string",
"format": "uuid",
"description": "The UUID of the migration.",
"x-openstack": {"min-ver": "2.59"},
},
"disk_processed_bytes": {
"type": "integer",
"description": "The amount of disk, in bytes, that has been processed during the migration.",
},
"disk_remaining_bytes": {