Skip to content
This repository has been archived by the owner on Apr 7, 2018. It is now read-only.

add vnc-port info #32

Merged
merged 1 commit into from
Jul 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/info/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def get_domain_XML(self, name):
domain = self.connection.lookupByName(name)
return minidom.parseString(domain.XMLDesc(0))

# Domain list
def get_domain_list(self):
# Get stopped domain list
domain_list = self.connection.listDefinedDomains()
Expand Down Expand Up @@ -118,16 +119,24 @@ def get_domain_info_all(self):

# Read XML file
domain_XML = self.get_domain_XML(name)
networks = []
# Show interface's information

vnc_ports = []
# Get vnc ports
for port in domain_XML.getElementsByTagName("graphics"):
if port.getAttribute("type") == "vnc":
vnc_ports.append(port.getAttribute("port"))
dom_info.update({"vncports": vnc_ports})

networks = []
# Get interface's information
for iface in domain_XML.getElementsByTagName("interface"):
networks.append(self.get_domain_network_info(iface))
dom_info.update({"networks": networks})
domain.append(dom_info)

return {"interfaces": domain}

# One information
# <name>'s information
def get_domain_info(self, name):
dom_info = {"name": name}
dom_info.update(self.get_domain(name))
Expand All @@ -138,8 +147,17 @@ def get_domain_info(self, name):

# Read XML file
domain_XML = self.get_domain_XML(name)
print(domain_XML.getElementsByTagName("graphics")[0].getAttribute("port"))

# Get vnc ports
vnc_ports = []
for port in domain_XML.getElementsByTagName("graphics"):
if port.getAttribute("type") == "vnc":
vnc_ports.append(port.getAttribute("port"))
dom_info.update({"vncports": vnc_ports})

# Get interface's information
networks = []
# Show interface's information
for iface in domain_XML.getElementsByTagName("interface"):
networks.append(self.get_domain_network_info(iface))
dom_info.update({"networks": networks})
Expand All @@ -156,6 +174,7 @@ def get_domain_network_info(self, iface):

return network_info

# check vm's existance
def vmname_exists(self, name):
try:
self.connection.lookupByName(name)
Expand Down