Skip to content
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

Add Websocket endpoint to access VM consoles #162

Merged
merged 4 commits into from
Mar 30, 2017
Merged

Conversation

rmohr
Copy link
Member

@rmohr rmohr commented Mar 22, 2017

virt-handler now has an '/api/v1/console/myvm' endpoint, which also takes
a 'device' header, to specify the console to connect to.

"kubevirt.io/kubevirt/pkg/virt-handler/virtwrap"
virtcache "kubevirt.io/kubevirt/pkg/virt-handler/virtwrap/cache"
"net/http"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builtin libs should be in first section

@@ -28,6 +31,8 @@ func main() {
libvirtUri := flag.String("libvirt-uri", "qemu:///system", "Libvirt connection string.")
libvirtUser := flag.String("user", "", "Libvirt user")
libvirtPass := flag.String("pass", "", "Libvirt password")
listen := flag.String("listen", "0.0.0.0", "Address and port where to listen on")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the address, right? Help text says "and port"

"github.com/emicklei/go-restful"
"github.com/gorilla/websocket"
"github.com/libvirt/libvirt-go"
"io"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort imports

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is alphabetical order

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a space between the go standard ones like io and the github ones, and the tooling will sort them within the groups. That does not have to be in this patch.

domain, err := t.connection.LookupDomainByName(vm)
if err != nil {
if err.(libvirt.Error).Code == libvirt.ERR_NO_DOMAIN {
logging.DefaultLogger().Error().Reason(err).Msg("Domain not found.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have easy access to the domain to communicate in the logs? (also goes for line 39)

err = <-errorChan

if err != nil {
logging.DefaultLogger().Error().Reason(err).Msg("I")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message is "I"... Is this a placeholder?

@rmohr rmohr changed the title [WIP] Add Websocket endpoint to access VM consoles Add Websocket endpoint to access VM consoles Mar 27, 2017
@rmohr
Copy link
Member Author

rmohr commented Mar 27, 2017

retest this please

@rmohr rmohr requested a review from admiyo March 28, 2017 09:10
virt-handler now has an '/api/v1/console/myvm' endpoint, which also takes
a 'device' header, to specify the console to connect to.
Like with all other libvirt interactions, allow mocking out contact
points with libvirt.
@rmohr
Copy link
Member Author

rmohr commented Mar 30, 2017

@admiyo @stu-gott ping

When using CNI hostPort, alone does not allow binding the container to
all interfaces. if that works, depends on the CNI provider. When using
the host network int works.
Copy link
Contributor

@admiyo admiyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor questions, but nothing tha should hold up merging.

"github.com/emicklei/go-restful"
"github.com/gorilla/websocket"
"github.com/libvirt/libvirt-go"
"io"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a space between the go standard ones like io and the github ones, and the tooling will sort them within the groups. That does not have to be in this patch.

t, body, err := con.ReadMessage()
Expect(t).To(Equal(websocket.TextMessage))
Expect(err).ToNot(HaveOccurred())
Expect(body).To(Equal([]byte("hello client!")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this "client" and not "console" as was written on line 134?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client sends "hello console" and the console writes "hello client!". Line 124

@rmohr
Copy link
Member Author

rmohr commented Mar 30, 2017

@admiyo thx for the review

@rmohr rmohr merged commit 3725eee into kubevirt:master Mar 30, 2017
kubevirt-bot pushed a commit to kubevirt-bot/kubevirt that referenced this pull request Dec 7, 2021
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants