<commit_before># Template allow to configure partitionning with quite a lot of flexibility,
# based on externally defined variables.

unique template filesystem/config;

include { 'quattor/functions/filesystem' };

variable FILESYSTEM_LAYOUT_CONFIG_SITE ?= null;

# The following variables define defaults for file systems and partitions.
# They are actually defined after including FILESYSTEM_LAYOUT_CONFIG_SITE.
#   - FILESYSTEM_DEFAULT_FS_TYPE: default file system type to use when none is specified
#   - FILESYSTEM_DEFAULT_PRESERVE: default file system preserve flag value
#   - FILESYSTEM_DEFAULT_FORMAT: default file system 'format' attribute


# Function to update DISK_VOLUME_PARAMS.
# This function allows to merge site-specific volume parameters with default ones.
# Calling sequence is  :
#    variable DISK_VOLUME_PARAMS = filesystem_layout_mod(volume_nlist);
# where 'volume_nlist' has the same format as DISK_VOLUME_PARAMS.
function filesystem_layout_mod = {
  function_name = 'filesystem_layout_mod';
  if ( (ARGC != 1) || !is_nlist(ARGV[0]) ) {
    error(function_name+': one argument required, must be a nlist');
  };

  foreach (volume;params;ARGV[0]) {
    if ( exists(SELF[volume]) ) {
      foreach (key;value;params) {
        SELF[volume][key] = value;
      };
    } else {
      SELF[volume] = params;
    };
  };
  SELF;
};

variable DISK_BOOT_DEV ?= boot_disk();
variable DISK_BOOT_DEV ?= {
  if (exists("/hardware/harddisks/sda")) {
    return("sda");
  } else if (exists("/hardware/harddisks/hda")) {
    return("hda");
  } else if (exists("/hardware/harddisks/xvda")) {
    return("xvda");
  } else if (exists("/hardware/harddisks/cciss/c0d0")) {
    return(escape("cciss/c0d0"));
  } else if (exists("/hardware/harddisks/vda")) {<commit_msg>filesystem/config: allow early definition of site values for variables defining block dev size<commit_after># Template allow to configure partitionning with quite a lot of flexibility,
# based on externally defined variables.

unique template filesystem/config;

include { 'quattor/functions/filesystem' };


@{
desc =  template customizing the default disk layout provided by the default configuration
values = template namespace
default = null
required = no
}
variable FILESYSTEM_LAYOUT_CONFIG_SITE ?= null;

@{
desc =  template included at the beginning of the file system configuration and allowing to \
 to redefine the default size of block devices defined in the default configuration
values = template namespace
default = FILESYSTEM_LAYOUT_CONFIG_SITE+'-init' or null if FILESYSTEM_LAYOUT_CONFIG_SITE is undefined
required = no
}
variable FILESYSTEM_LAYOUT_CONFIG_INIT ?= if ( is_defined(FILESYSTEM_LAYOUT_CONFIG_SITE) ) {
                                            if_exists(FILESYSTEM_LAYOUT_CONFIG_SITE + '-init');
                                          } else {
                                            null;
                                          };

# The following variables define defaults for file systems and partitions.
# They are actually defined after including FILESYSTEM_LAYOUT_CONFIG_SITE.
#   - FILESYSTEM_DEFAULT_FS_TYPE: default file system type to use when none is specified
#   - FILESYSTEM_DEFAULT_PRESERVE: default file system preserve flag value
#   - FILESYSTEM_DEFAULT_FORMAT: default file system 'format' attribute


# Function to update DISK_VOLUME_PARAMS.
# This function allows to merge site-specific volume parameters with default ones.
# Calling sequence is  :
#    variable DISK_VOLUME_PARAMS = filesystem_layout_mod(volume_nlist);
# where 'volume_nlist' has the same format as DISK_VOLUME_PARAMS.
function filesystem_layout_mod = {
  function_name = 'filesystem_layout_mod';
  if ( (ARGC != 1) || !is_nlist(ARGV[0]) ) {
    error(function_name+': one argument required, must be a nlist');
  };

  foreach (volume;params;ARGV[0]) {
    if ( exists(SELF[volume]) ) {
      foreach (key;value;params) {
        SELF[volume][key] = value;
      };
    } else {
      SELF[volume] = params;
    };
  };
  SELF;
};


# Include site configuration initialization if any
include FILESYSTEM_LAYOUT_CONFIG_INIT;


# Retrieve boot device name based on HW configuration
variable DISK_BOOT_DEV ?= boot_disk();
variable DISK_BOOT_DEV ?= {
  if (exists("/hardware/harddisks/sda")) {
    return("sda");
  } else if (exists("/hardware/harddisks/hda")) {
    return("hda");
  } else if (exists("/hardware/harddisks/xvda")) {
    return("xvda");
  } else if (exists("/hardware/harddisks/cciss/c0d0")) {
    return(escape("cciss/c0d0"));
  } else if (exists("/hardware/harddisks/vda")) {
{'fraction_non_alphanumeric': 0.09910694837725986, 'fraction_numerical': 0.0030494445654541493, 'mean_word_length': 3.8083769633507853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2091515', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1380, 'n_words': 387}