Compare commits
No commits in common. "bf2383458522c8489b2f916a1f9ebaf8a93bc15d" and "15a804e80947f3ffd3284f6640056fdc7abe9724" have entirely different histories.
bf23834585
...
15a804e809
@ -1,79 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
import os
|
|
||||||
import xml.etree.ElementTree as xmlet
|
|
||||||
import pandas
|
|
||||||
import math
|
|
||||||
|
|
||||||
outfile = 'xxx.csv'
|
|
||||||
|
|
||||||
columns = [ "name", "status", "role", "cluster", "tenant", "platform", "vcpus", "memory", "disk", "comments" ]
|
|
||||||
rows = []
|
|
||||||
|
|
||||||
domaindir = 'xmls/domains'
|
|
||||||
diskdir = 'xmls/disks'
|
|
||||||
|
|
||||||
status = 'Active'
|
|
||||||
cluster = 'xxx'
|
|
||||||
tenant = 'xxx'
|
|
||||||
comment = 'Imported from libvirt. Manual verification pending.'
|
|
||||||
|
|
||||||
for domainxml in os.listdir(domaindir):
|
|
||||||
domainparse = xmlet.parse(domaindir + "/" + domainxml)
|
|
||||||
domainroot = domainparse.getroot()
|
|
||||||
|
|
||||||
name = domainroot.find("name").text
|
|
||||||
vcpus = domainroot.find("vcpu").text
|
|
||||||
memory = int(domainroot.find("memory").text)
|
|
||||||
memorysize = round(memory*0.001024)
|
|
||||||
diskxml = diskdir + "/" + name + ".disk.export.xml"
|
|
||||||
diskparse = xmlet.parse(diskxml)
|
|
||||||
diskroot = diskparse.getroot()
|
|
||||||
diskcapacity = int(diskroot.find("capacity").text)
|
|
||||||
disksize = round(diskcapacity / (math.pow(1024, (int(math.floor(math.log(diskcapacity, 1024)))))))
|
|
||||||
|
|
||||||
while True:
|
|
||||||
role_choice = input ("Assign a role for " + name + ":\n1) Internal Client\n2) Internal Server\n3) ???\n4) ???\n> ")
|
|
||||||
if role_choice == "1":
|
|
||||||
role = "Virtual Machine (Internal, Client)"
|
|
||||||
break
|
|
||||||
if role_choice == "2":
|
|
||||||
role = "Virtual Machine (Internal, Server)"
|
|
||||||
break
|
|
||||||
if role_choice == "3":
|
|
||||||
role = "Virtual Machine (Customer)"
|
|
||||||
break
|
|
||||||
if role_choice not in ["1", "2", "3"]:
|
|
||||||
print("Invalid choice.")
|
|
||||||
|
|
||||||
while True:
|
|
||||||
platform_choice = input ("Assign platform for " + name + ":\n 1) openSUSE-x86_64\n2)OpenBSD-x86_64\n3)FreeBSD-x86_64\n> ")
|
|
||||||
if platform_choice == "1":
|
|
||||||
platform = "openSUSE-x86_64"
|
|
||||||
break
|
|
||||||
if platform_choice == "2":
|
|
||||||
platform = "OpenBSD-x86_64"
|
|
||||||
break
|
|
||||||
if platform_choice == "3":
|
|
||||||
platform = "FreeBSD-x86_64"
|
|
||||||
break
|
|
||||||
if platform_choice not in ["1", "2", "3"]:
|
|
||||||
print("Invalid choice.")
|
|
||||||
|
|
||||||
rows.append(
|
|
||||||
{
|
|
||||||
"name": name,
|
|
||||||
"status": status,
|
|
||||||
"role": role,
|
|
||||||
"cluster": cluster,
|
|
||||||
"tenant": tenant,
|
|
||||||
"platform": platform,
|
|
||||||
"vcpus": vcpus,
|
|
||||||
"memory": memorysize,
|
|
||||||
"disk": disksize,
|
|
||||||
"comments": comment
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
convert = pandas.DataFrame(rows, columns=columns)
|
|
||||||
convert.to_csv(outfile, index=False)
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user