Linode Metadata Client for Python
This package allows Python projects to easily interact with the Linode Metadata Service.
Getting Started
Prerequisites
- Python >= 3.8
- A running Linode Instance
Installation
pip install linode-metadata
Building from Source
To build and install this package:
- Clone this repository
make install
Examples
The following code snippets show multiple different ways to use the metadata client and retrieves various metadata of the current Linode.
Basic Usage
from linode_metadata import MetadataClient
client = MetadataClient()
instance_info = client.get_instance()
network_info = client.get_network()
ssh_info = client.get_ssh_keys()
user_data = client.get_user_data()
print("Instance ID:", instance_info.id)
print("Public IPv4:", network_info.ipv4.public[0])
print("SSH Keys:", "; ".join(ssh_info.users))
print("User Data:", user_data)
Asynchronous I/O and Context Manager Support
You can also use the context manager to ensure the HTTP client will be properly closed, and the
asyncio enabled client is also available.
import asyncio
from linode_metadata import AsyncMetadataClient
async def get_metadata():
with AsyncMetadataClient() as client:
instance_info = await client.get_instance()
print("Instance ID:", instance_info.id)
asyncio.run(get_metadata())
Watchers
Watchers are useful for monitor changes in the metadata, e.g. newly added IP address to the Linode.
import asyncio
from linode_metadata import AsyncMetadataClient
async def get_metadata():
async with AsyncMetadataClient() as client:
watcher = client.get_watcher()
async for new_network_info in watcher.watch_network():
print(new_network_info)
asyncio.run(get_metadata())
Testing
Before running tests on this project, please ensure you have a
Linode Personal Access Token
exported under the LINODE_TOKEN environment variable.
End-to-End Testing Using Ansible
This project contains an Ansible playbook to automatically deploy the necessary infrastructure and run end-to-end tests on it.
To install the dependencies for this playbook, ensure you have Python 3 installed and run the following:
make test-deps
After all dependencies have been installed, you can run the end-to-end test suite by running the following:
make int-test
If your local SSH public key is stored in a location other than ~/.ssh/id_rsa.pub,
you may need to override the TEST_PUBKEY argument:
make TEST_PUBKEY=/path/to/my/pubkey int-test
NOTE: To speed up subsequent test runs, the infrastructure provisioned for testing will persist after the test run is complete. This infrastructure is safe to manually remove.
Manual End-to-End Testing
End-to-end tests can also be manually run using the make int-test-local target.
This test suite is expected to run from within a Linode instance and will likely
fail in other environments.
License
This software is Copyright Akamai Technologies, Inc. and is released under the Apache 2.0 license.
Metadata
Release files for lgarber-fork-linode-metadata 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lgarber_fork_linode_metadata-0.2.0.tar.gz | 16.1 kB | Without provenance | Details for lgarber_fork_linode_metadata-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lgarber_fork_linode_metadata-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for lgarber_fork_linode_metadata-0.2.0-py3-none-any.whl |
Total release size: 34.9 kB
Release files / lgarber_fork_linode_metadata-0.2.0.tar.gz
| Download URL | lgarber_fork_linode_metadata-0.2.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2ec67861e8a98b104ed82e577c13332017ec5cb7200554a6c0dd29d4bc0130c
|
|
BLAKE2b-256 checksum How to use checksums |
5fc628454d07f19d71aa112add17e7807414264ff830df7c1b7486bf27428bf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / lgarber_fork_linode_metadata-0.2.0-py3-none-any.whl
| Download URL | lgarber_fork_linode_metadata-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6202272a000cc9bbc6a3b5cf0ad261644f6a93527672dd6054a684d18bfd8dbb
|
|
BLAKE2b-256 checksum How to use checksums |
6dd12c319c634b4c6f88009e5300b5fa97724087974d3564e92ef88b9dd1c2c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for lgarber-fork-linode-metadata 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.