Hyper Open Edge Cloud

How To Extend Sections In Buildout

How To Extend Sections In Buildout
  • Last Update:2023-08-21
  • Version:004
  • Language:en

Agenda

  • Extending Buildout Sections
  • Extend Download Sections in software.cfg
  • Verification

This howTo describes how to extend buildout section with macros in the context of SlapOS. The official buildout documentation is available here: Extending sections using macros

Here is the commit introducing this functionality to html5as Software release: 6840c4d0

Prerequisites

Access Theia

You can access the Theia using the url and logging in with username and password.

Observation

Sections doing the same things, share a lot of keys:

recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

Create macro: [download-base]

This code can be refactored using buildout macros.

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

Have one shared section to define the default behaviour to download templates. Sections extending this one don't need to redefine shared parameters

Simplification

We can reuse [download-base]

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

by extending it with  <= download-base line to replace:

recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

For example, [instance_html5as] becomes: 

# Download instance_html5as.cfg.in
[instance_html5as]
# This section inherit from download-base
<= download-base
_update_hash_filename_ = instance_html5as.cfg.in
md5sum = cc9270fa52d55143d4db7f38e38bbd37

Refactor all download sections in software.cfg

Refactor all download sections in software.cfg.

# Download instance_html5as.cfg.in
[instance_html5as]
# This section inherit from download-base
<= download-base
_update_hash_filename_ = instance_html5as.cfg.in
md5sum = cc9270fa52d55143d4db7f38e38bbd37

[template_nginx_conf]
<= download-base
_update_hash_filename_ = templates/nginx_conf.in
md5sum = 61dc4c82bf48563228ce4dea6c5c6319

[template_launcher]
<= download-base
_update_hash_filename_ = templates/launcher.in
md5sum = 6cb0d64905ae7fc67277c1bf76b86875 

[template_mime_types]
<= download-base
_update_hash_filename_ = templates/mime_types.in
md5sum = 4ef94a7b458d885cd79ba0b930a5727e

[template_index_html]
<= download-base
_update_hash_filename_ = templates/index.html.in
md5sum = d57cb01df5941e139b02a2f7bdabcdc8

Note : your own md5sum may be different. Don't change them if they are correct or you might get an error. 

Validation

  • Re-compiling
  • Check slapos node software logs: No error should appear in the last run

Validation

$ slapos node software --all

Re-compiling the software by

$ slapos node software --all

As there is no error in the output, the sections you extended should be fine.