vSphere Cloud Provider: update vmware/gomvomi godeps

This commit is contained in:
Doug MacEachern
2018-05-14 14:09:20 -07:00
parent 83768d286c
commit c340f6f9a4
55 changed files with 8733 additions and 596 deletions

View File

@@ -18,6 +18,7 @@ package session
import (
"context"
"net/http"
"net/url"
"os"
@@ -89,14 +90,51 @@ func (sm *Manager) Login(ctx context.Context, u *url.Userinfo) error {
return nil
}
func (sm *Manager) LoginExtensionByCertificate(ctx context.Context, key string, locale string) error {
// LoginExtensionByCertificate uses the vCenter SDK tunnel to login using a client certificate.
// The client certificate can be set using the soap.Client.SetCertificate method.
// See: https://kb.vmware.com/s/article/2004305
func (sm *Manager) LoginExtensionByCertificate(ctx context.Context, key string) error {
c := sm.client
u := c.URL()
if u.Hostname() != "sdkTunnel" {
sc := c.Tunnel()
c = &vim25.Client{
Client: sc,
RoundTripper: sc,
ServiceContent: c.ServiceContent,
}
// When http.Transport.Proxy is used, our thumbprint checker is bypassed, resulting in:
// "Post https://sdkTunnel:8089/sdk: x509: certificate is valid for $vcenter_hostname, not sdkTunnel"
// The only easy way around this is to disable verification for the call to LoginExtensionByCertificate().
// TODO: find a way to avoid disabling InsecureSkipVerify.
c.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify = true
}
req := types.LoginExtensionByCertificate{
This: sm.Reference(),
ExtensionKey: key,
Locale: locale,
Locale: Locale,
}
login, err := methods.LoginExtensionByCertificate(ctx, sm.client, &req)
login, err := methods.LoginExtensionByCertificate(ctx, c, &req)
if err != nil {
return err
}
// Copy the session cookie
sm.client.Jar.SetCookies(u, c.Jar.Cookies(c.URL()))
sm.userSession = &login.Returnval
return nil
}
func (sm *Manager) LoginByToken(ctx context.Context) error {
req := types.LoginByToken{
This: sm.Reference(),
Locale: Locale,
}
login, err := methods.LoginByToken(ctx, sm.client, &req)
if err != nil {
return err
}