genvid.toolbox.ProjectTool¶
Warning
This module has been deprecated. Although the code is still working for our oldest model, it is not expected to work with the new Bastion API. Please use the new genvid-sdk tool.
-
class
genvid.toolbox.
ProjectTool
(**kwargs)¶ Bases:
genvid.toolbox.consul_template.ConsulTemplateTool
Tool for managing project files.
Changed in version 1.30.0:
LOGS
have been moved toClusterTool
and it’s now considered deprecated.-
get_project_file
(dir_or_file)¶ Return a project file.
The argument can be either a directory or a project file. If it is a directory, the following files will be searched in this order inside the directory:
genvid.hcl
,genvid.json
.
-
load_config_folder
(source: typing.Union[pathlib.Path, str], *, env: typing.Union[typing.Mapping[str, str], NoneType] = None, job_template_dir: typing.Union[pathlib.Path, str, NoneType] = None, with_consul_template: bool = False) → dict¶ Loads the configuration file(s) (all files in a directory or a specific file) from the source and returns it.
Parameters: - source – Path to the configuration file/folder.
- with_consul_template – Execute consul-template on the configuration file(s) (if source is a directory) before using it only if it is set to true.
- job_template_dir – Path to Folder from where nomad templates should be loaded. If not mentioned, no jobs will be loaded.
- env – An optional environment to use with
consul-template
. If None, the default environment will be used.
Returns: The configuration as a dictionary that can be used directly with
set_config()
.- :raises FileNotFoundError : If the
job_template_dir
is notNone
and - is not a valid directory.
New in version 1.30.0.
-
load_nomad_job_template
(name, job_folder: typing.Union[pathlib.Path, str])¶ Read nomad job templates from the specific directory. Files only with extension of .nomad.tmpl are read.
Parameters: - name – Name of the file without extension.
- job_folder – Path to directory containing jobs.
New in version 1.30.0: Add support for
pathlib.Path
as job_folder.
-
load_project
(dir_or_file: str, **kwargs)¶ Load a project file.
A project file is either a JSON or HCL file (called either
genvid.json
orgenvid.hcl
) which may or may not contain templating directives to be resolved usingconsul-template
.This method sets
PROJECTDIR
to the directory containing the project file as a side effect.Parameters: - dir_or_file – The specified path is going to be recursively
searched to locate a
genvid.json
orgenvid.hcl
project file. - kwargs – All additional keyword parameters are going to be
passed directly to
consul-template
.
Note
The Consul server doesn’t need to run if your file doesn’t require anything from Consul. The result is parsed as either a JSON file if the extension is .json or an HCL file, otherwise.
-
Changed in version 1.21.0:
Adjusted to use the new version of
ConsulTemplateTool
.
- dir_or_file – The specified path is going to be recursively
searched to locate a
-
update_config
(config: dict, isLocal: bool)¶ Update the specified configuration.
Parameters: - config – The configuration to update.
- isLocal – If the configuration is for a local cluster or a remote cluster.
Returns: The updated configuration.
New in version 1.31.0.
-
update_project
(project, _islocal=None)¶ This method tries to update a project to the newer Genvid version.
The update runs after the template engines are run, so could lose some information.
-
-
class
project.
ProjectTool
¶ Implementation of
genvid.toolbox.ProjectTool