diff --git a/provisioning/mac.py b/provisioning/mac.py new file mode 100644 index 0000000..e4e2dc4 --- /dev/null +++ b/provisioning/mac.py @@ -0,0 +1,40 @@ +import libvirt +import xml.etree.ElementTree as ET + +def get_mac_address(domain): + + try: + # Connect to the libvirt daemon + conn = libvirt.open() + if conn is None: + raise RuntimeError("Failed to open connection to the hypervisor.") + + # Lookup the domain by name + vm = conn.lookupByName(domain) + if vm is None: + raise ValueError(f"Domain '{domain}' not found.") + + # Get the XML description of the domain + xml_desc = vm.XMLDesc() + + # Parse the XML to extract the MAC address + root = ET.fromstring(xml_desc) + mac_element = root.find(".//mac") + if mac_element is not None: + mac_address = mac_element.attrib.get('address') + return mac_address + else: + raise ValueError("MAC address not found in XML.") + + except libvirt.libvirtError as e: + return f"A libvirt error occurred: {e}" + except Exception as e: + return f"An error occurred: {e}" + finally: + if conn: + conn.close() + +# Replace 'debian' with your domain name +domain_name = "debian" +mac_address = get_mac_address(domain_name) +print(f"MAC Address: {mac_address}") diff --git a/provisioning/master.py b/provisioning/master.py new file mode 100644 index 0000000..7bd04a9 --- /dev/null +++ b/provisioning/master.py @@ -0,0 +1,26 @@ +# get new domain name + +# create a VM and clone disk + +# set CPU & RAM + +# get mac +virsh_vm.get_mac(domain) + +# change network +network.set_ip_for_mac_domain(domain, mac) + +# net destory net start ? + +# start vm + +# change hostname + +# add vm subdomains + +# run python script + +# run cert script + +# reload nginx +