Skip to content

Commit

Permalink
Adding OWNERS file for vSphere cloud-provider package
Browse files Browse the repository at this point in the history
also updating license file for Govmomi library
  • Loading branch information
dagnello committed May 9, 2016
1 parent 4fd02f5 commit f7b3cf3
Show file tree
Hide file tree
Showing 350 changed files with 241 additions and 31 deletions.
207 changes: 207 additions & 0 deletions Godeps/LICENSES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/cloudprovider/providers/vsphere/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
maintainers:
- dagnello
- abithap

56 changes: 28 additions & 28 deletions pkg/cloudprovider/providers/vsphere/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"errors"
"fmt"
"io"
"os/exec"
"net/url"
"os/exec"
"strings"

"github.com/vmware/govmomi"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -134,7 +134,7 @@ func newVSphere(cfg VSphereConfig) (*VSphere, error) {
}

vs := VSphere{
cfg: &cfg,
cfg: &cfg,
localInstanceID: id,
}
return &vs, nil
Expand All @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -231,7 +231,7 @@ func getInstances(cfg *VSphereConfig, ctx context.Context, c *govmomi.Client, fi
}

type Instances struct {
cfg *VSphereConfig
cfg *VSphereConfig
localInstanceID string
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/cloudprovider/providers/vsphere/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f7b3cf3

Please sign in to comment.