-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show helper to set up SSH tunnel for Desktop Viewer #1084
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,12 @@ | |
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import React from "react"; | ||
import { CodeBlock, CodeBlockCode } from "@patternfly/react-core/dist/esm/components/CodeBlock"; | ||
import { DesktopViewer } from '@patternfly/react-console'; | ||
|
||
import { getServerAddress, needsTunnel } from "./utils.js"; | ||
import cockpit from "cockpit"; | ||
import store from './../../../store.js'; | ||
|
||
const _ = cockpit.gettext; | ||
|
||
|
@@ -37,6 +40,11 @@ function fmt_to_fragments(fmt) { | |
} | ||
|
||
const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => { | ||
// DesktopViewer prefers spice over vnc | ||
const address = (spice && spice.address) || (vnc && vnc.address); | ||
const serverAddress = getServerAddress(); | ||
const loggedUser = store.getState().systemInfo.loggedUser; | ||
|
||
return ( | ||
<DesktopViewer spice={spice} | ||
vnc={vnc} | ||
|
@@ -57,6 +65,12 @@ const DesktopConsoleDownload = ({ vnc, spice, onDesktopConsole }) => { | |
<p> | ||
{fmt_to_fragments(_("Clicking \"Launch remote viewer\" will download a .vv file and launch $0."), <i>Remote Viewer</i>)} | ||
</p> | ||
{needsTunnel(address, serverAddress) && <p> | ||
{_("SSH tunnel needs to be set up on client:")} | ||
<CodeBlock> | ||
<CodeBlockCode>{`ssh -L 5900:localhost:5900 -N ${loggedUser.name}@${serverAddress}`}</CodeBlockCode> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually really nice! Even if the serverAddress is slightly incorrect (due to reverse proxy and such), it will at least give admins an idea what needs to happen. Same for the local port -- it might be busy, and this doesn't work if you run this for more than one VM (you need to pick a different local port then), but this is meant as a guideline. However, is it always 5900 on the remote side? Are VNC and spice using the same port? Can we ask libvirt about the port? |
||
</CodeBlock> | ||
</p>} | ||
<p> | ||
{fmt_to_fragments(_("$0 is available for most operating systems. To install it, search for it in GNOME Software or run the following:"), <i>Remote Viewer</i>)} | ||
</p> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,8 @@ class TestMachinesConsoles(VirtualMachinesCase): | |
b.wait_in_text('.pf-c-expandable-section__content', | ||
'Clicking "Launch remote viewer" will download') | ||
|
||
b.wait_not_in_text('.pf-c-expandable-section__content', 'SSH tunnel needs to be set up on client') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a positive test case, too. You already asked about this, just opening a thread to track it. |
||
|
||
b.assert_pixels("#vm-subVmTest1-consoles-page", "vm-details-console-external", skip_layouts=["rtl"]) | ||
|
||
def testInlineConsole(self, urlroot=""): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spice?.address || vnc?.address