#!/usr/bin/python3.6 -s

import sys

import requests
import yaml

if __name__ == "__main__":
    hostname = None
    try:
        hostname = sys.argv[1]
    except:
        print("usage: cobbler-ext-nodes <hostname>")

    if hostname is not None:
        with open("/etc/cobbler/settings.yaml") as conf:
            config = yaml.safe_load(conf.read())
        url = "http://%s:%s/cblr/svc/op/puppet/hostname/%s" % (
            config["server"],
            config["http_port"],
            hostname,
        )
        print(requests.get(url))
