Subir archivos a "docs"
This commit is contained in:
220
docs/SCRIPTS.md
Normal file
220
docs/SCRIPTS.md
Normal file
@@ -0,0 +1,220 @@
|
||||
# Scripts y Comandos
|
||||
|
||||
Los scripts CLI estan en `scripts/` y son la ruta avanzada para automatizacion o troubleshooting. Ejecutalos desde la raiz del proyecto con el ambiente virtual activo.
|
||||
|
||||
## Resumen
|
||||
|
||||
| Script | Objetivo | Entrada principal | Salida principal |
|
||||
| --- | --- | --- | --- |
|
||||
| `scripts/aws_fetch_offer.py` | Descargar offer AWS EC2. | Internet AWS Pricing. | `data/raw/aws/index.json`. |
|
||||
| `scripts/aws_eda.py` | Transformar offer AWS y generar EDA. | `data/raw/aws/index.json`. | `data/catalog/aws/aws_ec2_catalog.csv`, `data/eda/aws/aws_eda_*.md`. |
|
||||
| `scripts/aws_match.py` | Recomendar shapes AWS por inventario. | Inventario CSV/XLS/XLSX y catalogo AWS. | `data/match/aws/MATCH-AWS-*.csv`. |
|
||||
| `scripts/oci_fetch_offer.py` | Descargar precios OCI y catalogo plano. | API Oracle products. | `data/raw/oci/products.json`, `data/catalog/oci/oci_price_list.csv`. |
|
||||
| `scripts/oci_match.py` | Generar BOM OCI agregada. | Inventario CSV/XLS/XLSX y catalogo OCI. | `data/match/oci/MATCH-OCI-*.csv`. |
|
||||
| `scripts/cloud-chat.py` | Consultar catalogo cloud por CLI. | Pregunta natural y catalogo AWS. | Respuesta en consola y log. |
|
||||
| `scripts/cloud_chat_runtime.py` | Adaptador importable para Cloud Chat. | Variables de entorno. | Respuesta segura para WhatsApp/Flask. |
|
||||
| `scripts/whatsapp_send.py` | Enviar mensaje WhatsApp por Twilio. | `.env` y `--body`. | Mensaje Twilio o dry-run. |
|
||||
| `scripts/whatsapp_chatbot.py` | Webhook Flask para WhatsApp Cloud Chat. | Twilio webhook. | TwiML sync o respuesta diferida. |
|
||||
| `scripts/whatsapp_logging.py` | Sanitizar logs WhatsApp. | Eventos webhook. | Log diario. |
|
||||
| `scripts/match_shared.py` | Utilidades comunes AWS/OCI. | DataFrames e inventarios. | Mapping, normalizacion y movimiento a done. |
|
||||
| `scripts/cloud_conversion_logging.py` | Logging comun. | Prefijo y mensaje. | `logs/log_cloud_conversion_YYYYMMDD.txt`. |
|
||||
|
||||
## Pipeline AWS
|
||||
|
||||
### Descargar offer
|
||||
|
||||
```bash
|
||||
python scripts/aws_fetch_offer.py
|
||||
```
|
||||
|
||||
Descarga:
|
||||
|
||||
```text
|
||||
data/raw/aws/index.json
|
||||
```
|
||||
|
||||
Efectos:
|
||||
|
||||
- Crea directorio destino si no existe.
|
||||
- Escribe de forma atomica usando archivo temporal.
|
||||
- Registra mensajes con prefijo `>> AWS_fetch_offer>>`.
|
||||
|
||||
### Generar EDA y catalogo
|
||||
|
||||
```bash
|
||||
python scripts/aws_eda.py
|
||||
```
|
||||
|
||||
Con rutas explicitas:
|
||||
|
||||
```bash
|
||||
python scripts/aws_eda.py \
|
||||
--input data/raw/aws/index.json \
|
||||
--eda-output data/eda/aws/aws_eda_manual.md \
|
||||
--catalog-output data/catalog/aws/aws_ec2_catalog.csv
|
||||
```
|
||||
|
||||
Salidas:
|
||||
|
||||
- Catalogo plano AWS EC2.
|
||||
- Reporte Markdown EDA.
|
||||
|
||||
### AWS Match
|
||||
|
||||
```bash
|
||||
python scripts/aws_match.py --inventory input/inventario.xlsx --skip-llm
|
||||
```
|
||||
|
||||
Parametros frecuentes:
|
||||
|
||||
| Parametro | Uso |
|
||||
| --- | --- |
|
||||
| `--inventory` | Archivo CSV/XLS/XLSX de inventario. |
|
||||
| `--aws-catalog` | Catalogo AWS alterno. |
|
||||
| `--output` | CSV de salida. |
|
||||
| `--skip-llm` | Usa reglas deterministicas, sin Ollama. |
|
||||
| `--force-llm` | Fuerza mapeo por LLM. |
|
||||
| `--region-code` | Region AWS, default `us-east-1`. |
|
||||
| `--operating-system` | OS global opcional, por ejemplo `Linux` o `Windows`. |
|
||||
| `--include-previous-generation` | Incluye generaciones anteriores. |
|
||||
| `--include-unused-capacity` | Incluye capacidad distinta de `Used`. |
|
||||
| `--preferred-m-family` | Familia M preferida, default `m7a`. |
|
||||
|
||||
Efectos:
|
||||
|
||||
- Genera `data/match/aws/MATCH-AWS-<inventario>.csv` si no se pasa `--output`.
|
||||
- En CLI puede mover inventario exitoso a `input/done/`.
|
||||
- Registra mensajes con prefijo `>> AWS_match>>`.
|
||||
|
||||
## Pipeline OCI
|
||||
|
||||
### Descargar offer y catalogo OCI
|
||||
|
||||
```bash
|
||||
python scripts/oci_fetch_offer.py
|
||||
```
|
||||
|
||||
Salidas:
|
||||
|
||||
```text
|
||||
data/raw/oci/products.json
|
||||
data/catalog/oci/oci_price_list.csv
|
||||
```
|
||||
|
||||
Efectos:
|
||||
|
||||
- Descarga productos desde API Oracle.
|
||||
- Aplana precios localizados a CSV.
|
||||
- Registra mensajes con prefijo `>> OCI_fetch_offer>>`.
|
||||
|
||||
### OCI Match
|
||||
|
||||
```bash
|
||||
python scripts/oci_match.py --inventory input/inventario.xlsx --skip-llm
|
||||
```
|
||||
|
||||
Parametros frecuentes:
|
||||
|
||||
| Parametro | Uso |
|
||||
| --- | --- |
|
||||
| `--inventory` | Archivo CSV/XLS/XLSX de inventario. |
|
||||
| `--oci-catalog` | Catalogo OCI alterno. |
|
||||
| `--output` | CSV de salida. |
|
||||
| `--skip-llm` | Usa reglas deterministicas, sin Ollama. |
|
||||
| `--force-llm` | Fuerza mapeo por LLM. |
|
||||
| `--compute-series` | Serie OCI Standard, default `E`. |
|
||||
| `--compute-generation` | Generacion fija, por ejemplo `E6`. |
|
||||
| `--hours-per-month` | Horas mensuales, default `730`. |
|
||||
| `--no-move-to-done` | Evita archivar inventario al finalizar. |
|
||||
|
||||
Efectos:
|
||||
|
||||
- Genera `data/match/oci/MATCH-OCI-<inventario>.csv`.
|
||||
- En CLI mueve inventario exitoso a `input/done/` salvo `--no-move-to-done`.
|
||||
- Registra mensajes con prefijo `>> OCI_match>>`.
|
||||
|
||||
## Cloud Chat CLI
|
||||
|
||||
Modo interactivo:
|
||||
|
||||
```bash
|
||||
python scripts/cloud-chat.py
|
||||
```
|
||||
|
||||
Modo one-shot:
|
||||
|
||||
```bash
|
||||
python scripts/cloud-chat.py --ask "Cuanto cuesta m7a.xlarge en virginia?"
|
||||
```
|
||||
|
||||
Opciones:
|
||||
|
||||
```bash
|
||||
python scripts/cloud-chat.py \
|
||||
--provider aws \
|
||||
--catalog data/catalog/aws/aws_ec2_catalog.csv \
|
||||
--model llama3.1:8b \
|
||||
--ask "Que shapes tienen 8 vCPU y al menos 16 GB?"
|
||||
```
|
||||
|
||||
Defaults:
|
||||
|
||||
- Provider: `aws`.
|
||||
- Catalogo: `data/catalog/aws/aws_ec2_catalog.csv`.
|
||||
- Modelo: `llama3.1:8b`.
|
||||
- Region default: `us-east-1`.
|
||||
- OS default: `Linux`.
|
||||
- Horas mensuales: `730`.
|
||||
|
||||
## WhatsApp
|
||||
|
||||
### Envio
|
||||
|
||||
```bash
|
||||
python scripts/whatsapp_send.py --body "Prueba Cloud Conversion" --dry-run
|
||||
```
|
||||
|
||||
Envio real:
|
||||
|
||||
```bash
|
||||
python scripts/whatsapp_send.py --to whatsapp:+52XXXXXXXXXX --body "Hola"
|
||||
```
|
||||
|
||||
Requiere:
|
||||
|
||||
- `TWILIO_ACCOUNT_SID`
|
||||
- `TWILIO_AUTH_TOKEN`
|
||||
- `TWILIO_WHATSAPP_FROM`
|
||||
- `MY_WHATSAPP_TO` si no se pasa `--to`
|
||||
|
||||
### Webhook Cloud Chat
|
||||
|
||||
```bash
|
||||
python scripts/whatsapp_chatbot.py
|
||||
```
|
||||
|
||||
Requiere:
|
||||
|
||||
- `TWILIO_AUTH_TOKEN`
|
||||
- `PUBLIC_WEBHOOK_URL`
|
||||
- Variables de Cloud Chat si quieres cambiar modelo/catalogo.
|
||||
|
||||
El webhook responde sincronamente si la respuesta llega dentro de `WHATSAPP_SYNC_TIMEOUT_SECONDS`. Si tarda mas, devuelve un acuse y manda respuesta diferida por Twilio.
|
||||
|
||||
## Demos legacy
|
||||
|
||||
| Archivo | Estado |
|
||||
| --- | --- |
|
||||
| `server.py` | Demo Flask simple que valida firma Twilio y responde eco. No es el webhook recomendado. |
|
||||
| `send.py` | Demo simple de envio WhatsApp con mensaje fijo. Usa `scripts/whatsapp_send.py` para operacion. |
|
||||
|
||||
## Validar argumentos
|
||||
|
||||
```bash
|
||||
python scripts/aws_match.py --help
|
||||
python scripts/oci_match.py --help
|
||||
python scripts/aws_eda.py --help
|
||||
python scripts/cloud-chat.py --help
|
||||
python scripts/whatsapp_send.py --help
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user