[IDF] Add IDF schema validation based on version
[pharos.git] / config / pdf / idf-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   net_config:
14     v0.1:
15       # NOTE: I hope this is going away soon, so I won't model it yet
16       type: 'object'
17   daisy:
18     v0.1:
19       type: 'object'
20       # NOTE: To be properly modeled by Daisy maintainers
21   compass:
22     v0.1:
23       type: 'object'
24       # NOTE: To be properly modeled by Compass4NFV maintainers
25   fuel:
26     v0.1:
27       type: 'object'
28       properties:
29         jumphost:
30           type: 'object'
31           properties:
32             bridges:
33               type: 'object'
34               properties:
35                 admin:
36                   type: ['string', 'null']
37                 mgmt:
38                   type: ['string', 'null']
39                 private:
40                   type: ['string', 'null']
41                 public:
42                   type: ['string', 'null']
43               required: ['admin', 'mgmt', 'private', 'public']
44               additionalProperties: false
45           required: ['bridges']
46           additionalProperties: false
47         network:
48           type: 'object'
49           properties:
50             node:
51               type: 'array'
52               items:
53                 type: 'object'
54                 properties:
55                   interfaces:
56                     type: 'array'
57                     items:
58                       type: ['string', 'null']
59                   busaddr:
60                     type: 'array'
61                     items:
62                       type: ['string', 'null']
63                 required: ['interfaces', 'busaddr']
64                 additionalProperties: false
65           required: ['node']
66           additionalProperties: false
67       required: ['jumphost', 'network']
68       additionalProperties: false
69
70 ##############################################################################
71 # Top-level structure:
72 # - define all possible top-level and second-level keys, without enforcing a
73 #   schema for second-level, just so we can disallow additional properties;
74 # - require 'version' and allow dynamically generated 'version_x.y' key;
75 properties:
76   idf:
77     properties:
78       # version_x.y keys are auto-added by `validate_schema.py` based on 'version'
79       version_0.1:
80         type: 'boolean'
81       version:
82         type: 'number'
83         enum: [0.1]
84       net_config:
85         type: 'object'
86       fuel:
87         type: 'object'
88       daisy:
89         type: 'object'
90       compass:
91         type: 'object'
92     required: ['version']
93     additionalProperties: false
94     ############################################################################
95     # Schema versioning
96     # - based on dynamically added 'version_x.y', require additional IDF blocks
97     #   and validate them against the proper schema version;
98     dependencies:
99       version_0.1:
100         properties:
101           net_config:
102             $ref: '#/definitions/net_config/v0.1'
103           fuel:
104             $ref: '#/definitions/fuel/v0.1'
105           daisy:
106             $ref: '#/definitions/daisy/v0.1'
107           compass:
108             $ref: '#/definitions/compass/v0.1'
109         required: ['net_config']
110
111 # Do not allow any properties not defined here. This lets us catch typos.
112 additionalProperties: false
113 required: ['idf']