Skip to content

Commit c905ae2

Browse files
committed
Use server hostname/IP for desktop console
1 parent 659e620 commit c905ae2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/components/vm/consoles/desktopConsole.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { DesktopViewer } from '@patternfly/react-console';
2121

2222
import cockpit from "cockpit";
2323

24+
import { getConsoleAddress } from "./utils.js";
25+
2426
const _ = cockpit.gettext;
2527

2628
function fmt_to_fragments(fmt) {
@@ -37,6 +39,10 @@ function fmt_to_fragments(fmt) {
3739
}
3840

3941
const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => {
42+
if (spice)
43+
spice.address = getConsoleAddress(spice);
44+
if (vnc)
45+
vnc.address = getConsoleAddress(vnc);
4046
return (
4147
<DesktopViewer spice={spice}
4248
vnc={vnc}

test/check-machines-consoles

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class TestMachinesConsoles(VirtualMachinesCase):
3636
@skipImage('spice-server does not exist on RHEL 9', "rhel-9-1", "rhel-9-2", "rhel-9-3", "centos-9-stream")
3737
def testExternalConsole(self):
3838
b = self.browser
39+
m = self.machine
3940

4041
self.createVm("subVmTest1", graphics="spice")
4142

@@ -46,14 +47,14 @@ class TestMachinesConsoles(VirtualMachinesCase):
4647
b.wait_in_text("#vm-subVmTest1-system-state", "Running") # running or paused
4748
self.goToVmPage("subVmTest1")
4849

49-
# since VNC is not defined for this VM, the view for "Desktop Viewer" is rendered by default
50-
b.wait_in_text(".pf-c-console__manual-connection dl > div:first-child dd", "127.0.0.1")
50+
# since vnc is not defined for this vm, the view for "desktop viewer" is rendered by default
51+
b.wait_in_text(".pf-c-console__manual-connection dl > div:first-child dd", "localhost")
5152
b.wait_in_text(".pf-c-console__manual-connection dl > div:nth-child(2) dd", "5900")
5253

5354
b.click(".pf-c-console__remote-viewer-launch-vv") # "Launch Remote Viewer" button
5455
b.wait_visible("#dynamically-generated-file") # is .vv file generated for download?
5556
self.assertEqual(b.attr("#dynamically-generated-file", "href"),
56-
u"data:application/x-virt-viewer,%5Bvirt-viewer%5D%0Atype%3Dspice%0Ahost%3D127.0.0.1%0Aport%3D5900%0Adelete-this-file%3D1%0Afullscreen%3D0%0A")
57+
u"data:application/x-virt-viewer,%5Bvirt-viewer%5D%0Atype%3Dspice%0Ahost%3Dlocalhost%0Aport%3D5900%0Adelete-this-file%3D1%0Afullscreen%3D0%0A")
5758

5859
# HACK: clicking 'Launch Remote Viewer' kills execution context and thus CDP fails
5960
b.reload()
@@ -69,6 +70,12 @@ class TestMachinesConsoles(VirtualMachinesCase):
6970

7071
b.assert_pixels("#vm-subVmTest1-consoles-page", "vm-details-console-external", skip_layouts=["rtl"])
7172

73+
m.execute("echo '127.0.0.3 foodomain.org' >> /etc/hosts")
74+
m.execute("virt-xml subVmTest1 --edit --graphics listen='foodomain.org'")
75+
m.execute("virsh destroy subVmTest1; virsh start subVmTest1")
76+
77+
b.wait_in_text(".pf-c-console__manual-connection dl > div:first-child dd", "foodomain.org")
78+
7279
def testInlineConsole(self, urlroot=""):
7380
b = self.browser
7481

0 commit comments

Comments
 (0)