24 lines
345 B
Go
Executable File
24 lines
345 B
Go
Executable File
package vmomi
|
|
|
|
import (
|
|
"context"
|
|
url2 "net/url"
|
|
|
|
"github.com/vmware/govmomi"
|
|
)
|
|
|
|
func Connect(url, user, password string) (*govmomi.Client, error) {
|
|
esxiUri, err := url2.Parse(url)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
esxiUri.User = url2.UserPassword(user, password)
|
|
|
|
return govmomi.NewClient(
|
|
context.Background(),
|
|
esxiUri,
|
|
true,
|
|
)
|
|
}
|