Schema
RacksDB is provided with a database schema. It is basically a YAML file that defines the objects represented in the database with their properties, and the relations between these objects.
The content of this file eventually defines the database structure. This schema can be customized to store additional data using schema extensions.
Path
When RacksDB is installed, the schema is available in path
/usr/share/racksdb/schemas/racksdb.yml
.
The file is also available in source code Git repository.
Content
The schema file is a mapping that contains 3 main keys:
_version
-
Version number of the schema as a string.
_content
-
Database root object definition.
_objects
-
All other objects definitions.
The format of _content
is an object definition. The format of
_objects
is a mapping whose keys are objects names and values are
objects definitions.
Objects Definitions
Objects definitions are mappings with the following expected keys:
description
(optional)-
String to describe the purpose of the object.
properties
-
Mapping of objects properties. The keys are the names of the properties. The values are mapping with the following expected keys:
type
-
The property type, as described below.
description
-
String to describe the purpose and content of the property.
key
(optional)-
Boolean to determine if the property is a key. Default value is false.
default
(optional)-
Default value of the property. When the
type
is an object, the special value:recursive
can be used to make the default value of the property the corresponding object with all its defaults properties, recursively. example
(optional)-
Example value of the property.
optional
(optional)-
Boolean to determine if property is optional. Default value is false.
Properties Type
The properties types are expressed with the following notation:
-
native types are expressed by their name
ex: str or int -
objects are prefixed by
:
ex::DatacenterRoomDimensions
-
sequences (or lists) are noted
list[<content>]
ex:list[str]
orlist[:Infrastructure]
-
reference to other objects properties are prefixed by
$
ex:$NodeType.id
-
back references to a parent objects or one of their properties are prefixed by
^
ex:^Datacenter
or^InfrastructurePart.rack
-
defined types are prefixed by
~
ex:~dimension