Adding vSphere Volume support for vSphere Cloud Provider
This commit is contained in:
24
vendor/github.com/vmware/govmomi/vim25/mo/entity.go
generated
vendored
Normal file
24
vendor/github.com/vmware/govmomi/vim25/mo/entity.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package mo
|
||||
|
||||
// Entity is the interface that is implemented by all managed objects
|
||||
// that extend ManagedEntity.
|
||||
type Entity interface {
|
||||
Reference
|
||||
Entity() *ManagedEntity
|
||||
}
|
||||
36
vendor/github.com/vmware/govmomi/vim25/mo/mo.go
generated
vendored
36
vendor/github.com/vmware/govmomi/vim25/mo/mo.go
generated
vendored
@@ -130,6 +130,10 @@ type ComputeResource struct {
|
||||
ConfigurationEx types.BaseComputeResourceConfigInfo `mo:"configurationEx"`
|
||||
}
|
||||
|
||||
func (m *ComputeResource) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["ComputeResource"] = reflect.TypeOf((*ComputeResource)(nil)).Elem()
|
||||
}
|
||||
@@ -187,6 +191,10 @@ type Datacenter struct {
|
||||
Configuration types.DatacenterConfigInfo `mo:"configuration"`
|
||||
}
|
||||
|
||||
func (m *Datacenter) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["Datacenter"] = reflect.TypeOf((*Datacenter)(nil)).Elem()
|
||||
}
|
||||
@@ -203,6 +211,10 @@ type Datastore struct {
|
||||
IormConfiguration *types.StorageIORMInfo `mo:"iormConfiguration"`
|
||||
}
|
||||
|
||||
func (m *Datastore) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["Datastore"] = reflect.TypeOf((*Datastore)(nil)).Elem()
|
||||
}
|
||||
@@ -255,6 +267,10 @@ type DistributedVirtualSwitch struct {
|
||||
Runtime *types.DVSRuntimeInfo `mo:"runtime"`
|
||||
}
|
||||
|
||||
func (m *DistributedVirtualSwitch) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DistributedVirtualSwitch"] = reflect.TypeOf((*DistributedVirtualSwitch)(nil)).Elem()
|
||||
}
|
||||
@@ -359,6 +375,10 @@ type Folder struct {
|
||||
ChildEntity []types.ManagedObjectReference `mo:"childEntity"`
|
||||
}
|
||||
|
||||
func (m *Folder) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["Folder"] = reflect.TypeOf((*Folder)(nil)).Elem()
|
||||
}
|
||||
@@ -878,6 +898,10 @@ type HostSystem struct {
|
||||
SystemResources *types.HostSystemResourceInfo `mo:"systemResources"`
|
||||
}
|
||||
|
||||
func (m *HostSystem) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["HostSystem"] = reflect.TypeOf((*HostSystem)(nil)).Elem()
|
||||
}
|
||||
@@ -1117,6 +1141,10 @@ type Network struct {
|
||||
Vm []types.ManagedObjectReference `mo:"vm"`
|
||||
}
|
||||
|
||||
func (m *Network) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["Network"] = reflect.TypeOf((*Network)(nil)).Elem()
|
||||
}
|
||||
@@ -1286,6 +1314,10 @@ type ResourcePool struct {
|
||||
ChildConfiguration []types.ResourceConfigSpec `mo:"childConfiguration"`
|
||||
}
|
||||
|
||||
func (m *ResourcePool) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["ResourcePool"] = reflect.TypeOf((*ResourcePool)(nil)).Elem()
|
||||
}
|
||||
@@ -1551,6 +1583,10 @@ type VirtualMachine struct {
|
||||
GuestHeartbeatStatus types.ManagedEntityStatus `mo:"guestHeartbeatStatus"`
|
||||
}
|
||||
|
||||
func (m *VirtualMachine) Entity() *ManagedEntity {
|
||||
return &m.ManagedEntity
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["VirtualMachine"] = reflect.TypeOf((*VirtualMachine)(nil)).Elem()
|
||||
}
|
||||
|
||||
10
vendor/github.com/vmware/govmomi/vim25/mo/type_info.go
generated
vendored
10
vendor/github.com/vmware/govmomi/vim25/mo/type_info.go
generated
vendored
@@ -189,12 +189,20 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
||||
npv := reflect.New(pt)
|
||||
npv.Elem().Set(pv)
|
||||
pv = npv
|
||||
pt = pv.Type()
|
||||
} else {
|
||||
panic(fmt.Sprintf("type %s doesn't implement %s", pt.Name(), rt.Name()))
|
||||
}
|
||||
}
|
||||
|
||||
rv.Set(pv)
|
||||
if pt.AssignableTo(rt) {
|
||||
rv.Set(pv)
|
||||
} else if rt.ConvertibleTo(pt) {
|
||||
rv.Set(pv.Convert(rt))
|
||||
} else {
|
||||
panic(fmt.Sprintf("cannot assign %s (%s) to %s (%s)", rt.Name(), rt.Kind(), pt.Name(), pt.Kind()))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
52
vendor/github.com/vmware/govmomi/vim25/soap/client.go
generated
vendored
52
vendor/github.com/vmware/govmomi/vim25/soap/client.go
generated
vendored
@@ -428,23 +428,12 @@ var DefaultDownload = Download{
|
||||
Method: "GET",
|
||||
}
|
||||
|
||||
// DownloadFile GETs the given URL to a local file
|
||||
func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
||||
var err error
|
||||
|
||||
if param == nil {
|
||||
param = &DefaultDownload
|
||||
}
|
||||
|
||||
fh, err := os.Create(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fh.Close()
|
||||
// Download GETs the remote file from the given URL
|
||||
func (c *Client) Download(u *url.URL, param *Download) (io.ReadCloser, int64, error) {
|
||||
|
||||
req, err := http.NewRequest(param.Method, u.String(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if param.Ticket != nil {
|
||||
@@ -453,11 +442,9 @@ func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
||||
|
||||
res, err := c.Client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
default:
|
||||
@@ -465,12 +452,37 @@ func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
var r io.Reader = res.Body
|
||||
var r io.ReadCloser = res.Body
|
||||
|
||||
return r, res.ContentLength, nil
|
||||
}
|
||||
|
||||
// DownloadFile GETs the given URL to a local file
|
||||
func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
||||
var err error
|
||||
if param == nil {
|
||||
param = &DefaultDownload
|
||||
}
|
||||
|
||||
rc, contentLength, err := c.Download(u, param)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
var r io.Reader = rc
|
||||
|
||||
fh, err := os.Create(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
if param.Progress != nil {
|
||||
pr := progress.NewReader(param.Progress, res.Body, res.ContentLength)
|
||||
pr := progress.NewReader(param.Progress, r, contentLength)
|
||||
r = pr
|
||||
|
||||
// Mark progress reader as done when returning from this function.
|
||||
|
||||
12
vendor/github.com/vmware/govmomi/vim25/xml/read.go
generated
vendored
12
vendor/github.com/vmware/govmomi/vim25/xml/read.go
generated
vendored
@@ -271,9 +271,19 @@ var (
|
||||
// Find reflect.Type for an element's type attribute.
|
||||
func (p *Decoder) typeForElement(val reflect.Value, start *StartElement) reflect.Type {
|
||||
t := ""
|
||||
for _, a := range start.Attr {
|
||||
for i, a := range start.Attr {
|
||||
if a.Name == xmlSchemaInstance {
|
||||
t = a.Value
|
||||
// HACK: ensure xsi:type is last in the list to avoid using that value for
|
||||
// a "type" attribute, such as ManagedObjectReference.Type for example.
|
||||
// Note that xsi:type is already the last attribute in VC/ESX responses.
|
||||
// This is only an issue with govmomi simulator generated responses.
|
||||
// Proper fix will require finding a few needles in this xml package haystack.
|
||||
x := len(start.Attr) - 1
|
||||
if i != x {
|
||||
start.Attr[i] = start.Attr[x]
|
||||
start.Attr[x] = a
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user