33b2d8c303ba15c95fbbfb205627439ce2bb35b2
[pharos.git] / config / pdf / pod1.schema.yaml
1 ##############################################################################
2 # Copyright (c) 2018 Enea AB and others.
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 ##############################################################################
8 ---
9 $schema: 'http://json-schema.org/schema#'
10 $id: 'https://github.com/opnfv/pharos/blob/master/config/pdf/pod1.yaml'
11
12 definitions:
13   ############################################################################
14   # Low-level, general purpose definitions, unversioned
15   ip_address:
16     type: 'string'  # NOTE: we don't validate this is a valid addr (yet)
17   mac_address:
18     type: 'string'
19     pattern: '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
20   ############################################################################
21   # Mid-level definitions, common schema for jumpserver & cluster nodes
22   node:
23     v1.0:
24       type: 'object'
25       properties:
26         type:
27           type: 'string'
28           enum: ['baremetal', 'virtual']
29         vendor:
30           type: 'string'
31         model:
32           type: 'string'
33         arch:
34           type: 'string'
35           enum: ['aarch64', 'x86_64']
36         cpus:
37           type: 'number'
38         cpu_cflags:
39           type: 'string'
40         cores:
41           type: 'number'
42         memory:
43           type: 'string'
44           pattern: '^[1-9]\d*[MGT]B?$'
45       required: ['type', 'vendor', 'model', 'arch', 'cpus', 'cpu_cflags', 'cores', 'memory']
46       additionalProperties: false
47   disks:
48     v1.0:
49       type: 'array'
50       items:
51         type: 'object'
52         properties:
53           name:
54             type: 'string'
55             pattern: '^disk[0-9]+$'
56           disk_capacity:
57             type: 'string'
58             pattern: '^[1-9][\d\.]*[MGT]B?$'
59           disk_type:
60             type: 'string'
61             enum: ['hdd', 'ssd', 'cdrom', 'tape']
62           disk_interface:
63             type: 'string'
64             enum: ['sata', 'sas', 'ssd', 'nvme', 'scsi', 'iscsi']
65           disk_rotation:
66             type: 'number'
67             enum: [0, 5400, 7200, 10000, 15000]
68         required: ['name', 'disk_capacity', 'disk_type', 'disk_interface', 'disk_rotation']
69         additionalProperties: false
70   remote_management:
71     v1.0:
72       properties:
73         user:
74           type: 'string'
75         pass:
76           type: 'string'
77         type:
78           type: 'string'
79         versions:
80           type: 'array'
81         address:
82           type: 'string'
83         mac_address:
84           type: 'string'
85       # These subsections are best validated separately for baremetal/virtual
86       oneOf:
87         - type: 'object'
88           properties:
89             type:
90               type: 'string'
91               enum: ['ipmi', 'amt']
92             versions:
93               type: 'array'
94               items:
95                 type: 'number'
96                 enum: [1.0, 2.0]
97             address:
98               $ref: '#/definitions/ip_address'
99             mac_address:
100               $ref: '#/definitions/mac_address'
101           required: ['type', 'versions', 'address', 'mac_address']
102         - type: 'object'
103           properties:
104             type:
105               type: 'string'
106               enum: ['libvirt']
107             address:
108               type: 'string'  # Loose validation of libvirt URI for now
109           required: ['type', 'address']
110       required: ['user', 'pass']
111       additionalProperties: false
112   interfaces:
113     v1.0:
114       type: 'array'
115       items:
116         type: 'object'
117         properties:
118           name:
119             type: 'string'
120             pattern: '^nic[0-9]+$'
121           mac_address:
122             $ref: '#/definitions/mac_address'
123           # Optional
124           address:
125             $ref: '#/definitions/ip_address'
126           # Optional
127           vlan:
128             oneOf:
129               - type: 'string'
130                 pattern: '^(native|[1-9][0-9]{0,3})(\|(native|[1-9][0-9]{0,3}))*$'
131               - type: 'integer'
132                 mininum: 1
133                 maximum: 4095
134           # Optional
135           speed:
136             type: 'string'
137             enum: ['1gb', '10gb', '25gb', '40gb']
138             # FIXME: mandatory for nodes?
139           # Optional
140           features:
141             type: ['string', 'null']
142             pattern: '^((dpdk|sriov)\|?)*$'
143             # FIXME: mandatory for nodes?
144         required: ['name', 'mac_address']
145         additionalProperties: false
146   ############################################################################
147   # Top-level PDF blocks, versioned
148   details:
149     v1.0:
150       type: 'object'
151       properties:
152         type:
153           type: 'string'
154           enum: ['production', 'development']
155         pod_owner:
156           type: 'string'
157         contact:
158           type: 'string'
159           pattern: '^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+[,; ]*)+$'
160         lab:
161           type: 'string'
162         location:
163           type: 'string'
164         link:
165           type: 'string'
166       required: ['type', 'pod_owner', 'contact', 'lab', 'location', 'link']
167       additionalProperties: false
168   jumphost:
169     v1.0:
170       type: 'object'
171       properties:
172         name:
173           type: 'string'
174         node:
175           $ref: '#/definitions/node/v1.0'
176         disks:
177           $ref: '#/definitions/disks/v1.0'
178         os:
179           type: 'string'
180         remote_params:  # Optional YAML anchor, contents will be validated below
181           type: 'object'
182         remote_management:
183           $ref: '#/definitions/remote_management/v1.0'
184         interfaces:
185           $ref: '#/definitions/interfaces/v1.0'
186       required: ['name', 'node', 'disks', 'os', 'remote_management', 'interfaces']
187       additionalProperties: false
188   nodes:
189     v1.0:
190       type: 'array'
191       items:
192         type: 'object'
193         properties:
194           name:
195             type: 'string'
196           node:
197             $ref: '#/definitions/node/v1.0'
198           disks:
199             $ref: '#/definitions/disks/v1.0'
200           os:
201             type: 'string'
202           remote_params:  # Optional YAML anchor, contents will be validated after inject
203             type: 'object'
204           remote_management:
205             $ref: '#/definitions/remote_management/v1.0'
206           interfaces:
207             $ref: '#/definitions/interfaces/v1.0'
208         required: ['name', 'node', 'disks', 'remote_management', 'interfaces']
209         additionalProperties: false
210
211 ##############################################################################
212 # Top-level structure:
213 # - define all possible top-level keys, without enforcing a schema for them,
214 #   just so we can disallow additional properties;
215 # - require 'version' and allow dynamically generated 'version_x.y' key;
216 properties:
217   # version_x.y keys are auto-added by `validate_schema.py` based on 'version'
218   version_1.0:
219     type: 'boolean'
220   version:
221     type: 'number'
222     enum: [1.0]
223   details:
224     type: 'object'
225   jumphost:
226     type: 'object'
227   nodes:
228     type: 'array'
229 required: ['version']
230 additionalProperties: false
231
232 ##############################################################################
233 # Schema versioning
234 # - based on dynamically added 'version_x.y', require additional PDF blocks
235 #   and validate them against the proper schema version;
236 dependencies:
237   version_1.0:
238     properties:
239       details:
240         $ref: '#/definitions/details/v1.0'
241       jumphost:
242         $ref: '#/definitions/jumphost/v1.0'
243       nodes:
244         $ref: '#/definitions/nodes/v1.0'
245     required: ['details', 'jumphost', 'nodes']