NAME

LCFG::Component::Plugin - LCFG component environment initialization plugin

VERSION

This documentation refers to LCFG::Component::Plugin version 1.18.7

SYNOPSIS

package LCFG::Component::Plugin::Foo;
use parent qw(LCFG::Component::Plugin);

sub run {
  my ($self) = @_;
  my $comp = $self->component;

  for my $key ($self->params_list) {
      my $value = $self->param($key);
      if ( $comp->{_DEBUG} ) {
          $comp->Debug("Setting env var '$key' to '$value'");
      }
      $ENV{$key} = $value;
  }

  return;
}

DESCRIPTION

This is a base class from which all LCFG method environment initialization plugin modules should inherit. Typically all that is required is for the sub-class to implement the run method to provide the required initialization. The base class provides access to any appropriate parameters which are provided in the ngeneric resources for the component.

By default the following LCFG component methods will run environment initialization plugins: configure, start, restart, stop, run, logrotate, suspend and resume. You can alter your own component-specific methods to use the environment initialization plugins by adding a call to the InitializeEnvironment method after loading the resources.

ATTRIBUTES

The base class has the following attributes:

component

This is a reference to the LCFG::Component object from which this plugin was loaded. This is useful for logging and gaining access to the various variables which control the logging levels (e.g. debug, verbose).

params_list

This is a list of names of parameters which were specified in the ngeneric resources.

If you call this method in a list context it returns a list otherwise it returns a reference to a list.

params

This is a reference to a hash of the names and values of the parameters which were specified in the ngeneric resources.

SUBROUTINES/METHODS

new(%attributes)

This creates a new plugin object, it takes the following attributes: component, params_list and params. See the list above for details. See the LCFG RESOURCES section below for details on how the ngeneric resources for a component are mapped into the params list.

param($key)

This is a convenience method which returns the value of the named parameter from the params hash.

run()

This method does the environment initialization for the LCFG component method call. You should override this method in your sub-class.

LCFG RESOURCES

The list of plugins which should be run for a particular LCFG component should be specified via the relevant ng_plugins resource. For each plugin it is possible to specify a list of parameters via the ng_plugin_params_plugin resource. For each parameter in that list it is possible to specify a value via a ng_plugin_param_plugin_param resource, if no value is specified then the value of 1 is used.

The attributes are mapped into the plugin with the ng_plugin_param_plugin_ prefix removed. For example, if a component uses the env plugin (ng_plugins contains env) with a foo parameter (ng_plugin_params_env is foo) then when the LCFG::Component::Plugin::Env object is created a foo parameter will be passed in and the value will come from the ng_plugin_param_env_foo resource for the component. See lcfg-ngeneric(8) for more details. This is done by the CallPlugins method in LCFG::Component which is called by the InitializeEnvironment method.

DEPENDENCIES

This module has no dependencies.

SEE ALSO

LCFG::Component, LCFG::Component::Plugin::Env

PLATFORMS

This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

ScientificLinux6, EnterpriseLinux7, MacOSX

BUGS AND LIMITATIONS

Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.

AUTHOR

Paul Anderson <dcspaul@inf.ed.ac.uk>

LICENSE AND COPYRIGHT

Copyright (C) 2014-2015 University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.