Add privilege_level to remote management parameters
[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         privilege_level:
78           type: 'string'
79         type:
80           type: 'string'
81         versions:
82           type: 'array'
83         address:
84           type: 'string'
85         mac_address:
86           type: 'string'
87       # These subsections are best validated separately for baremetal/virtual
88       oneOf:
89         - type: 'object'
90           properties:
91             type:
92               type: 'string'
93               enum: ['ipmi', 'amt']
94             versions:
95               type: 'array'
96               items:
97                 type: 'number'
98                 enum: [1.0, 2.0]
99             address:
100               $ref: '#/definitions/ip_address'
101             mac_address:
102               $ref: '#/definitions/mac_address'
103           required: ['type', 'versions', 'address', 'mac_address']
104         - type: 'object'
105           properties:
106             type:
107               type: 'string'
108               enum: ['libvirt']
109             address:
110               type: 'string'  # Loose validation of libvirt URI for now
111           required: ['type', 'address']
112       required: ['user', 'pass']
113       additionalProperties: false
114   interfaces:
115     v1.0:
116       type: 'array'
117       items:
118         type: 'object'
119         properties:
120           name:
121             type: 'string'
122             pattern: '^nic[0-9]+$'
123           mac_address:
124             $ref: '#/definitions/mac_address'
125           # Optional
126           address:
127             $ref: '#/definitions/ip_address'
128           # Optional
129           vlan:
130             oneOf:
131               - type: 'string'
132                 pattern: '^(native|[1-9][0-9]{0,3})(\|(native|[1-9][0-9]{0,3}))*$'
133               - type: 'integer'
134                 mininum: 1
135                 maximum: 4095
136           # Optional
137           speed:
138             type: 'string'
139             enum: ['1gb', '10gb', '25gb', '40gb']
140             # FIXME: mandatory for nodes?
141           # Optional
142           features:
143             type: ['string', 'null']
144             pattern: '^((dpdk|sriov)\|?)*$'
145             # FIXME: mandatory for nodes?
146         required: ['name', 'mac_address']
147         additionalProperties: false
148   ############################################################################
149   # Top-level PDF blocks, versioned
150   details:
151     v1.0:
152       type: 'object'
153       properties:
154         type:
155           type: 'string'
156           enum: ['production', 'development']
157         pod_owner:
158           type: 'string'
159         contact:
160           type: 'string'
161           pattern: '^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+[,; ]*)+$'
162         lab:
163           type: 'string'
164         location:
165           type: 'string'
166         link:
167           type: 'string'
168       required: ['type', 'pod_owner', 'contact', 'lab', 'location', 'link']
169       additionalProperties: false
170   jumphost:
171     v1.0:
172       type: 'object'
173       properties:
174         name:
175           type: 'string'
176         node:
177           $ref: '#/definitions/node/v1.0'
178         disks:
179           $ref: '#/definitions/disks/v1.0'
180         os:
181           type: 'string'
182         remote_params:  # Optional YAML anchor, contents will be validated below
183           type: 'object'
184         remote_management:
185           $ref: '#/definitions/remote_management/v1.0'
186         interfaces:
187           $ref: '#/definitions/interfaces/v1.0'
188       required: ['name', 'node', 'disks', 'os', 'remote_management', 'interfaces']
189       additionalProperties: false
190   nodes:
191     v1.0:
192       type: 'array'
193       items:
194         type: 'object'
195         properties:
196           name:
197             type: 'string'
198           node:
199             $ref: '#/definitions/node/v1.0'
200           disks:
201             $ref: '#/definitions/disks/v1.0'
202           os:
203             type: 'string'
204           remote_params:  # Optional YAML anchor, contents will be validated after inject
205             type: 'object'
206           remote_management:
207             $ref: '#/definitions/remote_management/v1.0'
208           interfaces:
209             $ref: '#/definitions/interfaces/v1.0'
210         required: ['name', 'node', 'disks', 'remote_management', 'interfaces']
211         additionalProperties: false
212
213 ##############################################################################
214 # Top-level structure:
215 # - define all possible top-level keys, without enforcing a schema for them,
216 #   just so we can disallow additional properties;
217 # - require 'version' and allow dynamically generated 'version_x.y' key;
218 properties:
219   # version_x.y keys are auto-added by `validate_schema.py` based on 'version'
220   version_1.0:
221     type: 'boolean'
222   version:
223     type: 'number'
224     enum: [1.0]
225   details:
226     type: 'object'
227   jumphost:
228     type: 'object'
229   nodes:
230     type: 'array'
231 required: ['version']
232 additionalProperties: false
233
234 ##############################################################################
235 # Schema versioning
236 # - based on dynamically added 'version_x.y', require additional PDF blocks
237 #   and validate them against the proper schema version;
238 dependencies:
239   version_1.0:
240     properties:
241       details:
242         $ref: '#/definitions/details/v1.0'
243       jumphost:
244         $ref: '#/definitions/jumphost/v1.0'
245       nodes:
246         $ref: '#/definitions/nodes/v1.0'
247     required: ['details', 'jumphost', 'nodes']