Spotinst Agent
The `spotinst-agent` is a Python-based executor designed as a spectrum instance agent. Its primary function is to run remote scripts, collect data, and deploy applications on machines using a polling architecture. It's an active project, with version 1.1.260 released in June 2024, and appears to follow a regular release cadence.
Warnings
- gotcha The `spotinst-agent` PyPI package was uploaded using `CPython/2.7.18` and does not explicitly declare a `requires_python` version. This suggests it might have been developed for or is compatible with Python 2.7, which is end-of-life. Users on modern Python 3 environments should test compatibility carefully, as other Spotinst Python libraries (like `spotinst-sdk2`) require Python 3.7+.
- gotcha The `spotinst-agent` is a configuration-driven service, relying on YAML files like `agent.yml` for global settings and specific worker configurations. Misconfigurations in these files are a common source of operational issues, rather than code-level errors.
- gotcha Users often confuse `spotinst-agent` with the `spotinst-sdk` or `spotinst-sdk2` Python libraries. `spotinst-agent` is a deployed service for executing scripts, while the SDKs provide programmatic access to Spotinst (now Spot) APIs for managing cloud resources.
- gotcha Authentication for Spotinst services (including potentially the agent's internal operations or related tools like `spotctl`) often relies on a specific precedence for credentials: parameters in a client object, environment variables (`SPOTINST_TOKEN`, `SPOTINST_ACCOUNT`), or a shared credentials file (`~/.spotinst/credentials`). Incorrectly set or conflicting credentials can lead to authentication failures.
Install
-
pip install spotinst-agent
Imports
- spotinst-agent
The `spotinst-agent` package is primarily an executable agent/service, not typically imported directly as a Python library for programmatic interaction. Its functionality is exposed via deployment and configuration rather than a Python API.
Quickstart
# Install the agent
pip install spotinst-agent
# The Spotinst agent is typically run as a service or within a container.
# Its configuration is handled via YAML files (e.g., 'agent.yml') and worker configurations.
# Direct Python code interaction for 'spotinst-agent' itself is uncommon.
#
# Example of how you might *start* the agent process (conceptual, actual command depends on deployment):
# This usually involves running a command-line utility or daemonizing a script provided by the package.
# For example, if it had a main entry point:
# python -m spotinst_agent.main --config /path/to/agent.yml
#
# For interacting with Spotinst APIs programmatically, use the Spotinst SDK:
# import os
# from spotinst_sdk import SpotinstClient
#
# # Authenticate using environment variables (recommended for quickstart)
# # export SPOTINST_TOKEN='YOUR_SPOTINST_API_TOKEN'
# # export SPOTINST_ACCOUNT='YOUR_SPOTINST_ACCOUNT_ID'
#
# client = SpotinstClient(
# auth_token=os.environ.get('SPOTINST_TOKEN', 'YOUR_SPOTINST_API_TOKEN'),
# account_id=os.environ.get('SPOTINST_ACCOUNT', 'YOUR_SPOTINST_ACCOUNT_ID')
# )
# # Example: fetch all Elastigroups (this requires spotinst-sdk, not spotinst-agent)
# # elastigroups = client.get_all_elastigroups()
# # print(elastigroups)