Package: slapos.cookbook
slapos.cookbookCookbook of SlapOS recipes.testingUnit tests for recipes can be found underslapos/test/recipe. To run the
tests use provided unittest.defaultTestLoader insideslapos/test/test_recipeby invokingpython setup.py test –test-suite slapos.test.test_recipe.additional_testsgeneric_cloudoooThe generic_cloudooo recipe helps you to deploy cloudooo services with their configuration files.How to use generic_cloudooo?Here is an example of a section to add in your software.cfg :[cloudooo-configuration]recipe=slapos.cookbook:generic_cloudoooconfiguration-file=${directory:etc}/cloudooo.cfgwrapper=${directory:services}/cloudooodata-directory=${directory:srv}/cloudoooip=0.0.0.0port=1234ooo-paster=${directory:bin}/cloudooo_pastermimetype_entry_addition=text/html application/pdf wkhtmltopdfopenoffice-port=1235ooo-binary-path=${directory:libreoffice-bin}/programenvironment=FONTCONFIG_FILE=$${fontconfig-conf:output}PATH=${binary-link:target-directory}ooo-uno-path=${directory:libreoffice-bin}/basis-link/programWhere :configuration-fileis the path where the put the configuration file;wrapperis the path where the put the final executable file;data-directoryis the folder where cloudooo would put it’s temporary files;ipandportis where cloudooo will listen to;ooo-pasteris the path of the program that will load cloudooo configuration
and start the application;mimetype_entry_additionis additional entries to give to the default
mimetype registry. (see section below.) The mimetype entry list is sorted in
order to make the global mimetype at the bottom of the list.
(i.e.* * ooo>text/* * ooo)mimetype_entry_addition=<input_format> <output_format> <handler>openoffice-portis the port where the internal OpenOffice.org service will
listen to;ooo-binary-pathis the path of the openoffice service executable file;environmentare environment vars to use with the openoffice binary;ooo-uno-pathis the path where UNO library is installed.Default mimetype registryapplication/vnd.oasis.opendocument* * oooapplication/vnd.sun.xml* * oooapplication/pdf text/* pdfapplication/pdf * ooovideo/* * ffmpegaudio/* * ffmpegapplication/x-shockwave-flash * ffmpegapplication/ogg * ffmpegapplication/ogv * ffmpegimage/png image/jpeg imagemagickimage/png * oooimage/* image/* imagemagicktext/* * oooapplication/zip * oooapplication/msword * oooapplication/vnd* * oooapplication/x-vnd* * oooapplication/postscript * oooapplication/wmf * oooapplication/csv * oooapplication/x-openoffice-gdimetafile * oooapplication/x-emf * oooapplication/emf * oooapplication/octet* * ooo* application/vnd.oasis.opendocument* ooolibrecipeThanks to using slapos.cookbook:librecipe it is easier to create zc.buildout recipes in SlapOS environment.How to use?In setup.py of recipe add only one install requires to slap.lib.recipe.In code itself subclass from slap.lib.recipe.BaseSlapRecipe.BaseSlapRecipe.Use _install hook:from slap.lib.recipe.BaseSlapRecipe import BaseSlapRecipe

class Recipe(BaseSlapRecipe):
  ...
  def _install(self):
    # refer below for list of available objects
    specific code
    of recipeAvailable variables self.:name and options passed by zc.buildout during initwork_directory – buildout’s directorybin_directory – places for generated binariesrunning_wrapper_location – filename of wrapper to createdata_root_directory – directory container for data – inside this
directory it is advised to create named directories for provided servers
which needs databackup_directory – directory container for backups – inside this
directory it is advised o created named directories for backups, with same
structure as in data_root_directoryvar_directory – container for various, unix following things:log_directory – container for logsrun_directory – container for pidfiles and socketsetc_directory – place to put named files and directories of configuration
for provided serverscomputer_id – id of computercomputer_partition_id – if of computer partitionserver_url - url of Vifib serversoftware_release_url – url of software release being instantiatedslap – initialised connection to Vifib servercomputer_partition – initialised connection to computer partitionrequest – shortcut to computer partition request methodBy default all directories are created before calling _install hook._install method shall return list of paths which are safe to be removed by
buildout during part uninstallation.Important assumptionsBecause in SlapOS environment zc.buildout does not know when data are changed,
recipes shall be always uninstalled/installed. This is done during constructing
recipe instance which subclasses from BaseSlapRecipe.mkdirectorymkdirectory loops on its options and create the directory joinedNoteUse a slash/as directory separator. Don’t use system dependent separator.
The slash will be parsed and replace by the operating system right separator.Only use relative directory to the buildout root directory.The created directory won’t be added to path list.These recipes provide the ability to save some buildout parameters and their value in a custom file, inside the instance folder.In both recipes, you HAVE TO give a filename, which will be stored at the root of the instance folderWriteRecipe :Is used to create a section (named according to the buildout section_name).You can give then as much parameters you wish, with their default values.Whenever you run buildout, if the parameter has yet been saved in the config file, it will do nothing.If the parameter’s value has changed in the config file, it won’t be overwritten/!If you decide to change the default value of one parameter, ALL other parameters will be reseted in the config file, even if you changed it manually. Explanation : The default values aren’t expected to change, except while development purposes.ReadRecipe :It fills its own section with all the options in all the sections of the config file.