Created
April 9, 2025 14:01
-
-
Save grafuls/49ac6e9958da66c0ef749a103ef37594 to your computer and use it in GitHub Desktop.
Quads hostname2meta converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import re | |
from quads.quads_api import QuadsApi | |
from quads.config import Config | |
quads = QuadsApi(Config) | |
hosts = quads.get_hosts() | |
pattern = r"^(?P<rack>[^-]+)-(?P<uloc>[^-]+)-(?P<blade>[^-]+)-(?P<host_type>[^.]+)\.(?P<domain>.+)$" | |
for host in hosts: | |
match = re.match(pattern, host.name) | |
if match: | |
components = match.groupdict() | |
rack = components["rack"] | |
uloc = components["uloc"] | |
blade = components["blade"] | |
#print(f"{host.name}: rack {rack}, uloc {uloc}, blade {blade}") | |
quads.update_host(host.name, {"rack":rack, "uloc":uloc, "blade":blade}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment