pylorax.api package¶
Submodules¶
pylorax.api.bisect module¶
- 
pylorax.api.bisect.insort_left(a, x, key=None, lo=0, hi=None)[source]¶
- Insert item x in list a, and keep it sorted assuming a is sorted. - Parameters: - Returns: - index where the item was inserted - Return type: - If x is already in a, insert it to the left of the leftmost x. Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. - This is a modified version of bisect.insort_left that can use a function for the compare, and returns the index position where it was inserted. 
pylorax.api.cmdline module¶
pylorax.api.compose module¶
Setup for composing an image
Adding New Output Types¶
The new output type must add a kickstart template to ./share/composer/ where the name of the kickstart (without the trailing .ks) matches the entry in compose_args.
The kickstart should not have any url or repo entries, these will be added at build time. The %packages section should be the last thing, and while it can contain mandatory packages required by the output type, it should not have the trailing %end because the package NEVRAs will be appended to it at build time.
compose_args should have a name matching the kickstart, and it should set the novirt_install parameters needed to generate the desired output. Other types should be set to False.
- 
pylorax.api.compose.add_customizations(f, recipe)[source]¶
- Add customizations to the kickstart file - Parameters: - f (open file object) -- kickstart file object
- recipe (Recipe object) --
 - Returns: - None - Raises: - RuntimeError if there was a problem writing to the kickstart 
