Rename VSphereConnection.GoVmomiClient -> Client

pull/8/head
Doug MacEachern 2018-05-05 16:16:24 -07:00
parent 64601373f1
commit e7f74d83c6
9 changed files with 18 additions and 18 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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())
}
}