LinchPin Command-Line API
The linchpin.cli module provides an API for writing a command-line interface, the LinchPin Command Line Shell implementation being the reference implementation.
- class linchpin.cli.LinchpinCli(ctx)
- find_include(filename, ftype='topology')
Find the included file to be acted upon.
- Parameters
filename – name of file from to be loaded
ftype – the file type to locate: topology, layout (default: topology)
- lp_destroy(targets=(), run_id=None, tx_id=None, env_vars=None)
This function takes a list of targets, and performs a destructive teardown, including undefining nodes, according to the target(s).
See also
lp_down - currently unimplemented
- Parameters
targets – A tuple of targets to destroy.
run_id – An optional run_id to use
tx_id – An optional tx_id to use
- lp_fetch(src, root='', fetch_type='workspace', fetch_protocol='FetchGit', fetch_ref=None, dest_ws=None, nocache=False)
Fetch a workspace from git, http(s), or a local directory, and generate a provided workspace
- Parameters
src – The URL or URI of the remote directory
root – Used to specify the location of the workspace within the remote. If root is not set, the root of the given remote will be used.
fetch_type – Specifies which component(s) of a workspace the user wants to fetch. Types include: topologies, layouts, resources, hooks, workspace. (default: workspace)
fetch_protocol – The protocol to use to fetch the workspace. (default: git)
fetch_ref – Specify the git branch. Used only with git protocol (eg. master). If not used, the default branch will be used.
dest_ws –
Workspaces destination, the workspace will be relative to this location.
If dest_ws is not provided and -r/–root is provided, the basename will be the name of the workspace within the destination. If no root is provided, a random workspace name will be generated. The destination can also be explicitly set by using -w (see linchpin –help).
nocache – If true, don’t copy from the cache dir, unless it’s longer than the configured fetch.cache_days (1 day) (default: False)
- lp_init(providers=['libvirt'])
Initializes a linchpin project. Creates the necessary directory structure, includes PinFile, topologies and layouts for the given provider. (Default: Dummy. Other providers not yet implemented.)
- Parameters
providers – A list of providers for which templates
(and a target) will be provided into the workspace. NOT YET IMPLEMENTED
- lp_setup(providers='all')
This function takes a list of providers, and setsup the dependencies :param providers:
A tuple of providers to install dependencies
- lp_up(targets=(), run_id=None, tx_id=None, inv_f='cfg', env_vars=())
This function takes a list of targets, and provisions them according to their topology.
- Parameters
targets – A tuple of targets to provision
run_id – An optional run_id if the task is idempotent
tx_id – An optional tx_id if the task is idempotent
- lp_validate(targets=(), old_schema=False)
This function takes a list of targets, and validates their topology.
- Parameters
targets – A tuple of targets to provision
- :param old_schema
Denotes whether schema should be validated with the old schema rather than the new one!/usr/bin/env python
- property pf_data
getter for pinfile template data
- property pinfile
getter function for pinfile name
- property workspace
getter function for context workspace
- class linchpin.cli.context.LinchpinCliContext
Context object, which will be used to manage the cli, and load the configuration file
- property inventory
getter function for inventory
- property inventory_folder
getter function for inventory_folder
- property inventory_path
getter function for inventory_path
- load_config(lpconfig=None)
Update self.cfgs from the linchpin configuration file (linchpin.conf).
The following paths are used to find the config file. The search path defaults to the first-found order:
* /etc/linchpin.conf * /linchpin/library/path/linchpin.conf * <workspace>/linchpin.conf
An alternate search_path can be passed.
- Parameters
search_path – A list of paths to search a linchpin config
(default: None)
- log(msg, **kwargs)
Logs a message to a logfile or the console
- Parameters
msg – message to log
lvl – keyword argument defining the log level
msg_type – keyword argument giving more flexibility.
Note
Only msg_type STATE is currently implemented.
- log_debug(msg)
Logs a DEBUG message
- log_info(msg)
Logs an INFO message
- log_state(msg)
Logs a message to stdout
- property pinfile
getter function for pinfile name
- setup_logging()
Setup logging to a file, console, or both. Modifying the linchpin.conf appropriately will provide functionality.
- property workspace
getter function for workspace