You've already forked netbox-proxmox-power-button
added proxmox power button plugin 0.1
This commit is contained in:
50
proxmox_power_button/__init__.py
Normal file
50
proxmox_power_button/__init__.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
from netbox.plugins import PluginConfig
|
||||
|
||||
|
||||
class ProxmoxPowerButtonConfig(PluginConfig):
|
||||
name = "proxmox_power_button"
|
||||
verbose_name = "Proxmox Power Button"
|
||||
description = "Start/stop/reboot Proxmox VMs from the NetBox VM detail page"
|
||||
version = "0.1.0"
|
||||
author = "Bryan Pedini"
|
||||
base_url = "proxmox-power-button"
|
||||
# The data migration pins extras.0134_owner / virtualization.0052_gfk_indexes,
|
||||
# which first exist in NetBox 4.5.0 — on anything older `migrate` would die
|
||||
# with NodeNotFoundError, so don't claim compatibility we can't honour.
|
||||
min_version = "4.5.0"
|
||||
|
||||
# Optional behaviour, overridable via PLUGINS_CONFIG["proxmox_power_button"]:
|
||||
# verify_ssl : verify the Proxmox TLS cert (default False)
|
||||
# stop_mode : "shutdown" (graceful ACPI, default) or "stop" (hard kill)
|
||||
# reboot_mode : "reboot" (graceful, default) or "reset" (hard)
|
||||
default_settings = {
|
||||
"verify_ssl": False,
|
||||
"stop_mode": "shutdown",
|
||||
"reboot_mode": "reboot",
|
||||
}
|
||||
|
||||
def ready(self):
|
||||
super().ready()
|
||||
# Register the per-cluster VMID uniqueness validator (post_clean).
|
||||
from . import signals # noqa: F401
|
||||
|
||||
# Ensure power-operation audit lines reach stdout (container logs) even
|
||||
# when the deployment ships the default, mostly-silent logging config.
|
||||
import logging
|
||||
import sys
|
||||
|
||||
log = logging.getLogger("proxmox_power_button")
|
||||
if not any(getattr(h, "_ppb_handler", False) for h in log.handlers):
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
handler.setFormatter(
|
||||
logging.Formatter("%(levelname)s %(asctime)s proxmox_power_button %(message)s")
|
||||
)
|
||||
handler._ppb_handler = True
|
||||
log.addHandler(handler)
|
||||
log.setLevel(logging.INFO)
|
||||
log.propagate = False
|
||||
|
||||
|
||||
config = ProxmoxPowerButtonConfig
|
||||
Reference in New Issue
Block a user