A library for Cray Systems Management.
-
With
pip
python -m pip install setuptools_scm[toml] python -m pip install .
-
With
build
andpip
python -m pip install build python -m build python -m pip install ./dist/*.whl
This module is not published to PyPi, but it is published to the Cray-HPE CSM Artifactory pip repository (which requires credentials). To use this module without credentials, the GitHub repository must be referenced directly.
-
Install
-
From Artifactory (requires authentication)
-
Stable (
artifactory.algol60.net/artifactory/csm-python-modules/simple
)Commandpython3 -m pip install --extra-index-url https://{$ARTIFACTORY_USER}:${ARTIFACTORY_TOKEN}@artifactory.algol60.net/artifactory/csm-python-modules/simple libcsm
OutputLooking in indexes: https://pypi.org/simple, https://doomslayer:****@artifactory.algol60.net/artifactory/csm-python-modules/simple Collecting libcsm Downloading https://artifactory.algol60.net/artifactory/csm-python-modules/simple/libcsm/libcsm-0.0.1-py2.py3-none-any.whl (24 kB) Installing collected packages: libcsm Successfully installed libcsm-0.0.1
-
Unstable (
artifactory.algol60.net/artifactory/csm-python-modules/unstable
)Commandpython3 -m pip install --extra-index-url https://{$ARTIFACTORY_USER}:${ARTIFACTORY_TOKEN}@artifactory.algol60.net/artifactory/csm-python-modules/unstable libcsm
OutputLooking in indexes: https://pypi.org/simple, https://doomslayer:****@artifactory.algol60.net/artifactory/csm-python-modules/unstable Collecting libcsm Downloading https://artifactory.algol60.net/artifactory/csm-python-modules/unstable/libcsm/libcsm-0.0.1a2.dev1%2Bg757ad3a-py2.py3-none-any.whl (24 kB) Installing collected packages: libcsm Successfully installed libcsm-0.0.1a2.dev1+g757ad3a
-
-
From the VCS URL
# From the cloned repository python3 -m pip install . # From the Git URL python3 -m pip install git+https://github.com/Cray-HPE/libcsm.git # From the Git URL from a branch python3 -m pip install git+https://github.com/Cray-HPE/libcsm.git@main # From the Git URL from tag python3 -m pip install git+https://github.com/Cray-HPE/[email protected]
-
Import into another Python script or module with a standard import
call:
import libcsm
Look below for examples using the libcsm
in pyproject.toml
, setup.py
, and requirements.txt
based projects.
For more information regarding VCS versioning and dependency managment, see the following references
-
pip’s documentation on VCS support
libCSM is offered as an OS package (an rpm
), this package installs libCSM and its dependencies into
a virtual environment on the system. The package will depend on a flavor of the python-base
package
respective to the distribution being used.
rpm
is only available to internal HPE, it will be available via GitHub releases in the near future.-
To install and activate the virtualenv:
zypper --plus-repo=https://artifactory.algol60.net/artifactory/csm-rpms/hpe/stable/sle-$(awk -F= '/VERSION=/{gsub(/["-]/, "") ; print tolower($NF)}' /etc/os-release)/ --no-gpg-checks in libcsm
-
Then use
libcsm
.-
Activate the virtual environment
source /usr/lib/libcsm/python/bin/activate
-
Use the package ad-hoc in a Python interpreter:
/usr/lib/libcsm/python/bin/python
import libcsm
-
For setup.py
files, the GitHub source can be included in another project by adding a dependency_links=[]
parameter in the setup()
function call.
-
pyproject.toml
by branch name, git-tag, or git release[project] # ... dependencies = [ "libcsm @ git+https://github.com/Cray-HPE/libcsm.git@main", "libcsm @ git+https://github.com/Cray-HPE/[email protected]", "libcsm @ git+https://github.com/Cray-HPE/libcsm.git@eleases/tag/v1.0.1", ]
-
setup.py
by branch name, git-tag, or git releasesetup( # ... install_requires=[ # ... "libcsm @ git+https://github.com/Cray-HPE/libcsm.git@main", "libcsm @ git+https://github.com/Cray-HPE/[email protected]", "libcsm @ git+https://github.com/Cray-HPE/libcsm.git@eleases/tag/v1.0.1", ], ),
Add a line like the ones below to a requirements.txt
file.
-
By branch name
git+git://github.com/Cray-HPE/libcsm.git@master#egg=libcsm
-
By git tag
git+git://github.com/Cray-HPE/libcsm.git@v1.0.2#egg=libcsm
-
By release
git+git://github.com/Cray-HPE/libcsm.git@releases/tag/v1.0.1#egg=libcsm
The primary purpose of the libcsm
module is to support CSM installation, upgrade, and operational procedures. This module serves as a place for offering functions and error handling to common tasks
pertaining to the aforementioned CSM procedures.
Contributions can be in the form of:
-
Python code that can be imported and used in Python scripts
-
Callables for the command line that make use of one or more functions/modules
When a new or existing module of libcsm
wants to offer a command line function an entry_point
can be used.
For example, if we wanted a command called hms-do-stuff
to exist on the command line that invoked some code within a libcsm
submodule like the
code below:
# file: ./libcsm/hms/service.py
def do_stuff() -> None:
thing = 'cool stuff'
print(f'Doing {thing}')
foo(thing)
def foo(stuff: str) -> None:
with open('/tmp/foo', 'w') as file:
file.write(f'finished doing {stuff}')
Then we could add an Entry Point to the entry_points.ini
file
[console_scripts]
hms-do-stuff = 'libcsm.hms.service:do_stuff'
Use the library in a local/development environment.
SOURCEPREFIX="$(pwd)/sh"
. ${SOURCEPREFIX}/lib.sh
As this is library shell and intended to be usable in minimal containers and elsewhere, we want to ensure all shell is usable in any bourne compatible shell.
That includes ash
, dash
, busybox sh
, etc.
Note c
and teco c
shells are not included in this definition.
To aide in this we have a GitHub action, action-sh-checker that will be used to run the following on all pull requests:
-
shellcheck
-
shfmt
-
checkbashisms
This will help to ensure all library code remains portable and consistently formatted and enforced.
To run this action locally against work in progress changes install act
and/or docker
or some other equivalent and run act -j sh-checker
.
As we want to ensure portability across posix shells, the unit test library of choice is shellspec. For details why see `shellspec’s compression page in essence it has more features than bats and also allows us to ensure other shells function.
To locally run tests ensure one has shellspec
installed and available locally and one may simply run shellspec
or make test
to run all the unit tests.
To run against all configured shells known to work run make test-all
.
If one also has entr installed one can run make ci
to run against all of the configured shells in the makefile
on every update to a shell script.
make ci
+ for s in sh bash ksh
+ shellspec --shell sh
Running: /run/current-system/sw/bin/sh [bash 5.1.16(1)-release]
.............
Finished in 0.68 seconds (user 0.41 seconds, sys 0.27 seconds)
13 examples, 0 failures
+ for s in sh bash ksh
+ shellspec --shell bash
Running: /run/current-system/sw/bin/bash [bash 5.1.16(1)-release]
.............
Finished in 0.68 seconds (user 0.41 seconds, sys 0.26 seconds)
13 examples, 0 failures
+ for s in sh bash ksh
+ shellspec --shell ksh
Running: /bin/ksh [ksh Version AJM 93u+ 2012-08-01]
.............
Finished in 0.40 seconds (user 0.01 seconds, sys 0.00 seconds)
13 examples, 0 failures
+ date
Mon Oct 10 12:39:36 CDT 2022
ℹ️
|
This presumes all of the shells are available locally. This will become a GitHub action as well in a future pull-request. |