Merge pull request #15 from ebrainte/master

Replace conn master host > instance host
This commit is contained in:
Dom Del Nano 2021-03-16 19:40:13 -07:00 committed by GitHub
commit 20da456f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,9 +72,10 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
ui.Error(err.Error())
return multistep.ActionHalt
}
ui.Say("Connecting to the VM console VNC over xapi")
conn, err := net.Dial("tcp", fmt.Sprintf("%s:443", config.HostIp))
locationPieces := strings.SplitAfter(location, "/")
consoleHost := strings.TrimSuffix(locationPieces[2], "/")
ui.Say(fmt.Sprintf("Connecting to the VM console VNC over xapi via %s", consoleHost))
conn, err := net.Dial("tcp", fmt.Sprintf("%s:443", consoleHost))
if err != nil {
err := fmt.Errorf("Error connecting to VNC: %s", err)
@ -90,9 +91,8 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
}
tlsConn := tls.Client(conn, tlsConfig)
locationPieces := strings.SplitAfter(location, "/")
consoleLocation := strings.TrimSpace(fmt.Sprintf("/%s", locationPieces[len(locationPieces)-1]))
httpReq := fmt.Sprintf("CONNECT %s HTTP/1.0\r\nCookie: session_id=%s\r\n\r\n", consoleLocation, c.session)
httpReq := fmt.Sprintf("CONNECT %s HTTP/1.0\r\nHost: %s\r\nCookie: session_id=%s\r\n\r\n", consoleLocation, consoleHost, c.session)
fmt.Printf("Sending the follow http req: %v", httpReq)
ui.Say(fmt.Sprintf("Making HTTP request to initiate VNC connection: %s", httpReq))