Skip to content

Cetmix Tower YAML

Cetmix Tower YAML module is the core module that implements YAML interface for Cetmix Tower.
It allows to export and import Cetmix Tower records to/from YAML files and serves as an engine for other modules, such as Cetmix Tower Git.

YAML format specification

For detailed information on the YAML format, please refer to the YAML Format Specification page.

Video Tutorial

Here is a short video showing how to export and import data from/to Cetmix Tower using YAML files.

Installation

To use these functionalities, you must have the Cetmix Tower YAML cetmix_tower_yaml module installed. For further details, please refer to the Installing the Modules section of the documentation.

Access Rights

Special access rights are required to use YAML export/import. Please refer to the Access Rights section of the documentation for more details.

Data Export to YAML

To export a record or multiple records to YAML:

1. Open the record you want to export, switch to the YAML tab and click the Export Yaml button.

Export Yaml

Or select multiple records and click Export Yaml in the Action menu.

Export Yaml

Warning

If there is no YAML tab in the record form or Export YAML item in the Action menu, that mean that the record does not support YAML export, or user doesn't have access to the data export feature.
Also please ensure that you have refreshed the page after enabling "Export YAML" in the user settings.

2. A wizard will open where you can configure the export options.

Export Yaml Wizard

Field Description
YAML File Name Name of the file you download. The wizard adds .yaml.
Include Related Records On by default. Adds the records used by the ones you selected, and writes those records first. Records that belong to a selected record, such as flight plan lines or variable values, stay inside it.
When this is off, the file contains only the selected records, and links to other records are references.
Remove Empty x2m Field Values If enabled, the empty values of Many2many, One2many and Many2one fields will be removed from the YAML file. This allows to reduce the size of the YAML file and to avoid errors when importing the data.
Add Manifest Shows the manifest fields. When you fill in a snippet name, that manifest is written at the top of the file.
Preview Code Preview the generated YAML code before downloading the file.

3. Click the Generate YAML file button. Download the file from the pop up form that opens next.

Export Yaml Result

YAML File Modification

You can modify the result YAML file before importing it. You can also combine multiple YAML files into one by adding other records to the records section.
Check the YAML File Example for a reference.

Data Import from YAML

Cetmix Tower supports complex YAML files, which can contain multiple records from different models. When importing such files, the wizard will automatically create new records for each model or update existing records if they already exist.

To import records from a YAML file:

1. Go to Cetmix Tower > Tools > Import YAML.

Import Yaml

2. Upload the YAML file and click the Process button.

Import Yaml Import Yaml

3. A wizard will open where you can configure the import options.

Import Yaml Wizard

The If Record Exists field applies to records that are already in the database. The records you selected when exporting are marked in the file. A file with no such mark treats every top-level record as selected.

Option What happens
Skip record Leave the existing record unchanged. A record that is not in the database is created.
Update existing record Write the values from the file onto the existing record and the records nested in it, such as flight plan lines. Nested records that are no longer in the file are kept. A record that is not in the database is created.
Create a new record Create a new copy of a selected record, with new copies of the records nested in it. Its reference stays as written when that reference is free; otherwise a suffix is added. Any other record that already exists is left unchanged. A record that is not in the database is created.

4. Click the Import button. The wizard then opens the selected records:

  • One record: its form.
  • Several records of one model: their list.
  • Records of more than one model: a notification that names each model once.

Import Yaml Result

YAML File Structure

Every importable YAML file has this structure:

cetmix_tower_yaml_version: 1
manifest:          # Optional, top-level only — NOT a record in records
  name: ...
  description: |
    ...
records:           # Required — list of importable records
  - cetmix_tower_model: command
    reference: create_directory
    name: Create directory
  - cetmix_tower_model: plan
    cetmix_tower_root: true   # present on the records you selected
    reference: demo_flight_plan
    name: Demo Flight Plan
    line_ids:          # records that belong to this plan stay nested
      - reference: demo_flight_plan_line_1
        command_id: create_directory

See the YAML Format Specification for full details.

YAML File Example

Exporting a flight plan with Include Related Records on writes the command first, then the plan. The plan is marked because it is the record you selected. Its lines stay inside the plan, and each line points at the command by reference.

cetmix_tower_yaml_version: 1
records:
- cetmix_tower_model: command
  reference: create_directory
  name: Create directory
  action: ssh_command
  code: mkdir {{ dir }}
- cetmix_tower_model: plan
  cetmix_tower_root: true
  reference: demo_flight_plan
  name: Demo Flight Plan
  line_ids:
  - reference: demo_flight_plan_line_1
    sequence: 10
    command_id: create_directory