- 
pylorax.api.compose.bootloader_append(line, kernel_append)[source]¶
- Insert the kernel_append string into the --append argument - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.compose_args(compose_type)[source]¶
- Returns the settings to pass to novirt_install for the compose type - Parameters: - compose_type (str) -- The type of compose to create, from compose_types() - This will return a dict of options that match the ArgumentParser options for livemedia-creator. These are the ones the define the type of output, it's filename, etc. Other options will be filled in by make_compose() 
- 
pylorax.api.compose.compose_types(share_dir)[source]¶
- Returns a list of the supported output types - The output types come from the kickstart names in /usr/share/lorax/composer/*ks 
- 
pylorax.api.compose.customize_ks_template(ks_template, recipe)[source]¶
- Customize the kickstart template and return it - Parameters: - ks_template (str) -- The kickstart template
- recipe (Recipe object) --
 - Apply customizations to existing template commands, or add defaults for ones that are missing and required. - Apply customizations.kernel.append to the bootloader argument in the template. Add bootloader line if it is missing. - Add default timezone if needed. It does NOT replace an existing timezone entry 
- 
pylorax.api.compose.firewall_cmd(line, settings)[source]¶
- Update the firewall line with the new ports and services - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.get_default_services(recipe)[source]¶
- Get the default string for services, based on recipe :param recipe: The recipe - Returns: - string with "services" or "" - Return type: - str - When no services have been selected we don't need to add anything to the kickstart so return an empty string. Otherwise return "services" which will be updated with the settings. 
- 
pylorax.api.compose.get_extra_pkgs(dbo, share_dir, compose_type)[source]¶
- Return extra packages needed for the output type - Parameters: - Returns: - List of package names (name only, not NEVRA) - Return type: - Currently this is only needed by live-iso, it reads ./live/live-install.tmpl and processes only the installpkg lines. It lists the packages needed to complete creation of the iso using the templates such as x86.tmpl - Keep in mind that the live-install.tmpl is shared between livemedia-creator and lorax-composer, even though the results are applied differently. 
- 
pylorax.api.compose.get_firewall_settings(recipe)[source]¶
- Return the customizations.firewall settings - Parameters: - recipe (Recipe object) -- The recipe - Returns: - A dict of settings - Return type: - dict 
- 
pylorax.api.compose.get_kernel_append(recipe)[source]¶
- Return the customizations.kernel append value - Parameters: - recipe (Recipe object) -- - Returns: - append value or empty string - Return type: - str 
- 
pylorax.api.compose.get_keyboard_layout(recipe)[source]¶
- Return the customizations.locale.keyboard list - Parameters: - recipe (Recipe object) -- The recipe - Returns: - The keyboard layout string - Return type: - str 
- 
pylorax.api.compose.get_languages(recipe)[source]¶
- Return the customizations.locale.languages list - Parameters: - recipe (Recipe object) -- The recipe - Returns: - list of language strings - Return type: - list 
- 
pylorax.api.compose.get_services(recipe)[source]¶
- Return the customizations.services settings - Parameters: - recipe (Recipe object) -- The recipe - Returns: - A dict of settings - Return type: - dict 
- 
pylorax.api.compose.get_timezone_settings(recipe)[source]¶
- Return the customizations.timezone dict - Parameters: - recipe (Recipe object) -- - Returns: - append value or empty string - Return type: - dict 
- 
pylorax.api.compose.keyboard_cmd(line, layout)[source]¶
- Update the keyboard line with the layout - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.lang_cmd(line, languages)[source]¶
- Update the lang line with the languages - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.move_compose_results(cfg, results_dir)[source]¶
- Move the final image to the results_dir and cleanup the unneeded compose files - Parameters: - cfg (DataHolder) -- Build configuration
- results_dir (str) -- Directory to put the results into
 
- 
pylorax.api.compose.repo_to_ks(r, url='url')[source]¶
- Return a kickstart line with the correct args. :param r: DNF repository information :type r: dnf.Repo :param url: "url" or "baseurl" to use for the baseurl parameter :type url: str :returns: kickstart command arguments for url/repo command :rtype: str - Set url to "baseurl" if it is a repo, leave it as "url" for the installation url. 
- 
pylorax.api.compose.services_cmd(line, settings)[source]¶
- Update the services line with additional services to enable/disable - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.start_build(cfg, dnflock, gitlock, branch, recipe_name, compose_type, test_mode=0)[source]¶
- Start the build - Parameters: - cfg (ComposerConfig) -- Configuration object
- dnflock (YumLock) -- Lock and YumBase for depsolving
- recipe (str) -- The recipe to build
- compose_type (str) -- The type of output to create from the recipe
 - Returns: - Unique ID for the build that can be used to track its status - Return type: 
- 
pylorax.api.compose.test_templates(dbo, share_dir)[source]¶
- Try depsolving each of the the templates and report any errors - Parameters: - dbo (dnf.Base) -- dnf base object - Returns: - List of template types and errors - Return type: - List of errors - Return a list of templates and errors encountered or an empty list 
- 
pylorax.api.compose.timezone_cmd(line, settings)[source]¶
- Update the timezone line with the settings - Parameters: - Using pykickstart to process the line is the best way to make sure it is parsed correctly, and re-assembled for inclusion into the final kickstart 
- 
pylorax.api.compose.write_ks_group(f, group)[source]¶
- Write kickstart group entry - Parameters: - f (open file object) -- kickstart file object
- group -- A blueprint group dictionary
 - gid is optional 
- 
pylorax.api.compose.write_ks_root(f, user)[source]¶
- Write kickstart root password and sshkey entry - Parameters: - f (open file object) -- kickstart file object
- user (dict) -- A blueprint user dictionary
 - Returns: - True if it wrote a rootpw command to the kickstart - Return type: - If the entry contains a ssh key, use sshkey to write it If it contains password, use rootpw to set it - root cannot be used with the user command. So only key and password are supported for root. 
- 
pylorax.api.compose.write_ks_user(f, user)[source]¶
- Write kickstart user and sshkey entry - Parameters: - f (open file object) -- kickstart file object
- user (dict) -- A blueprint user dictionary
 - If the entry contains a ssh key, use sshkey to write it All of the user fields are optional, except name, write out a kickstart user entry with whatever options are relevant. 
pylorax.api.config module¶
- 
class pylorax.api.config.ComposerConfig(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)[source]¶
- Bases: - configparser.ConfigParser
- 
pylorax.api.config.configure(conf_file='/etc/lorax/composer.conf', root_dir='/', test_config=False)[source]¶
- lorax-composer configuration - Parameters: 
- 
pylorax.api.config.make_dnf_dirs(conf, uid, gid)[source]¶
- Make any missing dnf directories owned by user:group - Parameters: - conf (ComposerConfig) -- The configuration to use
- uid (int) -- uid of owner
- gid (int) -- gid of owner
 - Returns: - list of errors - Return type: - list of str 
- 
pylorax.api.config.make_owned_dir(p_dir, uid, gid)[source]¶
- Make a directory and its parents, setting owner and group - Parameters: - Returns: - list of errors - Return type: - list of str - Check to make sure it does not have o+rw permissions and that it is owned by uid:gid 
- 
pylorax.api.config.make_queue_dirs(conf, gid)[source]¶
- Make any missing queue directories - Parameters: - conf (ComposerConfig) -- The configuration to use
- gid (int) -- Group ID that has access to the queue directories
 - Returns: - list of errors - Return type: - list of str 
pylorax.api.crossdomain module¶
pylorax.api.dnfbase module¶
- 
class pylorax.api.dnfbase.DNFLock(conf, expire_secs=21600)[source]¶
- Bases: - object- Hold the dnf.Base object and a Lock to control access to it. - self.dbo is a property that returns the dnf.Base object, but it may change from one call to the next if the upstream repositories have changed. - 
lock¶
- Check for repo updates (using expiration time) and return the lock - If the repository has been updated, tear down the old dnf.Base and create a new one. This is the only way to force dnf to use the new metadata. 
 - 
lock_check¶
- Force a check for repo updates and return the lock - Use this method sparingly, it removes the repodata and downloads a new copy every time. 
 
- 
pylorax.api.errors module¶
pylorax.api.gitrpm module¶
Clone a git repository and package it as an rpm
This module contains functions for cloning a git repo, creating a tar archive of the selected commit, branch, or tag, and packaging the files into an rpm that will be installed by anaconda when creating the image.
- 
class pylorax.api.gitrpm.GitArchiveTarball(gitRepo)[source]¶
- Bases: - object- Create a git archive of the selected git repo and reference 
- 
class pylorax.api.gitrpm.GitRpmBuild(*args, **kwargs)[source]¶
- Bases: - rpmfluff.SimpleRpmBuild- Build an rpm containing files from a git repository - 
add_git_tarball(gitRepo)[source]¶
- Add a tar archive of a git repository to the rpm - Parameters: - gitRepo (dict) -- A dict with the repository details - This populates the rpm with the URL of the git repository, the summary describing the repo, the description of the repository and reference used, and sets up the rpm to install the archive contents into the destination path. 
 
- 
- 
pylorax.api.gitrpm.create_gitrpm_repo(results_dir, recipe)[source]¶
- Create a dnf repository with the rpms from the recipe - Parameters: - Returns: - Path to the dnf repository or "" - Return type: - This function creates a dnf repository directory at results_dir+"repo/", creates rpms for all of the repos.git entries in the recipe, runs createrepo_c on the dnf repository so that Anaconda can use it, and returns the path to the repository to the caller. 
- 
pylorax.api.gitrpm.get_repo_description(gitRepo)[source]¶
- Return a description including the git repo and reference - Parameters: - gitRepo (dict) -- A dict with the repository details - Returns: - A string with the git repo url and reference - Return type: - str 
- 
pylorax.api.gitrpm.make_git_rpm(gitRepo, dest)[source]¶
- Create an rpm from the specified git repo - Parameters: - gitRepo (dict) -- A dict with the repository details - This will clone the git repository, create an archive of the selected reference, and build an rpm that will install the files from the repository under the destination directory. The gitRepo dict should have the following fields: - rpmname: "server-config" rpmversion: "1.0" rpmrelease: "1" summary: "Setup files for server deployment" repo: "PATH OF GIT REPO TO CLONE" ref: "v1.0" destination: "/opt/server/" - rpmname: Name of the rpm to create, also used as the prefix name in the tar archive
- rpmversion: Version of the rpm, eg. "1.0.0"
- rpmrelease: Release of the rpm, eg. "1"
- summary: Summary string for the rpm
- repo: URL of the get repo to clone and create the archive from
- ref: Git reference to check out. eg. origin/branch-name, git tag, or git commit hash
- destination: Path to install the / of the git repo at when installing the rpm
 
pylorax.api.projects module¶
- 
pylorax.api.projects.api_changelog(changelog)[source]¶
- Convert the changelog to a string - Parameters: - changelog (tuple) -- A list of time, author, string tuples. - Returns: - The most recent changelog text or "" - Return type: - str - This returns only the most recent changelog entry. 
- 
pylorax.api.projects.api_time(t)[source]¶
- Convert time since epoch to a string - Parameters: - t (int) -- Seconds since epoch - Returns: - Time string - Return type: - str 
- 
pylorax.api.projects.delete_repo_source(source_glob, source_name)[source]¶
- Delete a source from a repo file - Parameters: - source_glob (str) -- A glob of the repo sources to search - Returns: - None - Raises: - ProjectsError if there was a problem - A repo file may have multiple sources in it, delete only the selected source. If it is the last one in the file, delete the file. - WARNING: This will delete ANY source, the caller needs to ensure that a system source_name isn't passed to it. 
- 
pylorax.api.projects.dep_evra(dep)[source]¶
- Return the epoch:version-release.arch for the dep - Parameters: - dep (dict) -- dependency dict - Returns: - epoch:version-release.arch - Return type: - str 
- 
pylorax.api.projects.dnf_repo_to_file_repo(repo)[source]¶
- Return a string representation of a DNF Repo object suitable for writing to a .repo file - Parameters: - repo (dnf.RepoDict) -- DNF Repository - Returns: - A string - Return type: - str - The DNF Repo.dump() function does not produce a string that can be used as a dnf .repo file, it ouputs baseurl and gpgkey as python lists which DNF cannot read. So do this manually with only the attributes we care about. 
- 
pylorax.api.projects.estimate_size(packages, block_size=6144)[source]¶
- Estimate the installed size of a package list - Parameters: - packages (list of hawkey.Package objects) -- The packages to be installed
- block_size (int) -- The block size to use for rounding up file sizes.
 - Returns: - The estimated size of installed packages - Return type: - Estimating actual requirements is difficult without the actual file sizes, which dnf doesn't provide access to. So use the file count and block size to estimate a minimum size for each package. 
- 
pylorax.api.projects.get_repo_sources(source_glob)[source]¶
- Return a list of sources from a directory of yum repositories - Parameters: - source_glob (str) -- A glob to use to match the source files, including full path - Returns: - A list of the source ids in all of the matching files - Return type: - list of str 
- 
pylorax.api.projects.get_source_ids(source_path)[source]¶
- Return a list of the source ids in a file - Parameters: - source_path (str) -- Full path and filename of the source (yum repo) file - Returns: - A list of source id strings - Return type: - list of str 
- 
pylorax.api.projects.modules_info(dbo, module_names)[source]¶
- Return details about a module, including dependencies - Parameters: - dbo (dnf.Base) -- dnf base object
- module_names (str) -- Names of the modules to get info about
 - Returns: - List of dicts with module details and dependencies. - Return type: - list of dicts 
- 
pylorax.api.projects.modules_list(dbo, module_names)[source]¶
- Return a list of modules - Parameters: - dbo (dnf.Base) -- dnf base object
- offset -- Number of modules to skip
- limit (int) -- Maximum number of modules to return
 - Returns: - List of module information and total count - Return type: - tuple of a list of dicts and an Int - Modules don't exist in RHEL7 so this only returns projects and sets the type to "rpm" 
- 
pylorax.api.projects.pkg_to_build(pkg)[source]¶
- Extract the build details from a hawkey.Package object - Parameters: - pkg (hawkey.Package) -- hawkey.Package object with package details - Returns: - A dict with the build details, epoch, release, arch, build_time, changelog, ... - Return type: - dict - metadata entries are hard-coded to {} - Note that this only returns the build dict, it does not include the name, description, etc. 
- 
pylorax.api.projects.pkg_to_dep(pkg)[source]¶
- Extract the info from a hawkey.Package object - Parameters: - pkg (hawkey.Package) -- A hawkey.Package object - Returns: - A dict with name, epoch, version, release, arch - Return type: - dict 
- 
pylorax.api.projects.pkg_to_project(pkg)[source]¶
- Extract the details from a hawkey.Package object - Parameters: - pkgs (hawkey.Package) -- hawkey.Package object with package details - Returns: - A dict with the name, summary, description, and url. - Return type: - dict - upstream_vcs is hard-coded to UPSTREAM_VCS 
- 
pylorax.api.projects.pkg_to_project_info(pkg)[source]¶
- Extract the details from a hawkey.Package object - Parameters: - pkg (hawkey.Package) -- hawkey.Package object with package details - Returns: - A dict with the project details, as well as epoch, release, arch, build_time, changelog, ... - Return type: - dict - metadata entries are hard-coded to {} 
- 
pylorax.api.projects.proj_to_module(proj)[source]¶
- Extract the name from a project_info dict - Parameters: - pkg (dict) -- dict with package details - Returns: - A dict with name, and group_type - Return type: - dict - group_type is hard-coded to "rpm" 
- 
pylorax.api.projects.projects_depsolve(dbo, projects, groups)[source]¶
- Return the dependencies for a list of projects - Parameters: - dbo (dnf.Base) -- dnf base object
- projects (List of Strings) -- The projects to find the dependencies for
- groups (List of str) -- The groups to include in dependency solving
 - Returns: - NEVRA's of the project and its dependencies - Return type: - list of dicts - Raises: - ProjectsError if there was a problem installing something 
- 
pylorax.api.projects.projects_depsolve_with_size(dbo, projects, groups, with_core=True)[source]¶
- Return the dependencies and installed size for a list of projects - Parameters: - dbo (dnf.Base) -- dnf base object
- project_names (List of Strings) -- The projects to find the dependencies for
- groups (List of str) -- The groups to include in dependency solving
 - Returns: - installed size and a list of NEVRA's of the project and its dependencies - Return type: - tuple of (int, list of dicts) - Raises: - ProjectsError if there was a problem installing something 
- 
pylorax.api.projects.projects_info(dbo, project_names)[source]¶
- Return details about specific projects - Parameters: - dbo (dnf.Base) -- dnf base object
- project_names (str) -- List of names of projects to get info about
 - Returns: - List of project info dicts with pkg_to_project as well as epoch, version, release, etc. - Return type: - list of dicts - If project_names is None it will return the full list of available packages 
- 
pylorax.api.projects.projects_list(dbo)[source]¶
- Return a list of projects - Parameters: - dbo (dnf.Base) -- dnf base object - Returns: - List of project info dicts with name, summary, description, homepage, upstream_vcs - Return type: - list of dicts 
- 
pylorax.api.projects.repo_to_source(repo, system_source)[source]¶
- Return a Weldr Source dict created from the DNF Repository - Parameters: - repo (dnf.RepoDict) -- DNF Repository
- system_source (bool) -- True if this source is an immutable system source
 - Returns: - A dict with Weldr Source fields filled in - Return type: - Example: - { "check_gpg": true, "check_ssl": true, "gpgkey_url": [ "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64" ], "name": "fedora", "proxy": "http://proxy.brianlane.com:8123", "system": true "type": "yum-metalink", "url": "https://mirrors.fedoraproject.org/metalink?repo=fedora-28&arch=x86_64" } 
- 
pylorax.api.projects.source_to_repo(source, dnf_conf)[source]¶
- Return a dnf Repo object created from a source dict - Parameters: - source (dict) -- A Weldr source dict - Returns: - A dnf Repo object - Return type: - dnf.Repo - Example: - { "check_gpg": True, "check_ssl": True, "gpgkey_urls": [ "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64" ], "name": "fedora", "proxy": "http://proxy.brianlane.com:8123", "system": True "type": "yum-metalink", "url": "https://mirrors.fedoraproject.org/metalink?repo=fedora-28&arch=x86_64" } 
pylorax.api.queue module¶
pylorax.api.recipes module¶
- 
class pylorax.api.recipes.CommitDetails(commit, timestamp, message, revision=None)[source]¶
- Bases: - pylorax.base.DataHolder
- 
pylorax.api.recipes.NewRecipeGit(toml_dict)[source]¶
- Create a RecipeGit object from fields in a TOML dict - Parameters: - rpmname (str) -- Name of the rpm to create, also used as the prefix name in the tar archive
- rpmversion (str) -- Version of the rpm, eg. "1.0.0"
- rpmrelease (str) -- Release of the rpm, eg. "1"
- summary (str) -- Summary string for the rpm
- repo (str) -- URL of the get repo to clone and create the archive from
- ref (str) -- Git reference to check out. eg. origin/branch-name, git tag, or git commit hash
- destination (str) -- Path to install the / of the git repo at when installing the rpm
 - Returns: - A populated RecipeGit object - Return type: - The TOML should look like this: - [[repos.git]] rpmname="server-config" rpmversion="1.0" rpmrelease="1" summary="Setup files for server deployment" repo="PATH OF GIT REPO TO CLONE" ref="v1.0" destination="/opt/server/" - Note that the repo path supports anything that git supports, file://, https://, http:// - Currently there is no support for authentication 
- 
class pylorax.api.recipes.Recipe(name, description, version, modules, packages, groups, customizations=None, gitrepos=None)[source]¶
- Bases: - dict- A Recipe of package and modules - This is a subclass of dict that enforces the constructor arguments and adds a .filename property to return the recipe's filename, and a .toml() function to return the recipe as a TOML string. - 
bump_version(old_version=None)[source]¶
- semver recipe version number bump - Parameters: - old_version (str) -- An optional old version number - Returns: - The new version number or None - Return type: - str - Raises: - ValueError - If neither have a version, 0.0.1 is returned If there is no old version the new version is checked and returned If there is no new version, but there is a old one, bump its patch level If the old and new versions are the same, bump the patch level If they are different, check and return the new version 
 - 
filename¶
- Return the Recipe's filename - Replaces spaces in the name with '-' and appends .toml 
 - 
freeze(deps)[source]¶
- Return a new Recipe with full module and package NEVRA - Parameters: - deps (list() -- A list of dependency NEVRA to use to fill in the modules and packages - Returns: - A new Recipe object - Return type: - Recipe 
 - 
group_names¶
- Return the names of the groups. Groups do not have versions. 
 - 
module_names¶
- Return the names of the modules 
 - 
module_nver¶
- Return the names and version globs of the modules 
 - 
package_names¶
- Return the names of the packages 
 - 
package_nver¶
- Return the names and version globs of the packages 
 
- 
- 
class pylorax.api.recipes.RecipeGit(rpmname, rpmversion, rpmrelease, summary, repo, ref, destination)[source]¶
- Bases: - dict
- 
pylorax.api.recipes.commit_recipe(repo, branch, recipe)[source]¶
- Commit a recipe to a branch - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.commit_recipe_directory(repo, branch, directory)[source]¶
- Commit all *.toml files from a directory, if they aren't already in git. - Parameters: - Returns: - None - Raises: - Can raise errors from Ggit or RecipeFileError - Files with Toml or RecipeFileErrors will be skipped, and the remainder will be tried. 
- 
pylorax.api.recipes.commit_recipe_file(repo, branch, filename)[source]¶
- Commit a recipe file to a branch - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit or RecipeFileError 
- 
pylorax.api.recipes.delete_file(repo, branch, filename)[source]¶
- Delete a file from a branch. - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.delete_recipe(repo, branch, recipe_name)[source]¶
- Delete a recipe from a branch. - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.diff_items(title, old_items, new_items)[source]¶
- Return the differences between two lists of dicts. - Parameters: - Returns: - List of diff dicts with old/new entries - Return type: 
- 
pylorax.api.recipes.find_commit_tag(repo, branch, filename, commit_id)[source]¶
- Find the tag that matches the commit_id - Parameters: - Returns: - The tag or None if there isn't one - Return type: - There should be only 1 tag pointing to a commit, but there may not be a tag at all. - The tag will look like: 'refs/tags/<branch>/<filename>/r<revision>' 
- 
pylorax.api.recipes.find_name(name, lst)[source]¶
- Find the dict matching the name in a list and return it. - Parameters: - name (str) -- Name to search for
- lst -- List of dict's with "name" field
 - Returns: - First dict with matching name, or None - Return type: 
- 
pylorax.api.recipes.get_commit_details(commit, revision=None)[source]¶
- Return the details about a specific commit. - Parameters: - commit (Git.Commit) -- The commit to get details from
- revision (int) -- Optional commit revision
 - Returns: - Details about the commit - Return type: - Raises: - CommitTimeValError or Ggit exceptions 
- 
pylorax.api.recipes.get_revision_from_tag(tag)[source]¶
- Return the revision number from a tag - Parameters: - tag (str) -- The tag to exract the revision from - Returns: - The integer revision or None - Return type: - int or None - The revision is the part after the r in 'branch/filename/rXXX' 
- 
pylorax.api.recipes.head_commit(repo, branch)[source]¶
- Get the branch's HEAD Commit Object - Parameters: - repo (Git.Repository) -- Open repository
- branch (str) -- Branch name
 - Returns: - Branch's head commit - Return type: - Git.Commit - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.is_commit_tag(repo, commit_id, tag)[source]¶
- Check to see if a tag points to a specific commit. - Parameters: - repo (Git.Repository) -- Open repository
- commit_id (Git.OId) -- The commit id to check
- tag (str) -- The tag to check
 - Returns: - True if the tag points to the commit, False otherwise - Return type: 
- 
pylorax.api.recipes.is_parent_diff(repo, filename, tree, parent)[source]¶
- Check to see if the commit is different from its parents - Parameters: - repo (Git.Repository) -- Open repository
- filename (str) -- filename to revert
- tree (Git.Tree) -- The commit's tree
- parent (Git.Commit) -- The commit's parent commit
 - Retuns: - True if filename in the commit is different from its parents - Return type: 
- 
pylorax.api.recipes.list_branch_files(repo, branch)[source]¶
- Return a sorted list of the files on the branch HEAD - Parameters: - repo (Git.Repository) -- Open repository
- branch (str) -- Branch name
 - Returns: - A sorted list of the filenames - Return type: - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.list_commit_files(repo, commit)[source]¶
- Return a sorted list of the files on a commit - Parameters: - repo (Git.Repository) -- Open repository
- commit (str) -- The commit hash to list
 - Returns: - A sorted list of the filenames - Return type: - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.list_commits(repo, branch, filename, limit=0)[source]¶
- List the commit history of a file on a branch. - Parameters: - Returns: - A list of commit details - Return type: - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.open_or_create_repo(path)[source]¶
- Open an existing repo, or create a new one - Parameters: - path (string) -- path to recipe directory - Returns: - A repository object - Return type: - Git.Repository - Raises: - Can raise errors from Ggit - A bare git repo will be created in the git directory of the specified path. If a repo already exists it will be opened and returned instead of creating a new one. 
- 
pylorax.api.recipes.prepare_commit(repo, branch, builder)[source]¶
- Prepare for a commit - Parameters: - repo (Git.Repository) -- Open repository
- branch (str) -- Branch name
- builder (TreeBuilder) -- instance of TreeBuilder
 - Returns: - (Tree, Sig, Ref) - Return type: - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.read_commit(repo, branch, filename, commit=None)[source]¶
- Return the contents of a file on a specific branch or commit. - Parameters: - Returns: - The commit id, and the contents of the commit - Return type: - Raises: - Can raise errors from Ggit - If no commit is passed the master:filename is returned, otherwise it will be commit:filename 
- 
pylorax.api.recipes.read_commit_spec(repo, spec)[source]¶
- Return the raw content of the blob specified by the spec - Parameters: - repo (Git.Repository) -- Open repository
- spec (str) -- Git revparse spec
 - Returns: - Contents of the commit - Return type: - Raises: - Can raise errors from Ggit - eg. To read the README file from master the spec is "master:README" 
- 
pylorax.api.recipes.read_recipe_and_id(repo, branch, recipe_name, commit=None)[source]¶
- Read a recipe commit and its id from git - Parameters: - Returns: - The commit id, and a Recipe object - Return type: - Raises: - Can raise errors from Ggit - If no commit is passed the master:filename is returned, otherwise it will be commit:filename 
- 
pylorax.api.recipes.read_recipe_commit(repo, branch, recipe_name, commit=None)[source]¶
- Read a recipe commit from git and return a Recipe object - Parameters: - Returns: - A Recipe object - Return type: - Raises: - Can raise errors from Ggit - If no commit is passed the master:filename is returned, otherwise it will be commit:filename 
- 
pylorax.api.recipes.recipe_diff(old_recipe, new_recipe)[source]¶
- Diff two versions of a recipe - Parameters: - Returns: - A list of diff dict entries with old/new - Return type: 
- 
pylorax.api.recipes.recipe_filename(name)[source]¶
- Return the toml filename for a recipe - Replaces spaces with '-' and appends '.toml' 
- 
pylorax.api.recipes.recipe_from_dict(recipe_dict)[source]¶
- Create a Recipe object from a plain dict. - Parameters: - recipe_dict (dict) -- A plain dict of the recipe - Returns: - A Recipe object - Return type: - Recipe - Raises: - RecipeError 
- 
pylorax.api.recipes.recipe_from_file(recipe_path)[source]¶
- Return a recipe file as a Recipe object - Parameters: - recipe_path (str) -- Path to the recipe fila - Returns: - A Recipe object - Return type: - Recipe 
- 
pylorax.api.recipes.recipe_from_toml(recipe_str)[source]¶
- Create a Recipe object from a toml string. - Parameters: - recipe_str (str) -- The Recipe TOML string - Returns: - A Recipe object - Return type: - Recipe - Raises: - TomlError 
- 
pylorax.api.recipes.repo_file_exists(repo, branch, filename)[source]¶
- Return True if the filename exists on the branch - Parameters: - Returns: - True if the filename exists on the HEAD of the branch, False otherwise. - Return type: 
- 
pylorax.api.recipes.revert_file(repo, branch, filename, commit)[source]¶
- Revert the contents of a file to that of a previous commit - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.revert_recipe(repo, branch, recipe_name, commit)[source]¶
- Revert the contents of a recipe to that of a previous commit - Parameters: - Returns: - OId of the new commit - Return type: - Git.OId - Raises: - Can raise errors from Ggit 
- 
pylorax.api.recipes.tag_file_commit(repo, branch, filename)[source]¶
- Tag a file's most recent commit - Parameters: - Returns: - Tag id or None if it failed. - Return type: - Git.OId - Raises: - Can raise errors from Ggit - This uses git tags, of the form refs/tags/<branch>/<filename>/r<revision> Only the most recent recipe commit can be tagged to prevent out of order tagging. Revisions start at 1 and increment for each new commit that is tagged. If the commit has already been tagged it will return false. 
- 
pylorax.api.recipes.tag_recipe_commit(repo, branch, recipe_name)[source]¶
- Tag a file's most recent commit - Parameters: - Returns: - Tag id or None if it failed. - Return type: - Git.OId - Raises: - Can raise errors from Ggit - Uses tag_file_commit() 
pylorax.api.regexes module¶
pylorax.api.server module¶
pylorax.api.timestamp module¶
pylorax.api.v0 module¶
pylorax.api.workspace module¶
- 
pylorax.api.workspace.workspace_delete(repo, branch, recipe_name)[source]¶
- Delete the recipe from the workspace - Parameters: - Returns: - None - Raises: - IO related errors 
- 
pylorax.api.workspace.workspace_dir(repo, branch)[source]¶
- Create the workspace's path from a Repository and branch - Parameters: - repo (Git.Repository) -- Open repository
- branch (str) -- Branch name
 - Returns: - The path to the branch's workspace directory - Return type: