Skip to content

Commit

Permalink
console enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Oct 10, 2019
1 parent bfd1b86 commit 128f646
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kvirt/kvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,16 +1018,13 @@ def console(self, name, tunnel=False, web=False):
else:
xml = vm.XMLDesc(0)
root = ET.fromstring(xml)
host = self.host
for element in list(root.getiterator('graphics')):
attributes = element.attrib
if attributes['listen'] == '127.0.0.1':
if not os.path.exists("i_am_a_container"):
tunnel = True
elif self.host not in ['127.0.0.1', 'localhost']:
if not os.path.exists("i_am_a_container") or self.host not in ['127.0.0.1', 'localhost']:
tunnel = True
host = '127.0.0.1'
else:
host = self.host
protocol = attributes['type']
port = attributes['port']
localport = port
Expand Down Expand Up @@ -1073,7 +1070,12 @@ def serialconsole(self, name):
print("No serial Console found. Leaving...")
return
elif self.host in ['localhost', '127.0.0.1']:
os.system('virsh -c %s console %s' % (self.url, name))
cmd = 'virsh -c %s console %s' % (self.url, name)
if self.debug or os.path.exists("/i_am_a_container"):
msg = "Run the following command:\n%s" % cmd
common.pprint(msg)
else:
os.system(cmd)
else:
for element in serial:
serialport = element.find('source').get('service')
Expand Down

0 comments on commit 128f646

Please sign in to comment.