Adding OWNERS file for vSphere cloud-provider package

also updating license file for Govmomi library
This commit is contained in:
dagnello
2016-04-26 14:12:53 -07:00
parent 4fd02f54ef
commit f7b3cf39d6
350 changed files with 241 additions and 31 deletions

View File

@@ -0,0 +1,4 @@
maintainers:
- dagnello
- abithap

View File

@@ -21,8 +21,8 @@ import (
"errors"
"fmt"
"io"
"os/exec"
"net/url"
"os/exec"
"strings"
"github.com/vmware/govmomi"
@@ -51,13 +51,13 @@ type VSphere struct {
type VSphereConfig struct {
Global struct {
User string `gcfg:"user"`
Password string `gcfg:"password"`
VCenterIP string `gcfg:"server"`
VCenterPort string `gcfg:"port"`
InsecureFlag bool `gcfg:"insecure-flag"`
Datacenter string `gcfg:"datacenter"`
Datastore string `gcfg:"datastore"`
User string `gcfg:"user"`
Password string `gcfg:"password"`
VCenterIP string `gcfg:"server"`
VCenterPort string `gcfg:"port"`
InsecureFlag bool `gcfg:"insecure-flag"`
Datacenter string `gcfg:"datacenter"`
Datastore string `gcfg:"datastore"`
}
Network struct {
@@ -89,7 +89,7 @@ func init() {
func readInstanceID(cfg *VSphereConfig) (string, error) {
cmd := exec.Command("bash", "-c", `dmidecode -t 1 | grep UUID | tr -d ' ' | cut -f 2 -d ':'`)
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return "", err
@@ -134,7 +134,7 @@ func newVSphere(cfg VSphereConfig) (*VSphere, error) {
}
vs := VSphere{
cfg: &cfg,
cfg: &cfg,
localInstanceID: id,
}
return &vs, nil
@@ -159,7 +159,7 @@ func vsphereLogin(cfg *VSphereConfig, ctx context.Context) (*govmomi.Client, err
return c, nil
}
func getVirtualMachineByName(cfg *VSphereConfig, ctx context.Context, c *govmomi.Client, name string) (*object.VirtualMachine, error){
func getVirtualMachineByName(cfg *VSphereConfig, ctx context.Context, c *govmomi.Client, name string) (*object.VirtualMachine, error) {
// Create a new finder
f := find.NewFinder(c.Client, true)
@@ -180,12 +180,12 @@ func getVirtualMachineByName(cfg *VSphereConfig, ctx context.Context, c *govmomi
return vm, nil
}
func getVirtualMachineManagedObjectReference(ctx context.Context, c *govmomi.Client, vm *object.VirtualMachine, field string, dst interface{}) error{
func getVirtualMachineManagedObjectReference(ctx context.Context, c *govmomi.Client, vm *object.VirtualMachine, field string, dst interface{}) error {
collector := property.DefaultCollector(c.Client)
// Retrieve required field from VM object
err := collector.RetrieveOne(ctx, vm.Reference(), []string{field}, dst);
if err !=nil {
err := collector.RetrieveOne(ctx, vm.Reference(), []string{field}, dst)
if err != nil {
return err
}
return nil
@@ -231,7 +231,7 @@ func getInstances(cfg *VSphereConfig, ctx context.Context, c *govmomi.Client, fi
}
type Instances struct {
cfg *VSphereConfig
cfg *VSphereConfig
localInstanceID string
}
@@ -277,13 +277,13 @@ func (i *Instances) NodeAddresses(name string) ([]api.NodeAddress, error) {
defer c.Logout(ctx)
vm, err := getVirtualMachineByName(i.cfg, ctx, c, name)
if err !=nil {
if err != nil {
return nil, err
}
var mvm mo.VirtualMachine
err = getVirtualMachineManagedObjectReference(ctx, c, vm, "guest.net", &mvm)
if err !=nil {
if err != nil {
return nil, err
}
@@ -335,18 +335,18 @@ func (i *Instances) ExternalID(name string) (string, error) {
var mvm mo.VirtualMachine
err = getVirtualMachineManagedObjectReference(ctx, c, vm, "summary", &mvm)
if err !=nil {
if err != nil {
return "", err
}
if mvm.Summary.Runtime.PowerState == ActivePowerState {
return vm.InventoryPath, nil
}
}
if mvm.Summary.Config.Template == false {
glog.Warningf("VM %s, is not in %s state", name, ActivePowerState)
glog.Warningf("VM %s, is not in %s state", name, ActivePowerState)
} else {
glog.Warningf("VM %s, is a template", name)
glog.Warningf("VM %s, is a template", name)
}
return "", cloudprovider.InstanceNotFound
@@ -369,18 +369,18 @@ func (i *Instances) InstanceID(name string) (string, error) {
var mvm mo.VirtualMachine
err = getVirtualMachineManagedObjectReference(ctx, c, vm, "summary", &mvm)
if err !=nil {
if err != nil {
return "", err
}
if mvm.Summary.Runtime.PowerState == ActivePowerState {
return "/" + vm.InventoryPath, nil
}
if mvm.Summary.Config.Template == false {
glog.Warning("VM %s, is not in %s state", name, ActivePowerState)
glog.Warning("VM %s, is not in %s state", name, ActivePowerState)
} else {
glog.Warning("VM %s, is a template", name)
glog.Warning("VM %s, is a template", name)
}
return "", cloudprovider.InstanceNotFound
@@ -406,13 +406,13 @@ func (vs *VSphere) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
// Zones returns an implementation of Zones for Google vSphere.
func (vs *VSphere) Zones() (cloudprovider.Zones, bool) {
glog.V(1).Info("Claiming to support Zones")
glog.V(4).Info("Claiming to support Zones")
return vs, true
}
func (vs *VSphere) GetZone() (cloudprovider.Zone, error) {
glog.V(1).Infof("Current zone is %v", vs.cfg.Global.Datacenter)
glog.V(4).Infof("Current zone is %v", vs.cfg.Global.Datacenter)
return cloudprovider.Zone{Region: vs.cfg.Global.Datacenter}, nil
}

View File

@@ -124,9 +124,8 @@ func TestZones(t *testing.T) {
cfg.Global.Datacenter = "myDatacenter"
// Create vSphere configuration object
vs, err := newVSphere(cfg)
if err != nil {
t.Fatalf("Failed to construct/authenticate vSphere: %s", err)
vs := VSphere{
cfg: &cfg,
}
z, ok := vs.Zones()