From e7f74d83c6d2265f8aaec60fcf103025241c4c56 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 5 May 2018 16:16:24 -0700 Subject: [PATCH] Rename VSphereConnection.GoVmomiClient -> Client --- .../providers/vsphere/nodemanager.go | 2 +- .../providers/vsphere/vclib/connection.go | 18 +++++++++--------- .../providers/vsphere/vclib/datacenter.go | 4 ++-- .../providers/vsphere/vclib/datacenter_test.go | 2 +- .../providers/vsphere/vclib/datastore_test.go | 2 +- .../providers/vsphere/vclib/folder_test.go | 2 +- .../providers/vsphere/vclib/utils_test.go | 2 +- .../vsphere/vclib/virtualmachine_test.go | 2 +- pkg/cloudprovider/providers/vsphere/vsphere.go | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/cloudprovider/providers/vsphere/nodemanager.go b/pkg/cloudprovider/providers/vsphere/nodemanager.go index 4979d605871..25f8d58c9e2 100644 --- a/pkg/cloudprovider/providers/vsphere/nodemanager.go +++ b/pkg/cloudprovider/providers/vsphere/nodemanager.go @@ -360,7 +360,7 @@ func (nm *NodeManager) renewNodeInfo(nodeInfo *NodeInfo, reconnect bool) (*NodeI return nil, err } } - vm := nodeInfo.vm.RenewVM(vsphereInstance.conn.GoVmomiClient) + vm := nodeInfo.vm.RenewVM(vsphereInstance.conn.Client) return &NodeInfo{vm: &vm, dataCenter: vm.Datacenter, vcServer: nodeInfo.vcServer}, nil } diff --git a/pkg/cloudprovider/providers/vsphere/vclib/connection.go b/pkg/cloudprovider/providers/vsphere/vclib/connection.go index 097fbd4937e..6181eba3f72 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/connection.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/connection.go @@ -30,7 +30,7 @@ import ( // VSphereConnection contains information for connecting to vCenter type VSphereConnection struct { - GoVmomiClient *vim25.Client + Client *vim25.Client Username string Password string Hostname string @@ -43,23 +43,23 @@ var ( clientLock sync.Mutex ) -// Connect makes connection to vCenter and sets VSphereConnection.GoVmomiClient. -// If connection.GoVmomiClient is already set, it obtains the existing user session. -// if user session is not valid, connection.GoVmomiClient will be set to the new client. +// Connect makes connection to vCenter and sets VSphereConnection.Client. +// If connection.Client is already set, it obtains the existing user session. +// if user session is not valid, connection.Client will be set to the new client. func (connection *VSphereConnection) Connect(ctx context.Context) error { var err error clientLock.Lock() defer clientLock.Unlock() - if connection.GoVmomiClient == nil { - connection.GoVmomiClient, err = connection.NewClient(ctx) + if connection.Client == nil { + connection.Client, err = connection.NewClient(ctx) if err != nil { glog.Errorf("Failed to create govmomi client. err: %+v", err) return err } return nil } - m := session.NewManager(connection.GoVmomiClient) + m := session.NewManager(connection.Client) userSession, err := m.UserSession(ctx) if err != nil { glog.Errorf("Error while obtaining user session. err: %+v", err) @@ -70,7 +70,7 @@ func (connection *VSphereConnection) Connect(ctx context.Context) error { } glog.Warningf("Creating new client session since the existing session is not valid or not authenticated") - connection.GoVmomiClient, err = connection.NewClient(ctx) + connection.Client, err = connection.NewClient(ctx) if err != nil { glog.Errorf("Failed to create govmomi client. err: %+v", err) return err @@ -80,7 +80,7 @@ func (connection *VSphereConnection) Connect(ctx context.Context) error { // Logout calls SessionManager.Logout for the given connection. func (connection *VSphereConnection) Logout(ctx context.Context) { - m := session.NewManager(connection.GoVmomiClient) + m := session.NewManager(connection.Client) if err := m.Logout(ctx); err != nil { glog.Errorf("Logout failed: %s", err) } diff --git a/pkg/cloudprovider/providers/vsphere/vclib/datacenter.go b/pkg/cloudprovider/providers/vsphere/vclib/datacenter.go index 2c744116e9a..d60448d1ccf 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/datacenter.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/datacenter.go @@ -39,7 +39,7 @@ type Datacenter struct { // GetDatacenter returns the DataCenter Object for the given datacenterPath // If datacenter is located in a folder, include full path to datacenter else just provide the datacenter name func GetDatacenter(ctx context.Context, connection *VSphereConnection, datacenterPath string) (*Datacenter, error) { - finder := find.NewFinder(connection.GoVmomiClient, false) + finder := find.NewFinder(connection.Client, false) datacenter, err := finder.Datacenter(ctx, datacenterPath) if err != nil { glog.Errorf("Failed to find the datacenter: %s. err: %+v", datacenterPath, err) @@ -52,7 +52,7 @@ func GetDatacenter(ctx context.Context, connection *VSphereConnection, datacente // GetAllDatacenter returns all the DataCenter Objects func GetAllDatacenter(ctx context.Context, connection *VSphereConnection) ([]*Datacenter, error) { var dc []*Datacenter - finder := find.NewFinder(connection.GoVmomiClient, false) + finder := find.NewFinder(connection.Client, false) datacenters, err := finder.DatacenterList(ctx, "*") if err != nil { glog.Errorf("Failed to find the datacenter. err: %+v", err) diff --git a/pkg/cloudprovider/providers/vsphere/vclib/datacenter_test.go b/pkg/cloudprovider/providers/vsphere/vclib/datacenter_test.go index 65b70a76b24..95c89b70112 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/datacenter_test.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/datacenter_test.go @@ -47,7 +47,7 @@ func TestDatacenter(t *testing.T) { t.Fatal(err) } - vc := &VSphereConnection{GoVmomiClient: c.Client} + vc := &VSphereConnection{Client: c.Client} _, err = GetDatacenter(ctx, vc, testNameNotFound) if err == nil { diff --git a/pkg/cloudprovider/providers/vsphere/vclib/datastore_test.go b/pkg/cloudprovider/providers/vsphere/vclib/datastore_test.go index 3ecd99c0a1a..7e9b2b7367b 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/datastore_test.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/datastore_test.go @@ -45,7 +45,7 @@ func TestDatastore(t *testing.T) { t.Fatal(err) } - vc := &VSphereConnection{GoVmomiClient: c.Client} + vc := &VSphereConnection{Client: c.Client} dc, err := GetDatacenter(ctx, vc, testDefaultDatacenter) if err != nil { diff --git a/pkg/cloudprovider/providers/vsphere/vclib/folder_test.go b/pkg/cloudprovider/providers/vsphere/vclib/folder_test.go index b83ea7f0da5..a8b39a8671e 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/folder_test.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/folder_test.go @@ -47,7 +47,7 @@ func TestFolder(t *testing.T) { t.Fatal(err) } - vc := &VSphereConnection{GoVmomiClient: c.Client} + vc := &VSphereConnection{Client: c.Client} dc, err := GetDatacenter(ctx, vc, testDefaultDatacenter) if err != nil { diff --git a/pkg/cloudprovider/providers/vsphere/vclib/utils_test.go b/pkg/cloudprovider/providers/vsphere/vclib/utils_test.go index 786da2f1a33..df4bba3a341 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/utils_test.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/utils_test.go @@ -46,7 +46,7 @@ func TestUtils(t *testing.T) { t.Fatal(err) } - vc := &VSphereConnection{GoVmomiClient: c.Client} + vc := &VSphereConnection{Client: c.Client} dc, err := GetDatacenter(ctx, vc, testDefaultDatacenter) if err != nil { diff --git a/pkg/cloudprovider/providers/vsphere/vclib/virtualmachine_test.go b/pkg/cloudprovider/providers/vsphere/vclib/virtualmachine_test.go index 35b7c5a51e9..c366c396146 100644 --- a/pkg/cloudprovider/providers/vsphere/vclib/virtualmachine_test.go +++ b/pkg/cloudprovider/providers/vsphere/vclib/virtualmachine_test.go @@ -43,7 +43,7 @@ func TestVirtualMachine(t *testing.T) { t.Fatal(err) } - vc := &VSphereConnection{GoVmomiClient: c.Client} + vc := &VSphereConnection{Client: c.Client} dc, err := GetDatacenter(ctx, vc, testDefaultDatacenter) if err != nil { diff --git a/pkg/cloudprovider/providers/vsphere/vsphere.go b/pkg/cloudprovider/providers/vsphere/vsphere.go index 87a08234ea3..14ecfed732c 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere.go @@ -410,7 +410,7 @@ func newControllerNode(cfg VSphereConfig) (*VSphere, error) { func logout(vs *VSphere) { for _, vsphereIns := range vs.vsphereInstanceMap { - if vsphereIns.conn.GoVmomiClient != nil { + if vsphereIns.conn.Client != nil { vsphereIns.conn.Logout(context.TODO()) } }