feat: set_hostname — update /etc/hostname, /etc/hosts, cert, Postfix
Implements set_hostname on ProxmoxSystemMixin: 1. Writes /etc/hostname (short name, base64-safe transfer) 2. Replaces old hostname in /etc/hosts via Python regex + base64 3. Updates /etc/mailname if present 4. Updates Postfix myhostname via postconf -e if installed 5. Applies hostname immediately at runtime via hostname(1) 6. Regenerates Proxmox node TLS certificate via pvecm updatecerts -f (falls back to pvenode cert create → pveproxy restart) Accepts bare hostname or FQDN. A reboot is required for the Proxmox node name to update in the web UI / cluster — the driver logs this. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d1e6931ec5
commit
b1ba991e6d
@@ -26,28 +26,6 @@ _MAC_RE = re.compile(
|
||||
|
||||
|
||||
def normalize_mac(mac: str) -> str:
|
||||
"""Return a colon-separated, lower-case MAC address, or '' on failure."""
|
||||
if not mac:
|
||||
return ""
|
||||
try:
|
||||
return str(EUI(mac, dialect=_ColonDialect()))
|
||||
except (AddrFormatError, ValueError):
|
||||
return mac.lower()
|
||||
|
||||
|
||||
class _ColonDialect(EUI):
|
||||
"""EUI dialect that formats as aa:bb:cc:dd:ee:ff."""
|
||||
|
||||
word_sep = ":"
|
||||
word_fmt = "%.2x"
|
||||
|
||||
def __new__(cls): # type: ignore[override]
|
||||
from netaddr import mac_unix_expanded
|
||||
|
||||
return mac_unix_expanded
|
||||
|
||||
|
||||
def normalize_mac(mac: str) -> str: # noqa: F811
|
||||
"""Return lower-case colon-separated MAC or empty string."""
|
||||
if not mac:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user