linchpin.cli module

This page contains the list of project’s modules

class linchpin.cli.LinchpinCli(ctx)
__init__(ctx)

Set some variables, pass to parent class

lp_up(pinfile, targets='all')

This function takes a list of targets, and provisions them according to their topology. If an layout argument is provided, an inventory will be generated for the provisioned nodes.

Parameters:
  • pinfile – Provided PinFile, with available targets,
  • targets – A tuple of targets to provision.
lp_destroy(pinfile, targets='all')

This function takes a list of targets, and performs a destructive teardown, including undefining nodes, according to the target.

See also

lp_down - currently unimplemented

Parameters:
  • pinfile – Provided PinFile, with available targets,
  • targets – A tuple of targets to destroy.
lp_down(pinfile, targets='all')

This function takes a list of targets, and performs a shutdown on nodes in the target’s topology. Only providers which support shutdown from their API (Ansible) will support this option.

CURRENTLY UNIMPLEMENTED

See also

lp_destroy

Parameters:
  • pinfile – Provided PinFile, with available targets,
  • targets – A tuple of targets to provision.
run_playbook(pinfile, targets='all', playbook='up')

This function takes a list of targets, and executes the given playbook (provison, destroy, etc.) for each provided target.

Parameters:
  • pinfile – Provided PinFile, with available targets,
  • targets – A tuple of targets to run. (default: ‘all’)
find_topology(topology)

Find the topology to be acted upon. This could be pulled from a registry.

Parameters:topology – name of topology from PinFile to be loaded
get_cfg(section=None, key=None, default=None)

Get cfgs value(s) by section and/or key, or the whole cfgs object

Parameters:
  • section – section from ini-style config file
  • key – key to get from config file, within section
  • default – default value to return if nothing is found.

Does not apply if section is not provided.

set_cfg(section, key, value)

Set a value in cfgs. Does not persist into a file, only during the current execution.

Parameters:
  • section – section within ini-style config file
  • key – key to use
  • value – value to set into section within config file
get_evar(key=None, default=None)

Get the current evars (extra_vars)

Parameters:
  • key – key to use
  • default – default value to return if nothing is found (default: None)
set_evar(key, value)

Set a value into evars (extra_vars). Does not persist into a file, only during the current execution.

Parameters:
  • key – key to use
  • value – value to set into evars
lp_rise(pinfile, targets='all')

DEPRECATED

An alias for lp_up. Used only for backward compatibility.

lp_drop(pinfile, targets)

DEPRECATED

An alias for lp_destroy. Used only for backward compatibility.

class linchpin.cli.context.LinchpinCliContext

Context object, which will be used to manage the cli, and load the configuration file

get_cfg(section=None, key=None, default=None)

Get cfgs value(s) by section and/or key, or the whole cfgs object

Parameters:
  • section – section from ini-style config file
  • key – key to get from config file, within section
  • default – default value to return if nothing is found.

Does not apply if section is not provided.

get_evar(key=None, default=None)

Get the current evars (extra_vars)

Parameters:
  • key – key to use
  • default – default value to return if nothing is found (default: None)
load_config(lpconfig=None)

Create self.cfgs from the linchpin configuration file.

Note

Overrides load_config in linchpin.api.LinchpinContext

These are the only hardcoded values, which are used to find the config file. The search path, is a first found of the following:

* $PWD/linchpin.conf
* ~/.linchpin.conf
* /etc/linchpin.conf
* /linchpin/library/path/linchpin.conf

Alternatively, a full path to the linchpin configuration file can be passed.

Parameters:lpconfig – absolute path to a linchpin config (default: None)
load_global_evars()

Instantiate the evars variable, then load the variables from the ‘evars’ section in linchpin.conf. This will then be passed to invoke_linchpin, which passes them to the Ansible playbook as needed.

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

set_cfg(section, key, value)

Set a value in cfgs. Does not persist into a file, only during the current execution.

Parameters:
  • section – section within ini-style config file
  • key – key to use
  • value – value to set into section within config file
set_evar(key, value)

Set a value into evars (extra_vars). Does not persist into a file, only during the current execution.

Parameters:
  • key – key to use
  • value – value to set into evars
setup_logging()

Setup logging to a file, console, or both. Modifying the linchpin.conf appropriately will provide functionality.