Skip to content

Commit

Permalink
Use server hostname/IP for desktop console
Browse files Browse the repository at this point in the history
  • Loading branch information
skobyda committed May 23, 2023
1 parent 659e620 commit c905ae2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/components/vm/consoles/desktopConsole.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { DesktopViewer } from '@patternfly/react-console';

import cockpit from "cockpit";

import { getConsoleAddress } from "./utils.js";

const _ = cockpit.gettext;

function fmt_to_fragments(fmt) {
Expand All @@ -37,6 +39,10 @@ function fmt_to_fragments(fmt) {
}

const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => {
if (spice)
spice.address = getConsoleAddress(spice);
if (vnc)
vnc.address = getConsoleAddress(vnc);
return (
<DesktopViewer spice={spice}
vnc={vnc}
Expand Down
13 changes: 10 additions & 3 deletions test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class TestMachinesConsoles(VirtualMachinesCase):
@skipImage('spice-server does not exist on RHEL 9', "rhel-9-1", "rhel-9-2", "rhel-9-3", "centos-9-stream")
def testExternalConsole(self):
b = self.browser
m = self.machine

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

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

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

b.click(".pf-c-console__remote-viewer-launch-vv") # "Launch Remote Viewer" button
b.wait_visible("#dynamically-generated-file") # is .vv file generated for download?
self.assertEqual(b.attr("#dynamically-generated-file", "href"),
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")
u"data:application/x-virt-viewer,%5Bvirt-viewer%5D%0Atype%3Dspice%0Ahost%3Dlocalhost%0Aport%3D5900%0Adelete-this-file%3D1%0Afullscreen%3D0%0A")

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

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

m.execute("echo '127.0.0.3 foodomain.org' >> /etc/hosts")
m.execute("virt-xml subVmTest1 --edit --graphics listen='foodomain.org'")
m.execute("virsh destroy subVmTest1; virsh start subVmTest1")

b.wait_in_text(".pf-c-console__manual-connection dl > div:first-child dd", "foodomain.org")

def testInlineConsole(self, urlroot=""):
b = self.browser

Expand Down

0 comments on commit c905ae2

Please sign in to comment.