On branch main

Initial commit

 Changes to be committed:
	new file:   README.md
	new file:   abx/apply_nsx_tags_for_tiers/README.md
	new file:   abx/apply_nsx_tags_for_tiers/action.py
	new file:   abx/list_vcenter_vms/README.md
	new file:   abx/list_vcenter_vms/action.py
	new file:   abx/send_email/README.md
	new file:   abx/send_email/action.py
	new file:   blueprints/forms/vdefend-form.json
	new file:   blueprints/vdefend-form-driven.yaml
This commit is contained in:
fultonbr
2025-09-18 09:40:08 -05:00
commit 24ff9fd2fc
9 changed files with 446 additions and 0 deletions

9
abx/send_email/README.md Normal file
View File

@@ -0,0 +1,9 @@
# ABX: send_email (Python 3)
Sends a summary email to the requester with the created section/groups and the chosen ports.
## Inputs
- smtp_host, smtp_port (25 default), smtp_user/smtp_pass (optional), use_tls (bool)
- from_email, to_email, subject, body (text)
This action is generic; blueprint post-processing can construct a friendly body.

34
abx/send_email/action.py Normal file
View File

@@ -0,0 +1,34 @@
import smtplib, ssl, os
from email.mime.text import MIMEText
def handler(context, inputs):
smtp_host = inputs.get("smtp_host") or os.getenv("SMTP_HOST")
smtp_port = int(inputs.get("smtp_port", 25))
smtp_user = inputs.get("smtp_user") or os.getenv("SMTP_USER")
smtp_pass = inputs.get("smtp_pass") or os.getenv("SMTP_PASS")
use_tls = bool(inputs.get("use_tls", False))
from_email = inputs["from_email"]
to_email = inputs["to_email"]
subject = inputs.get("subject", "vDefend policy created")
body = inputs.get("body", "")
msg = MIMEText(body, "plain", "utf-8")
msg["Subject"] = subject
msg["From"] = from_email
msg["To"] = to_email
if use_tls:
context = ssl.create_default_context()
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls(context=context)
if smtp_user and smtp_pass:
server.login(smtp_user, smtp_pass)
server.send_message(msg)
else:
with smtplib.SMTP(smtp_host, smtp_port) as server:
if smtp_user and smtp_pass:
server.login(smtp_user, smtp_pass)
server.send_message(msg)
return {"status": "sent", "to": to_email}