Introduction to ScienceLogic Libraries and Execution Environments

Download this manual as a PDF file

This section describes how to create and manage ScienceLogic Libraries and Execution Environments.

What is a ScienceLogic Library?

Some Dynamic Applications, credential tests, and Run Book Actions in SL1 collect data or complete automated actions by executing one or more blocks of Python code, called snippets. When this happens, SL1 passes credentials and other configuration information to the snippet, and at the end of execution, the snippet either passes collected data back to SL1 or runs an action. Upon release of version 12.1.0, SL1 upgraded to Python 3.

ScienceLogic Library is a package consisting of metadata and Python files that can be used by the Dynamic Applications, credential tests, and Run Book Actions that use snippets. ScienceLogic Libraries can be included in a PowerPack along with the Dynamic Applications, credential tests, and Run Book Actions that they support.

These are a few reasons you might want to create and use a ScienceLogic library in your PowerPack:

  • You have a few short Python functions or classes you want to share between snippets (py_directory).
  • You have a Python package you created that you want to share between snippets (py_package).
  • You have a third-party package that needs to be available during snippet execution (py_package).

ScienceLogic Libraries have two formats. The type that you use depends on your Python expertise and your requirements:

  • py_directory (.tar format). This file type includes metadata and a directory of Python source files. This format is most useful for users who are not experienced Python developers or who do not want the overhead of Python packages.
  • py_package (.tar format). This file type includes metadata and Python packages. This format requires an understanding of Python packaging tools. While this format is more complex, it also allows you to more easily take advantage of unit tests, automatic versioning, and other common packaging practices.

ScienceLogic Libraries can be installed on SL1 in three ways:

  • Some libraries are included when you install SL1 or run system updates.
  • Libraries that are included in a PowerPack are installed on SL1 when you install the PowerPack.
  • Libraries can be manually imported into SL1.

You can view all of the installed ScienceLogic Libraries on the ScienceLogic Library Manager page (System > Customize > ScienceLogic Libraries).

For details about how to manage libraries in SL1, see the Managing ScienceLogic Libraries section.

What is an Execution Environment?

To use a ScienceLogic Library, you must align it with an execution environment.

In the SL1 user interface, an execution environment is a list of one or more ScienceLogic libraries. When a Dynamic Application snippet, Run Book Automation snippet, or credential test is executed, the execution environment defines a virtual Python environment that is deployed on-demand and includes all of the ScienceLogic libraries aligned with it for use during snippet execution.

A ScienceLogic Library can be associated with multiple execution environments, allowing you to share code between snippets, Dynamic Applications, and PowerPacks. A ScienceLogic Library can be aligned with only a single execution environment at a time.

Execution environments must be specified when creating or editing the following:

  • Snippets
  • Credential tests
  • Run Book Action policies that execute a snippet

When SL1 runs a snippet embedded in a Dynamic Application, credential test, or a Run Book Action, it automatically deploys the runtime environment defined by the execution environment. The runtime environment includes each library aligned with the execution environment, plus system libraries that are provided by SL1.

If you do not specify the execution environment for a Dynamic Application, credential test, or Run Book Action, SL1 aligns them with a system-default execution environment. This default execution environment is defined in each SL1 System update.

When you build a PowerPack, it automatically includes the execution environments that are aligned with the PowerPack's Dynamic Applications, credential tests, and Run Book Actions that execute snippets.

Additionally, built-in non-snippet Dynamic Application types use a pre-deployed, read only Python 3 execution environment, "sl1_default_ee". This execution environment appears on the Environment Manager page (System>Customize> ScienceLogic Libraries>Action button>Execution Environments), but you cannot edit or delete it. Whenever, new, built-in Dynamic Applications are created via the user interface, they will be automatically assigned to this execution environment.

As a part of this update, the internal collection processes and Internal Collection Dynamic Applications (ICDAs) now run on Python 3. The snippet code that is included in these Dynamic Applications must be Python 3, or at least Python 2/3-compliant.

For details about how to create and manage execution environments in SL1, see the Managing Execution Environments section.

For more information about aligning execution environments with Dynamic Applications, credential tests, or Run Book Actions, see the following sections: