Metadata-Version: 2.4
Name: pynetappfoundry
Version: 0.1.0
Summary: ONTAP administration library and CLI tools
Project-URL: Homepage, https://github.com/endavis/pynetappfoundry
Project-URL: Repository, https://github.com/endavis/pynetappfoundry
Project-URL: Documentation, https://github.com/endavis/pynetappfoundry/tree/main/docs
Project-URL: Issues, https://github.com/endavis/pynetappfoundry/issues
Author-email: Eric Davis <endavis@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Eric Davis
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: administration,cli,netapp,ontap,storage
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.13
Requires-Dist: click>=8.1
Requires-Dist: cryptography>=46.0.6
Requires-Dist: doit>=0.36.0
Requires-Dist: jsonschema>=4.25.1
Requires-Dist: netapp-ontap>=9.17.1.0
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pandas>=2.3.3
Requires-Dist: paramiko>=4.0.0
Requires-Dist: psutil>=7.1.2
Requires-Dist: pydantic>=2.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: requests>=2.31
Requires-Dist: rich>=15.0.0
Requires-Dist: tenacity>=8.2
Requires-Dist: tomli-w>=1.0
Requires-Dist: xlsxwriter>=3.2.9
Requires-Dist: yattag>=1.15
Provides-Extra: dev
Requires-Dist: codespell>=2.2; extra == 'dev'
Requires-Dist: commitizen>=4.13.10; extra == 'dev'
Requires-Dist: hypothesis>=6.151.14; extra == 'dev'
Requires-Dist: mkdocs-material>=9.5; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=1.0.3; extra == 'dev'
Requires-Dist: mutmut>=3.0; extra == 'dev'
Requires-Dist: mypy>=1.20.1; extra == 'dev'
Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
Requires-Dist: pyproject-fmt>=2.0; extra == 'dev'
Requires-Dist: pyright>=1.1.0; extra == 'dev'
Requires-Dist: pytest-benchmark>=4.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
Requires-Dist: pytest>=9.0.3; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: radon>=6.0; extra == 'dev'
Requires-Dist: ruff>=0.15.10; extra == 'dev'
Requires-Dist: types-paramiko>=4.0.0.20260408; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0.12.20260408; extra == 'dev'
Requires-Dist: types-requests>=2.33.0.20260408; extra == 'dev'
Requires-Dist: vulture>=2.11; extra == 'dev'
Provides-Extra: security
Requires-Dist: bandit>=1.7; extra == 'security'
Requires-Dist: cyclonedx-bom>=4.0; extra == 'security'
Requires-Dist: pip-audit>=2.6; extra == 'security'
Requires-Dist: pip-licenses>=4.0; extra == 'security'
Requires-Dist: pip>=26.0; extra == 'security'
Description-Content-Type: text/markdown

# pynetappfoundry

ONTAP administration library and CLI tools.

## Installation

```bash
pip install pynetappfoundry
```

For development:

```bash
pip install -e ".[dev]"
```

## CLI Usage

pynetappfoundry provides a single CLI entry point `nf` with subcommand groups:

```bash
# License management
nf licenses check --filter '{"bu":"Business"}'
nf licenses get --config-dir /path/to/config
nf licenses savings --output-dir ./output

# Reports
nf reports space-usage --filter '{"env":"Prod"}'
nf reports locks
nf reports html

# Events
nf events get --filter '{"name":"cluster1"}'
nf events save-azure

# Metrics
nf metrics dump-dii

# Utilities
nf utils validate
nf utils run-cmd "vol show"
nf utils sqlite-to-excel metrics.db
```

### Common Options

All commands support these global options:

- `--config-dir, -c`: Configuration directory path (default: `config`)
- `--output-dir, -o`: Output directory path
- `--debug/--no-debug`: Enable debug logging
- `--filter, -f`: JSON filter for cluster selection

### Filter Syntax

The filter option accepts JSON with AND/OR logic:

```bash
# Match all criteria
-f '{"bu":"Business", "env":"Prod", "tags":"active"}'

# AND operator for tags
-f '{"tags":"active && workload"}'

# OR operator
-f '{"app": "app1 || app2"}'

# Multiple clusters by name
-f '{"name":"cluster1 || cluster2"}'
```

## Library Usage

pynetappfoundry can also be used as a library in your own scripts:

```python
from pynetappfoundry import Config, ONTAPAPIClient, ONTAPCLI
from pynetappfoundry.db import MetricDB
from pynetappfoundry.utils import approximate_size

# Load configuration
config = Config("/path/to/config")
clusters = config.get_clusters({"env": "Prod", "bu": "Business"})

# Query clusters
for name, details in clusters.items():
    # Using the ONTAP Python SDK (via HostConnection)
    user, password = config.get_user("clusters", name)

    # Or use the CLI wrapper for SSH commands
    cli = ONTAPCLI(name, details["ip"], user, password)
    output = cli.run_command("vol show")
    cli.disconnect()

# Work with metrics database
db = MetricDB(config)
db.create_table("cluster_metrics")
db.upsert_data("cluster_metrics", {"timestamp": "2024-01-01", "read_ops": 100})
```

## Configuration

Create a `config` directory with TOML files:

### settings.toml

```toml
[settings]
[settings.clusters]
searchable_keys = ["name", "bu", "env", "app", "tags"]

[settings.SMTP]
server = "smtp.example.com"
port = 25
user = ""
password = ""
auth = "False"

[settings.licensing]
mailfrom = "netapp-alerts@example.com"
mailto = "admin@example.com"
```

### users.toml

```toml
[users.clusters]
user = "admin"
enc = "password"
```

### clusters.toml

```toml
[settings]
type = "data"

[clusters.cluster1]
name = "cluster1"
ip = "10.0.0.1"
bu = "Business"
env = "Prod"
tags = ["active", "production"]

[clusters.cluster2]
name = "cluster2"
ip = "10.0.0.2"
bu = "Business"
env = "Dev"
tags = ["active", "development"]
```

## Development

```bash
# Clone the repository
git clone https://github.com/endavis/pynetappfoundry.git
cd pynetappfoundry

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check src/

# Run type checking
mypy src/
```

## License

MIT License - see LICENSE file for details.
