Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
23ee1745
Commit
23ee1745
authored
May 22, 2017
by
Balu Dontu
Committed by
System Administrator
May 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PBM govmomi dependencies
parent
199465c3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
2266 additions
and
297 deletions
+2266
-297
Godeps.json
Godeps/Godeps.json
+45
-30
LICENSES
Godeps/LICENSES
+0
-0
.mailmap
vendor/github.com/vmware/govmomi/.mailmap
+16
-0
BUILD
vendor/github.com/vmware/govmomi/BUILD
+1
-0
CHANGELOG.md
vendor/github.com/vmware/govmomi/CHANGELOG.md
+32
-0
CONTRIBUTORS
vendor/github.com/vmware/govmomi/CONTRIBUTORS
+10
-6
README.md
vendor/github.com/vmware/govmomi/README.md
+10
-0
BUILD
vendor/github.com/vmware/govmomi/find/BUILD
+2
-0
doc.go
vendor/github.com/vmware/govmomi/find/doc.go
+37
-0
finder.go
vendor/github.com/vmware/govmomi/find/finder.go
+136
-31
recurser.go
vendor/github.com/vmware/govmomi/find/recurser.go
+245
-0
BUILD
vendor/github.com/vmware/govmomi/list/BUILD
+0
-1
lister.go
vendor/github.com/vmware/govmomi/list/lister.go
+7
-18
recurser.go
vendor/github.com/vmware/govmomi/list/recurser.go
+0
-97
BUILD
vendor/github.com/vmware/govmomi/object/BUILD
+5
-1
authorization_manager_internal.go
...m/vmware/govmomi/object/authorization_manager_internal.go
+86
-0
datastore_file.go
vendor/github.com/vmware/govmomi/object/datastore_file.go
+0
-2
datastore_file_manager.go
...ithub.com/vmware/govmomi/object/datastore_file_manager.go
+145
-0
host_config_manager.go
...r/github.com/vmware/govmomi/object/host_config_manager.go
+16
-0
host_vsan_internal_system.go
...ub.com/vmware/govmomi/object/host_vsan_internal_system.go
+117
-0
list_view.go
vendor/github.com/vmware/govmomi/object/list_view.go
+0
-70
opaque_network.go
vendor/github.com/vmware/govmomi/object/opaque_network.go
+57
-0
virtual_disk_manager_internal.go
...om/vmware/govmomi/object/virtual_disk_manager_internal.go
+97
-0
virtual_machine.go
vendor/github.com/vmware/govmomi/object/virtual_machine.go
+32
-0
BUILD
vendor/github.com/vmware/govmomi/pbm/BUILD
+41
-0
client.go
vendor/github.com/vmware/govmomi/pbm/client.go
+217
-0
BUILD
vendor/github.com/vmware/govmomi/pbm/methods/BUILD
+31
-0
methods.go
vendor/github.com/vmware/govmomi/pbm/methods/methods.go
+0
-0
pbm_util.go
vendor/github.com/vmware/govmomi/pbm/pbm_util.go
+146
-0
BUILD
vendor/github.com/vmware/govmomi/pbm/types/BUILD
+32
-0
enum.go
vendor/github.com/vmware/govmomi/pbm/types/enum.go
+211
-0
if.go
vendor/github.com/vmware/govmomi/pbm/types/if.go
+139
-0
types.go
vendor/github.com/vmware/govmomi/pbm/types/types.go
+0
-0
BUILD
vendor/github.com/vmware/govmomi/property/BUILD
+1
-0
collector.go
vendor/github.com/vmware/govmomi/property/collector.go
+27
-0
filter.go
vendor/github.com/vmware/govmomi/property/filter.go
+135
-0
wait.go
vendor/github.com/vmware/govmomi/task/wait.go
+5
-0
methods.go
vendor/github.com/vmware/govmomi/vim25/methods/methods.go
+1
-1
ancestors.go
vendor/github.com/vmware/govmomi/vim25/mo/ancestors.go
+2
-0
mo.go
vendor/github.com/vmware/govmomi/vim25/mo/mo.go
+113
-28
client.go
vendor/github.com/vmware/govmomi/vim25/soap/client.go
+34
-0
error.go
vendor/github.com/vmware/govmomi/vim25/soap/error.go
+7
-1
soap.go
vendor/github.com/vmware/govmomi/vim25/soap/soap.go
+2
-6
enum.go
vendor/github.com/vmware/govmomi/vim25/types/enum.go
+1
-1
helpers.go
vendor/github.com/vmware/govmomi/vim25/types/helpers.go
+4
-0
if.go
vendor/github.com/vmware/govmomi/vim25/types/if.go
+1
-1
registry.go
vendor/github.com/vmware/govmomi/vim25/types/registry.go
+14
-1
types.go
vendor/github.com/vmware/govmomi/vim25/types/types.go
+1
-1
extras.go
vendor/github.com/vmware/govmomi/vim25/xml/extras.go
+2
-0
read.go
vendor/github.com/vmware/govmomi/vim25/xml/read.go
+3
-1
No files found.
Godeps/Godeps.json
View file @
23ee1745
...
...
@@ -2438,78 +2438,93 @@
},
{
"ImportPath"
:
"github.com/vmware/govmomi"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/find"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/list"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/object"
,
"Comment"
:
"v0.12.1-14-g0a28e59"
,
"Rev"
:
"0a28e595c8e9e99879e8d2f796e82c5a68202ff0"
"Comment"
:
"v0.14.0-11-gb8b228c"
,
"Rev"
:
"b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/pbm"
,
"Comment"
:
"v0.14.0-11-gb8b228c"
,
"Rev"
:
"b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/pbm/methods"
,
"Comment"
:
"v0.14.0-11-gb8b228c"
,
"Rev"
:
"b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/pbm/types"
,
"Comment"
:
"v0.14.0-11-gb8b228c"
,
"Rev"
:
"b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/property"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/session"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/task"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/debug"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/methods"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/mo"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/progress"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/soap"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/types"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/govmomi/vim25/xml"
,
"Comment"
:
"v0.1
2.1-14-g0a28e59
"
,
"Rev"
:
"
0a28e595c8e9e99879e8d2f796e82c5a68202ff0
"
"Comment"
:
"v0.1
4.0-11-gb8b228c
"
,
"Rev"
:
"
b8b228cfbad7f0a69ed90393ca9aee085d3c6ef1
"
},
{
"ImportPath"
:
"github.com/vmware/photon-controller-go-sdk/SSPI"
,
...
...
Godeps/LICENSES
View file @
23ee1745
This diff is collapsed.
Click to expand it.
vendor/github.com/vmware/govmomi/.mailmap
0 → 100644
View file @
23ee1745
Amit Bathla <abathla@.vmware.com> <abathla@promb-1s-dhcp216.eng.vmware.com>
Bruce Downs <bruceadowns@gmail.com> <bdowns@vmware.com>
Bruce Downs <bruceadowns@gmail.com> <bruce.downs@jivesoftware.com>
Clint Greenwood <cgreenwood@vmware.com> <clint.greenwood@gmail.com>
Cédric Blomart <cblomart@gmail.com> <cedric.blomart@minfin.fed.be>
Cédric Blomart <cblomart@gmail.com> cedric <cblomart@gmail.com>
David Stark <dave@davidstark.name> <david.stark@bskyb.com>
Eric Gray <egray@vmware.com> <ericgray@users.noreply.github.com>
Eric Yutao <eric.yutao@gmail.com> eric <eric.yutao@gmail.com>
Henrik Hodne <henrik@travis-ci.com> <henrik@hodne.io>
Jeremy Canady <jcanady@jackhenry.com> <jcanady@gmail.com>
Pieter Noordhuis <pnoordhuis@vmware.com> <pcnoordhuis@gmail.com>
Takaaki Furukawa <takaaki.frkw@gmail.com> takaaki.furukawa <takaaki.furukawa@mail.rakuten.com>
Takaaki Furukawa <takaaki.frkw@gmail.com> tkak <takaaki.frkw@gmail.com>
Vadim Egorov <vegorov@vmware.com> <egorovv@gmail.com>
Zee Yang <zeey@vmware.com> <zee.yang@gmail.com>
vendor/github.com/vmware/govmomi/BUILD
View file @
23ee1745
...
...
@@ -34,6 +34,7 @@ filegroup(
"//vendor/github.com/vmware/govmomi/find:all-srcs",
"//vendor/github.com/vmware/govmomi/list:all-srcs",
"//vendor/github.com/vmware/govmomi/object:all-srcs",
"//vendor/github.com/vmware/govmomi/pbm:all-srcs",
"//vendor/github.com/vmware/govmomi/property:all-srcs",
"//vendor/github.com/vmware/govmomi/session:all-srcs",
"//vendor/github.com/vmware/govmomi/task:all-srcs",
...
...
vendor/github.com/vmware/govmomi/CHANGELOG.md
View file @
23ee1745
# changelog
### 0.14.0 (2017-04-08)
*
Add view.ContainerView type and methods
*
Add Collector.RetrieveWithFilter method
*
Add property.Filter type
*
Implement EthernetCardBackingInfo for OpaqueNetwork
*
Finder: support changing object root in find mode
*
Add VirtualDiskManager.QueryVirtualDiskInfo
*
Add performance.Manager APIs
### 0.13.0 (2017-03-02)
*
Add DatastoreFileManager API wrapper
*
Add HostVsanInternalSystem API wrappers
*
Add Container support to view package
*
Finder supports Folder recursion without specifying a path
*
Add VirtualMachine.QueryConfigTarget method
*
Add device option to VirtualMachine.WaitForNetIP
*
Remove _Task suffix from vapp methods
### 0.12.1 (2016-12-19)
*
Add DiagnosticLog helper
...
...
vendor/github.com/vmware/govmomi/CONTRIBUTORS
View file @
23ee1745
# People who can (and typically have) contributed to this repository.
#
#
Please keep the list sorted.
#
This script is generated by contributors.sh
#
abrarshivani <abrarshivani@users.noreply.github.com>
...
...
@@ -9,24 +9,26 @@ Amit Bathla <abathla@.vmware.com>
Andrew Chin <andrew@andrewtchin.com>
Arran Walker <arran.walker@zopa.com>
Austin Parker <aparker@apprenda.com>
bastienbc <bastien.barbe.creuly@gmail.com>
Bob Killen <killen.bob@gmail.com>
Brad Fitzpatrick <bradfitz@golang.org>
Bruce Downs <bruceadowns@gmail.com>
Cédric Blomart <cblomart@gmail.com>
Christian Höltje <docwhat@gerf.org>
Clint Greenwood <cgreenwood@vmware.com>
<clint.greenwood@gmail.com>
Clint Greenwood <cgreenwood@vmware.com>
Danny Lockard <danny.lockard@banno.com>
Dave Tucker <dave@dtucker.co.uk>
Davide Agnello <dagnello@hp.com>
David Stark <dave@davidstark.name>
Doug MacEachern <dougm@vmware.com>
Eloy Coto <eloy.coto@gmail.com>
Eric Gray <egray@vmware.com>
Eric Yutao <eric.yutao@gmail.com>
Fabio Rapposelli <fabio@vmware.com>
Faiyaz Ahmed <ahmedf@vmware.com>
forkbomber <forkbomber@users.noreply.github.com>
Gavin Gray <gavin@infinio.com>
Gavrie Philipson <gavrie
@philipson.co.il> <gavrie
.philipson@elastifile.com>
Gavrie Philipson <gavrie.philipson@elastifile.com>
George Hicken <ghicken@vmware.com>
Gerrit Renker <Gerrit.Renker@ctl.io>
gthombare <gthombare@vmware.com>
...
...
@@ -34,18 +36,20 @@ Hasan Mahmood <mahmoodh@vmware.com>
Henrik Hodne <henrik@travis-ci.com>
Isaac Rodman <isaac@eyz.us>
Jason Kincl <jkincl@gmail.com>
Jeremy Canady <jcanady@jackhenry.com>
Louie Jiang <jiangl@vmware.com>
Marc Carmier <mcarmier@gmail.com>
Mevan Samaratunga <mevansam@gmail.com>
Nicolas Lamirault <nicolas.lamirault@gmail.com>
Pieter Noordhuis <pnoordhuis@vmware.com>
<pcnoordhuis@gmail.com>
Pieter Noordhuis <pnoordhuis@vmware.com>
runner.mei <runner.mei@gmail.com>
S.Çağlar Onur <conur@vmware.com>
Sergey Ignatov <sergey.ignatov@jetbrains.com>
Steve Purcell <steve@sanityinc.com>
Takaaki Furukawa <takaaki.frkw@gmail.com>
<takaaki.furukawa@mail.rakuten.com>
Takaaki Furukawa <takaaki.frkw@gmail.com>
Ted Zlatanov <tzz@lifelogs.com>
Vadim Egorov <vegorov@vmware.com>
Yang Yang <yangy@vmware.com>
Yuya Kusakabe <yuya.kusakabe@gmail.com>
Zach Tucker <ztucker@vmware.com>
Zee Yang <zeey@vmware.com>
<zee.yang@gmail.com>
Zee Yang <zeey@vmware.com>
vendor/github.com/vmware/govmomi/README.md
View file @
23ee1745
...
...
@@ -61,8 +61,18 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes.
*
[
Travis CI
](
https://github.com/travis-ci/jupiter-brain
)
*
[
collectd-vsphere
](
https://github.com/travis-ci/collectd-vsphere
)
*
[
Gru
](
https://github.com/dnaeon/gru
)
*
[
Libretto
](
https://github.com/apcera/libretto/tree/master/virtualmachine/vsphere
)
## Related projects
*
[
rbvmomi
](
https://github.com/vmware/rbvmomi
)
*
[
pyvmomi
](
https://github.com/vmware/pyvmomi
)
## License
govmomi is available under the
[
Apache 2 license
](
LICENSE
)
.
vendor/github.com/vmware/govmomi/find/BUILD
View file @
23ee1745
...
...
@@ -10,8 +10,10 @@ load(
go_library(
name = "go_default_library",
srcs = [
"doc.go",
"error.go",
"finder.go",
"recurser.go",
],
tags = ["automanaged"],
deps = [
...
...
vendor/github.com/vmware/govmomi/find/doc.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2014-2017 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 find implements inventory listing and searching.
The Finder is an alternative to the object.SearchIndex FindByInventoryPath() and FindChild() methods.
SearchIndex.FindByInventoryPath requires an absolute path, whereas the Finder also supports relative paths
and patterns via path.Match.
SearchIndex.FindChild requires a parent to find the child, whereas the Finder also supports an ancestor via
recursive object traversal.
The various Finder methods accept a "path" argument, which can absolute or relative to the Folder for the object type.
The Finder supports two modes, "list" and "find". The "list" mode behaves like the "ls" command, only searching within
the immediate path. The "find" mode behaves like the "find" command, with the search starting at the immediate path but
also recursing into sub Folders relative to the Datacenter. The default mode is "list" if the given path contains a "/",
otherwise "find" mode is used.
The exception is to use a "..." wildcard with a path to find all objects recursively underneath any root object.
For example: VirtualMachineList("/DC1/...")
See also: https://github.com/vmware/govmomi/blob/master/govc/README.md#usage
*/
package
find
vendor/github.com/vmware/govmomi/find/finder.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
...
...
@@ -20,6 +20,7 @@ import (
"context"
"errors"
"path"
"strings"
"github.com/vmware/govmomi/list"
"github.com/vmware/govmomi/object"
...
...
@@ -30,17 +31,18 @@ import (
)
type
Finder
struct
{
client
*
vim25
.
Client
recurser
list
.
Recurser
client
*
vim25
.
Client
r
recurser
dc
*
object
.
Datacenter
si
*
object
.
SearchIndex
folders
*
object
.
DatacenterFolders
}
func
NewFinder
(
client
*
vim25
.
Client
,
all
bool
)
*
Finder
{
f
:=
&
Finder
{
client
:
client
,
recurser
:
list
.
Recurser
{
si
:
object
.
NewSearchIndex
(
client
),
r
:
recurser
{
Collector
:
property
.
DefaultCollector
(
client
),
All
:
all
,
},
...
...
@@ -55,9 +57,41 @@ func (f *Finder) SetDatacenter(dc *object.Datacenter) *Finder {
return
f
}
type
findRelativeFunc
func
(
ctx
context
.
Context
)
(
object
.
Reference
,
error
)
// findRoot makes it possible to use "find" mode with a different root path.
// Example: ResourcePoolList("/dc1/host/cluster1/...")
func
(
f
*
Finder
)
findRoot
(
ctx
context
.
Context
,
root
*
list
.
Element
,
parts
[]
string
)
bool
{
if
len
(
parts
)
==
0
{
return
false
}
ix
:=
len
(
parts
)
-
1
if
parts
[
ix
]
!=
"..."
{
return
false
}
if
ix
==
0
{
return
true
// We already have the Object for root.Path
}
// Lookup the Object for the new root.Path
rootPath
:=
path
.
Join
(
root
.
Path
,
path
.
Join
(
parts
[
:
ix
]
...
))
ref
,
err
:=
f
.
si
.
FindByInventoryPath
(
ctx
,
rootPath
)
if
err
!=
nil
||
ref
==
nil
{
// If we get an error or fail to match, fall through to find() with the original root and path
return
false
}
root
.
Path
=
rootPath
root
.
Object
=
ref
return
true
}
func
(
f
*
Finder
)
find
(
ctx
context
.
Context
,
arg
string
,
s
*
spec
)
([]
list
.
Element
,
error
)
{
isPath
:=
strings
.
Contains
(
arg
,
"/"
)
func
(
f
*
Finder
)
find
(
ctx
context
.
Context
,
fn
findRelativeFunc
,
tl
bool
,
arg
string
)
([]
list
.
Element
,
error
)
{
root
:=
list
.
Element
{
Path
:
"/"
,
Object
:
object
.
NewRootFolder
(
f
.
client
),
...
...
@@ -70,7 +104,7 @@ func (f *Finder) find(ctx context.Context, fn findRelativeFunc, tl bool, arg str
case
".."
:
// Not supported; many edge case, little value
return
nil
,
errors
.
New
(
"cannot traverse up a tree"
)
case
"."
:
// Relative to whatever
pivot
,
err
:=
fn
(
ctx
)
pivot
,
err
:=
s
.
Relative
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -93,13 +127,17 @@ func (f *Finder) find(ctx context.Context, fn findRelativeFunc, tl bool, arg str
}
}
f
.
recurser
.
TraverseLeafs
=
tl
es
,
err
:=
f
.
recurser
.
Recurse
(
ctx
,
root
,
parts
)
if
err
!=
nil
{
return
nil
,
err
if
s
.
listMode
(
isPath
)
{
if
f
.
findRoot
(
ctx
,
&
root
,
parts
)
{
parts
=
[]
string
{
"*"
}
}
else
{
return
f
.
r
.
List
(
ctx
,
s
,
root
,
parts
)
}
}
return
es
,
nil
s
.
Parents
=
append
(
s
.
Parents
,
s
.
Nested
...
)
return
f
.
r
.
Find
(
ctx
,
s
,
root
,
parts
)
}
func
(
f
*
Finder
)
datacenter
()
(
*
object
.
Datacenter
,
error
)
{
...
...
@@ -208,7 +246,7 @@ func (f *Finder) rootFolder(_ context.Context) (object.Reference, error) {
return
object
.
NewRootFolder
(
f
.
client
),
nil
}
func
(
f
*
Finder
)
managedObjectList
(
ctx
context
.
Context
,
path
string
,
tl
bool
)
([]
list
.
Element
,
error
)
{
func
(
f
*
Finder
)
managedObjectList
(
ctx
context
.
Context
,
path
string
,
tl
bool
,
include
[]
string
)
([]
list
.
Element
,
error
)
{
fn
:=
f
.
rootFolder
if
f
.
dc
!=
nil
{
...
...
@@ -219,7 +257,18 @@ func (f *Finder) managedObjectList(ctx context.Context, path string, tl bool) ([
path
=
"."
}
return
f
.
find
(
ctx
,
fn
,
tl
,
path
)
s
:=
&
spec
{
Relative
:
fn
,
Parents
:
[]
string
{
"ComputeResource"
,
"ClusterComputeResource"
,
"HostSystem"
,
"VirtualApp"
,
"StoragePod"
},
Include
:
include
,
}
if
tl
{
s
.
Contents
=
true
s
.
ListMode
=
types
.
NewBool
(
true
)
}
return
f
.
find
(
ctx
,
path
,
s
)
}
// Element returns an Element for the given ManagedObjectReference
...
...
@@ -229,7 +278,11 @@ func (f *Finder) Element(ctx context.Context, ref types.ManagedObjectReference)
return
ref
,
nil
}
e
,
err
:=
f
.
find
(
ctx
,
rl
,
false
,
"."
)
s
:=
&
spec
{
Relative
:
rl
,
}
e
,
err
:=
f
.
find
(
ctx
,
"./"
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -270,16 +323,21 @@ func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectRef
return
r
,
nil
}
func
(
f
*
Finder
)
ManagedObjectList
(
ctx
context
.
Context
,
path
string
)
([]
list
.
Element
,
error
)
{
return
f
.
managedObjectList
(
ctx
,
path
,
false
)
func
(
f
*
Finder
)
ManagedObjectList
(
ctx
context
.
Context
,
path
string
,
include
...
string
)
([]
list
.
Element
,
error
)
{
return
f
.
managedObjectList
(
ctx
,
path
,
false
,
include
)
}
func
(
f
*
Finder
)
ManagedObjectListChildren
(
ctx
context
.
Context
,
path
string
)
([]
list
.
Element
,
error
)
{
return
f
.
managedObjectList
(
ctx
,
path
,
true
)
func
(
f
*
Finder
)
ManagedObjectListChildren
(
ctx
context
.
Context
,
path
string
,
include
...
string
)
([]
list
.
Element
,
error
)
{
return
f
.
managedObjectList
(
ctx
,
path
,
true
,
include
)
}
func
(
f
*
Finder
)
DatacenterList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
Datacenter
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
rootFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
rootFolder
,
Include
:
[]
string
{
"Datacenter"
},
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -336,7 +394,12 @@ func (f *Finder) DatacenterOrDefault(ctx context.Context, path string) (*object.
}
func
(
f
*
Finder
)
DatastoreList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
Datastore
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
datastoreFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
datastoreFolder
,
Parents
:
[]
string
{
"StoragePod"
},
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -404,7 +467,11 @@ func (f *Finder) DatastoreOrDefault(ctx context.Context, path string) (*object.D
}
func
(
f
*
Finder
)
DatastoreClusterList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
StoragePod
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
datastoreFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
datastoreFolder
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -461,7 +528,11 @@ func (f *Finder) DatastoreClusterOrDefault(ctx context.Context, path string) (*o
}
func
(
f
*
Finder
)
ComputeResourceList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
ComputeResource
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
hostFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
hostFolder
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -523,7 +594,11 @@ func (f *Finder) ComputeResourceOrDefault(ctx context.Context, path string) (*ob
}
func
(
f
*
Finder
)
ClusterComputeResourceList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
ClusterComputeResource
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
hostFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
hostFolder
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -564,7 +639,13 @@ func (f *Finder) ClusterComputeResource(ctx context.Context, path string) (*obje
}
func
(
f
*
Finder
)
HostSystemList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
HostSystem
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
hostFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
hostFolder
,
Parents
:
[]
string
{
"ComputeResource"
,
"ClusterComputeResource"
},
Include
:
[]
string
{
"HostSystem"
},
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -635,7 +716,11 @@ func (f *Finder) HostSystemOrDefault(ctx context.Context, path string) (*object.
}
func
(
f
*
Finder
)
NetworkList
(
ctx
context
.
Context
,
path
string
)
([]
object
.
NetworkReference
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
networkFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
networkFolder
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -644,10 +729,14 @@ func (f *Finder) NetworkList(ctx context.Context, path string) ([]object.Network
for
_
,
e
:=
range
es
{
ref
:=
e
.
Object
.
Reference
()
switch
ref
.
Type
{
case
"Network"
,
"OpaqueNetwork"
:
case
"Network"
:
r
:=
object
.
NewNetwork
(
f
.
client
,
ref
)
r
.
InventoryPath
=
e
.
Path
ns
=
append
(
ns
,
r
)
case
"OpaqueNetwork"
:
r
:=
object
.
NewOpaqueNetwork
(
f
.
client
,
ref
)
r
.
InventoryPath
=
e
.
Path
ns
=
append
(
ns
,
r
)
case
"DistributedVirtualPortgroup"
:
r
:=
object
.
NewDistributedVirtualPortgroup
(
f
.
client
,
ref
)
r
.
InventoryPath
=
e
.
Path
...
...
@@ -701,7 +790,14 @@ func (f *Finder) NetworkOrDefault(ctx context.Context, path string) (object.Netw
}
func
(
f
*
Finder
)
ResourcePoolList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
ResourcePool
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
hostFolder
,
true
,
path
)
s
:=
&
spec
{
Relative
:
f
.
hostFolder
,
Parents
:
[]
string
{
"ComputeResource"
,
"ClusterComputeResource"
,
"VirtualApp"
},
Nested
:
[]
string
{
"ResourcePool"
},
Contents
:
true
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -804,7 +900,12 @@ func (f *Finder) FolderOrDefault(ctx context.Context, path string) (*object.Fold
}
func
(
f
*
Finder
)
VirtualMachineList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
VirtualMachine
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
vmFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
vmFolder
,
Parents
:
[]
string
{
"VirtualApp"
},
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -840,7 +941,11 @@ func (f *Finder) VirtualMachine(ctx context.Context, path string) (*object.Virtu
}
func
(
f
*
Finder
)
VirtualAppList
(
ctx
context
.
Context
,
path
string
)
([]
*
object
.
VirtualApp
,
error
)
{
es
,
err
:=
f
.
find
(
ctx
,
f
.
vmFolder
,
false
,
path
)
s
:=
&
spec
{
Relative
:
f
.
vmFolder
,
}
es
,
err
:=
f
.
find
(
ctx
,
path
,
s
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
vendor/github.com/vmware/govmomi/find/recurser.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2014-2017 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
find
import
(
"context"
"os"
"path"
"github.com/vmware/govmomi/list"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25/mo"
)
// spec is used to specify per-search configuration, independent of the Finder instance.
type
spec
struct
{
// Relative returns the root object to resolve Relative paths (starts with ".")
Relative
func
(
ctx
context
.
Context
)
(
object
.
Reference
,
error
)
// ListMode can be used to optionally force "ls" behavior, rather than "find" behavior
ListMode
*
bool
// Contents configures the Recurser to list the Contents of traversable leaf nodes.
// This is typically set to true when used from the ls command, where listing
// a folder means listing its Contents. This is typically set to false for
// commands that take managed entities that are not folders as input.
Contents
bool
// Parents specifies the types which can contain the child types being searched for.
// for example, when searching for a HostSystem, parent types can be
// "ComputeResource" or "ClusterComputeResource".
Parents
[]
string
// Include specifies which types to be included in the results, used only in "find" mode.
Include
[]
string
// Nested should be set to types that can be Nested, used only in "find" mode.
Nested
[]
string
// ChildType avoids traversing into folders that can't contain the Include types, used only in "find" mode.
ChildType
[]
string
}
func
(
s
*
spec
)
traversable
(
o
mo
.
Reference
)
bool
{
ref
:=
o
.
Reference
()
switch
ref
.
Type
{
case
"Datacenter"
:
if
len
(
s
.
Include
)
==
1
&&
s
.
Include
[
0
]
==
"Datacenter"
{
// No point in traversing deeper as Datacenters cannot be nested
return
false
}
return
true
case
"Folder"
:
if
f
,
ok
:=
o
.
(
mo
.
Folder
);
ok
{
// TODO: Not making use of this yet, but here we can optimize when searching the entire
// inventory across Datacenters for specific types, for example: 'govc ls -t VirtualMachine /**'
// should not traverse into a Datacenter's host, network or datatore folders.
if
!
s
.
traversableChildType
(
f
.
ChildType
)
{
return
false
}
}
return
true
}
for
_
,
kind
:=
range
s
.
Parents
{
if
kind
==
ref
.
Type
{
return
true
}
}
return
false
}
func
(
s
*
spec
)
traversableChildType
(
ctypes
[]
string
)
bool
{
if
len
(
s
.
ChildType
)
==
0
{
return
true
}
for
_
,
t
:=
range
ctypes
{
for
_
,
c
:=
range
s
.
ChildType
{
if
t
==
c
{
return
true
}
}
}
return
false
}
func
(
s
*
spec
)
wanted
(
e
list
.
Element
)
bool
{
if
len
(
s
.
Include
)
==
0
{
return
true
}
w
:=
e
.
Object
.
Reference
()
.
Type
for
_
,
kind
:=
range
s
.
Include
{
if
w
==
kind
{
return
true
}
}
return
false
}
// listMode is a global option to revert to the original Finder behavior,
// disabling the newer "find" mode.
var
listMode
=
os
.
Getenv
(
"GOVMOMI_FINDER_LIST_MODE"
)
==
"true"
func
(
s
*
spec
)
listMode
(
isPath
bool
)
bool
{
if
listMode
{
return
true
}
if
s
.
ListMode
!=
nil
{
return
*
s
.
ListMode
}
return
isPath
}
type
recurser
struct
{
Collector
*
property
.
Collector
// All configures the recurses to fetch complete objects for leaf nodes.
All
bool
}
func
(
r
recurser
)
List
(
ctx
context
.
Context
,
s
*
spec
,
root
list
.
Element
,
parts
[]
string
)
([]
list
.
Element
,
error
)
{
if
len
(
parts
)
==
0
{
// Include non-traversable leaf elements in result. For example, consider
// the pattern "./vm/my-vm-*", where the pattern should match the VMs and
// not try to traverse them.
//
// Include traversable leaf elements in result, if the contents
// field is set to false.
//
if
!
s
.
Contents
||
!
s
.
traversable
(
root
.
Object
.
Reference
())
{
return
[]
list
.
Element
{
root
},
nil
}
}
k
:=
list
.
Lister
{
Collector
:
r
.
Collector
,
Reference
:
root
.
Object
.
Reference
(),
Prefix
:
root
.
Path
,
}
if
r
.
All
&&
len
(
parts
)
<
2
{
k
.
All
=
true
}
in
,
err
:=
k
.
List
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
// This folder is a leaf as far as the glob goes.
if
len
(
parts
)
==
0
{
return
in
,
nil
}
pattern
:=
parts
[
0
]
parts
=
parts
[
1
:
]
var
out
[]
list
.
Element
for
_
,
e
:=
range
in
{
matched
,
err
:=
path
.
Match
(
pattern
,
path
.
Base
(
e
.
Path
))
if
err
!=
nil
{
return
nil
,
err
}
if
!
matched
{
continue
}
nres
,
err
:=
r
.
List
(
ctx
,
s
,
e
,
parts
)
if
err
!=
nil
{
return
nil
,
err
}
out
=
append
(
out
,
nres
...
)
}
return
out
,
nil
}
func
(
r
recurser
)
Find
(
ctx
context
.
Context
,
s
*
spec
,
root
list
.
Element
,
parts
[]
string
)
([]
list
.
Element
,
error
)
{
var
out
[]
list
.
Element
if
len
(
parts
)
>
0
{
pattern
:=
parts
[
0
]
matched
,
err
:=
path
.
Match
(
pattern
,
path
.
Base
(
root
.
Path
))
if
err
!=
nil
{
return
nil
,
err
}
if
matched
&&
s
.
wanted
(
root
)
{
out
=
append
(
out
,
root
)
}
}
if
!
s
.
traversable
(
root
.
Object
)
{
return
out
,
nil
}
k
:=
list
.
Lister
{
Collector
:
r
.
Collector
,
Reference
:
root
.
Object
.
Reference
(),
Prefix
:
root
.
Path
,
}
in
,
err
:=
k
.
List
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
e
:=
range
in
{
nres
,
err
:=
r
.
Find
(
ctx
,
s
,
e
,
parts
)
if
err
!=
nil
{
return
nil
,
err
}
out
=
append
(
out
,
nres
...
)
}
return
out
,
nil
}
vendor/github.com/vmware/govmomi/list/BUILD
View file @
23ee1745
...
...
@@ -12,7 +12,6 @@ go_library(
srcs = [
"lister.go",
"path.go",
"recurser.go",
],
tags = ["automanaged"],
deps = [
...
...
vendor/github.com/vmware/govmomi/list/lister.go
View file @
23ee1745
...
...
@@ -33,6 +33,10 @@ type Element struct {
Object
mo
.
Reference
}
func
(
e
Element
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s @ %s"
,
e
.
Object
.
Reference
(),
e
.
Path
)
}
func
ToElement
(
r
mo
.
Reference
,
prefix
string
)
Element
{
var
name
string
...
...
@@ -112,23 +116,6 @@ type Lister struct {
All
bool
}
func
traversable
(
ref
types
.
ManagedObjectReference
)
bool
{
switch
ref
.
Type
{
case
"Folder"
:
case
"Datacenter"
:
case
"ComputeResource"
,
"ClusterComputeResource"
:
// Treat ComputeResource and ClusterComputeResource as one and the same.
// It doesn't matter from the perspective of the lister.
case
"HostSystem"
:
case
"VirtualApp"
:
case
"StoragePod"
:
default
:
return
false
}
return
true
}
func
(
l
Lister
)
retrieveProperties
(
ctx
context
.
Context
,
req
types
.
RetrieveProperties
,
dst
*
[]
interface
{})
error
{
res
,
err
:=
l
.
Collector
.
RetrieveProperties
(
ctx
,
req
)
if
err
!=
nil
{
...
...
@@ -225,6 +212,8 @@ func (l Lister) ListFolder(ctx context.Context) ([]Element, error) {
// Additional basic properties.
switch
t
{
case
"Folder"
:
pspec
.
PathSet
=
append
(
pspec
.
PathSet
,
"childType"
)
case
"ComputeResource"
,
"ClusterComputeResource"
:
// The ComputeResource and ClusterComputeResource are dereferenced in
// the ResourcePoolFlag. Make sure they always have their resourcePool
...
...
@@ -286,7 +275,7 @@ func (l Lister) ListDatacenter(ctx context.Context) ([]Element, error) {
if
l
.
All
{
pspec
.
All
=
types
.
NewBool
(
true
)
}
else
{
pspec
.
PathSet
=
[]
string
{
"name"
}
pspec
.
PathSet
=
[]
string
{
"name"
,
"childType"
}
}
req
:=
types
.
RetrieveProperties
{
...
...
vendor/github.com/vmware/govmomi/list/recurser.go
deleted
100644 → 0
View file @
199465c3
/*
Copyright (c) 2014-2015 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
list
import
(
"context"
"path"
"path/filepath"
"github.com/vmware/govmomi/property"
)
type
Recurser
struct
{
Collector
*
property
.
Collector
// All configures the recurses to fetch complete objects for leaf nodes.
All
bool
// TraverseLeafs configures the Recurser to traverse traversable leaf nodes.
// This is typically set to true when used from the ls command, where listing
// a folder means listing its contents. This is typically set to false for
// commands that take managed entities that are not folders as input.
TraverseLeafs
bool
}
func
(
r
Recurser
)
Recurse
(
ctx
context
.
Context
,
root
Element
,
parts
[]
string
)
([]
Element
,
error
)
{
if
len
(
parts
)
==
0
{
// Include non-traversable leaf elements in result. For example, consider
// the pattern "./vm/my-vm-*", where the pattern should match the VMs and
// not try to traverse them.
//
// Include traversable leaf elements in result, if the TraverseLeafs
// field is set to false.
//
if
!
traversable
(
root
.
Object
.
Reference
())
||
!
r
.
TraverseLeafs
{
return
[]
Element
{
root
},
nil
}
}
k
:=
Lister
{
Collector
:
r
.
Collector
,
Reference
:
root
.
Object
.
Reference
(),
Prefix
:
root
.
Path
,
}
if
r
.
All
&&
len
(
parts
)
<
2
{
k
.
All
=
true
}
in
,
err
:=
k
.
List
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
// This folder is a leaf as far as the glob goes.
if
len
(
parts
)
==
0
{
return
in
,
nil
}
pattern
:=
parts
[
0
]
parts
=
parts
[
1
:
]
var
out
[]
Element
for
_
,
e
:=
range
in
{
matched
,
err
:=
filepath
.
Match
(
pattern
,
path
.
Base
(
e
.
Path
))
if
err
!=
nil
{
return
nil
,
err
}
if
!
matched
{
continue
}
nres
,
err
:=
r
.
Recurse
(
ctx
,
e
,
parts
)
if
err
!=
nil
{
return
nil
,
err
}
out
=
append
(
out
,
nres
...
)
}
return
out
,
nil
}
vendor/github.com/vmware/govmomi/object/BUILD
View file @
23ee1745
...
...
@@ -11,6 +11,7 @@ go_library(
name = "go_default_library",
srcs = [
"authorization_manager.go",
"authorization_manager_internal.go",
"cluster_compute_resource.go",
"common.go",
"compute_resource.go",
...
...
@@ -19,6 +20,7 @@ go_library(
"datacenter.go",
"datastore.go",
"datastore_file.go",
"datastore_file_manager.go",
"datastore_path.go",
"diagnostic_log.go",
"diagnostic_manager.go",
...
...
@@ -41,12 +43,13 @@ go_library(
"host_storage_system.go",
"host_system.go",
"host_virtual_nic_manager.go",
"host_vsan_internal_system.go",
"host_vsan_system.go",
"http_nfc_lease.go",
"list_view.go",
"namespace_manager.go",
"network.go",
"network_reference.go",
"opaque_network.go",
"option_manager.go",
"ovf_manager.go",
"resource_pool.go",
...
...
@@ -58,6 +61,7 @@ go_library(
"virtual_app.go",
"virtual_device_list.go",
"virtual_disk_manager.go",
"virtual_disk_manager_internal.go",
"virtual_machine.go",
"vmware_distributed_virtual_switch.go",
],
...
...
vendor/github.com/vmware/govmomi/object/authorization_manager_internal.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
object
import
(
"context"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
type
DisabledMethodRequest
struct
{
Method
string
`xml:"method"`
Reason
string
`xml:"reasonId"`
}
type
disableMethodsRequest
struct
{
This
types
.
ManagedObjectReference
`xml:"_this"`
Entity
[]
types
.
ManagedObjectReference
`xml:"entity"`
Method
[]
DisabledMethodRequest
`xml:"method"`
Source
string
`xml:"sourceId"`
Scope
bool
`xml:"sessionScope,omitempty"`
}
type
disableMethodsBody
struct
{
Req
*
disableMethodsRequest
`xml:"urn:internalvim25 DisableMethods,omitempty"`
Res
interface
{}
`xml:"urn:vim25 DisableMethodsResponse,omitempty"`
Err
*
soap
.
Fault
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func
(
b
*
disableMethodsBody
)
Fault
()
*
soap
.
Fault
{
return
b
.
Err
}
func
(
m
AuthorizationManager
)
DisableMethods
(
ctx
context
.
Context
,
entity
[]
types
.
ManagedObjectReference
,
method
[]
DisabledMethodRequest
,
source
string
)
error
{
var
reqBody
,
resBody
disableMethodsBody
reqBody
.
Req
=
&
disableMethodsRequest
{
This
:
m
.
Reference
(),
Entity
:
entity
,
Method
:
method
,
Source
:
source
,
}
return
m
.
Client
()
.
RoundTrip
(
ctx
,
&
reqBody
,
&
resBody
)
}
type
enableMethodsRequest
struct
{
This
types
.
ManagedObjectReference
`xml:"_this"`
Entity
[]
types
.
ManagedObjectReference
`xml:"entity"`
Method
[]
string
`xml:"method"`
Source
string
`xml:"sourceId"`
}
type
enableMethodsBody
struct
{
Req
*
enableMethodsRequest
`xml:"urn:internalvim25 EnableMethods,omitempty"`
Res
interface
{}
`xml:"urn:vim25 EnableMethodsResponse,omitempty"`
Err
*
soap
.
Fault
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func
(
b
*
enableMethodsBody
)
Fault
()
*
soap
.
Fault
{
return
b
.
Err
}
func
(
m
AuthorizationManager
)
EnableMethods
(
ctx
context
.
Context
,
entity
[]
types
.
ManagedObjectReference
,
method
[]
string
,
source
string
)
error
{
var
reqBody
,
resBody
enableMethodsBody
reqBody
.
Req
=
&
enableMethodsRequest
{
This
:
m
.
Reference
(),
Entity
:
entity
,
Method
:
method
,
Source
:
source
,
}
return
m
.
Client
()
.
RoundTrip
(
ctx
,
&
reqBody
,
&
resBody
)
}
vendor/github.com/vmware/govmomi/object/datastore_file.go
View file @
23ee1745
...
...
@@ -344,8 +344,6 @@ func (f *followDatastoreFile) Read(p []byte) (int, error) {
offset
:=
f
.
r
.
offset
.
seek
stop
:=
false
defer
f
.
r
.
Close
()
for
{
n
,
err
:=
f
.
r
.
Read
(
p
)
if
err
!=
nil
&&
err
==
io
.
EOF
{
...
...
vendor/github.com/vmware/govmomi/object/datastore_file_manager.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
object
import
(
"bufio"
"bytes"
"context"
"fmt"
"io"
"log"
"path"
"strings"
"github.com/vmware/govmomi/vim25/soap"
)
// DatastoreFileManager combines FileManager and VirtualDiskManager to manage files on a Datastore
type
DatastoreFileManager
struct
{
Datacenter
*
Datacenter
Datastore
*
Datastore
FileManager
*
FileManager
VirtualDiskManager
*
VirtualDiskManager
Force
bool
}
// NewFileManager creates a new instance of DatastoreFileManager
func
(
d
Datastore
)
NewFileManager
(
dc
*
Datacenter
,
force
bool
)
*
DatastoreFileManager
{
c
:=
d
.
Client
()
m
:=
&
DatastoreFileManager
{
Datacenter
:
dc
,
Datastore
:
&
d
,
FileManager
:
NewFileManager
(
c
),
VirtualDiskManager
:
NewVirtualDiskManager
(
c
),
Force
:
force
,
}
return
m
}
// Delete dispatches to the appropriate Delete method based on file name extension
func
(
m
*
DatastoreFileManager
)
Delete
(
ctx
context
.
Context
,
name
string
)
error
{
switch
path
.
Ext
(
name
)
{
case
".vmdk"
:
return
m
.
DeleteVirtualDisk
(
ctx
,
name
)
default
:
return
m
.
DeleteFile
(
ctx
,
name
)
}
}
// DeleteFile calls FileManager.DeleteDatastoreFile
func
(
m
*
DatastoreFileManager
)
DeleteFile
(
ctx
context
.
Context
,
name
string
)
error
{
p
:=
m
.
Path
(
name
)
task
,
err
:=
m
.
FileManager
.
DeleteDatastoreFile
(
ctx
,
p
.
String
(),
m
.
Datacenter
)
if
err
!=
nil
{
return
err
}
return
task
.
Wait
(
ctx
)
}
// DeleteVirtualDisk calls VirtualDiskManager.DeleteVirtualDisk
// Regardless of the Datastore type, DeleteVirtualDisk will fail if 'ddb.deletable=false',
// so if Force=true this method attempts to set 'ddb.deletable=true' before starting the delete task.
func
(
m
*
DatastoreFileManager
)
DeleteVirtualDisk
(
ctx
context
.
Context
,
name
string
)
error
{
p
:=
m
.
Path
(
name
)
var
merr
error
if
m
.
Force
{
merr
=
m
.
markDiskAsDeletable
(
ctx
,
p
)
}
task
,
err
:=
m
.
VirtualDiskManager
.
DeleteVirtualDisk
(
ctx
,
p
.
String
(),
m
.
Datacenter
)
if
err
!=
nil
{
log
.
Printf
(
"markDiskAsDeletable(%s): %s"
,
p
,
merr
)
return
err
}
return
task
.
Wait
(
ctx
)
}
// Path converts path name to a DatastorePath
func
(
m
*
DatastoreFileManager
)
Path
(
name
string
)
*
DatastorePath
{
var
p
DatastorePath
if
!
p
.
FromString
(
name
)
{
p
.
Path
=
name
p
.
Datastore
=
m
.
Datastore
.
Name
()
}
return
&
p
}
func
(
m
*
DatastoreFileManager
)
markDiskAsDeletable
(
ctx
context
.
Context
,
path
*
DatastorePath
)
error
{
r
,
_
,
err
:=
m
.
Datastore
.
Download
(
ctx
,
path
.
Path
,
&
soap
.
DefaultDownload
)
if
err
!=
nil
{
return
err
}
defer
r
.
Close
()
hasFlag
:=
false
buf
:=
new
(
bytes
.
Buffer
)
s
:=
bufio
.
NewScanner
(
&
io
.
LimitedReader
{
R
:
r
,
N
:
2048
})
// should be only a few hundred bytes, limit to be sure
for
s
.
Scan
()
{
line
:=
s
.
Text
()
if
strings
.
HasPrefix
(
line
,
"ddb.deletable"
)
{
hasFlag
=
true
continue
}
fmt
.
Fprintln
(
buf
,
line
)
}
if
err
:=
s
.
Err
();
err
!=
nil
{
return
err
// any error other than EOF
}
if
!
hasFlag
{
return
nil
// already deletable, so leave as-is
}
// rewrite the .vmdk with ddb.deletable flag removed (the default is true)
return
m
.
Datastore
.
Upload
(
ctx
,
buf
,
path
.
Path
,
&
soap
.
DefaultUpload
)
}
vendor/github.com/vmware/govmomi/object/host_config_manager.go
View file @
23ee1745
...
...
@@ -105,6 +105,22 @@ func (m HostConfigManager) VsanSystem(ctx context.Context) (*HostVsanSystem, err
return
NewHostVsanSystem
(
m
.
c
,
*
h
.
ConfigManager
.
VsanSystem
),
nil
}
func
(
m
HostConfigManager
)
VsanInternalSystem
(
ctx
context
.
Context
)
(
*
HostVsanInternalSystem
,
error
)
{
var
h
mo
.
HostSystem
err
:=
m
.
Properties
(
ctx
,
m
.
Reference
(),
[]
string
{
"configManager.vsanInternalSystem"
},
&
h
)
if
err
!=
nil
{
return
nil
,
err
}
// Added in 5.5
if
h
.
ConfigManager
.
VsanInternalSystem
==
nil
{
return
nil
,
ErrNotSupported
}
return
NewHostVsanInternalSystem
(
m
.
c
,
*
h
.
ConfigManager
.
VsanInternalSystem
),
nil
}
func
(
m
HostConfigManager
)
AccountManager
(
ctx
context
.
Context
)
(
*
HostAccountManager
,
error
)
{
var
h
mo
.
HostSystem
...
...
vendor/github.com/vmware/govmomi/object/host_vsan_internal_system.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
object
import
(
"context"
"encoding/json"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
)
type
HostVsanInternalSystem
struct
{
Common
}
func
NewHostVsanInternalSystem
(
c
*
vim25
.
Client
,
ref
types
.
ManagedObjectReference
)
*
HostVsanInternalSystem
{
m
:=
HostVsanInternalSystem
{
Common
:
NewCommon
(
c
,
ref
),
}
return
&
m
}
// QueryVsanObjectUuidsByFilter returns vSAN DOM object uuids by filter.
func
(
m
HostVsanInternalSystem
)
QueryVsanObjectUuidsByFilter
(
ctx
context
.
Context
,
uuids
[]
string
,
limit
int32
,
version
int32
)
([]
string
,
error
)
{
req
:=
types
.
QueryVsanObjectUuidsByFilter
{
This
:
m
.
Reference
(),
Uuids
:
uuids
,
Limit
:
limit
,
Version
:
version
,
}
res
,
err
:=
methods
.
QueryVsanObjectUuidsByFilter
(
ctx
,
m
.
Client
(),
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
type
VsanObjExtAttrs
struct
{
Type
string
`json:"Object type"`
Class
string
`json:"Object class"`
Size
string
`json:"Object size"`
Path
string
`json:"Object path"`
Name
string
`json:"User friendly name"`
}
func
(
a
*
VsanObjExtAttrs
)
DatastorePath
(
dir
string
)
string
{
l
:=
len
(
dir
)
path
:=
a
.
Path
if
len
(
path
)
>=
l
{
path
=
a
.
Path
[
l
:
]
}
if
path
!=
""
{
return
path
}
return
a
.
Name
// vmnamespace
}
// GetVsanObjExtAttrs is internal and intended for troubleshooting/debugging situations in the field.
// WARNING: This API can be slow because we do IOs (reads) to all the objects.
func
(
m
HostVsanInternalSystem
)
GetVsanObjExtAttrs
(
ctx
context
.
Context
,
uuids
[]
string
)
(
map
[
string
]
VsanObjExtAttrs
,
error
)
{
req
:=
types
.
GetVsanObjExtAttrs
{
This
:
m
.
Reference
(),
Uuids
:
uuids
,
}
res
,
err
:=
methods
.
GetVsanObjExtAttrs
(
ctx
,
m
.
Client
(),
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
var
attrs
map
[
string
]
VsanObjExtAttrs
err
=
json
.
Unmarshal
([]
byte
(
res
.
Returnval
),
&
attrs
)
return
attrs
,
err
}
// DeleteVsanObjects is internal and intended for troubleshooting/debugging only.
// WARNING: This API can be slow because we do IOs to all the objects.
// DOM won't allow access to objects which have lost quorum. Such objects can be deleted with the optional "force" flag.
// These objects may however re-appear with quorum if the absent components come back (network partition gets resolved, etc.)
func
(
m
HostVsanInternalSystem
)
DeleteVsanObjects
(
ctx
context
.
Context
,
uuids
[]
string
,
force
*
bool
)
([]
types
.
HostVsanInternalSystemDeleteVsanObjectsResult
,
error
)
{
req
:=
types
.
DeleteVsanObjects
{
This
:
m
.
Reference
(),
Uuids
:
uuids
,
Force
:
force
,
}
res
,
err
:=
methods
.
DeleteVsanObjects
(
ctx
,
m
.
Client
(),
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
vendor/github.com/vmware/govmomi/object/list_view.go
deleted
100644 → 0
View file @
199465c3
/*
Copyright (c) 2015 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
object
import
(
"context"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
)
type
ListView
struct
{
Common
}
func
NewListView
(
c
*
vim25
.
Client
,
ref
types
.
ManagedObjectReference
)
*
ListView
{
return
&
ListView
{
Common
:
NewCommon
(
c
,
ref
),
}
}
func
(
v
ListView
)
Destroy
(
ctx
context
.
Context
)
error
{
req
:=
types
.
DestroyView
{
This
:
v
.
Reference
(),
}
_
,
err
:=
methods
.
DestroyView
(
ctx
,
v
.
c
,
&
req
)
return
err
}
func
(
v
ListView
)
Add
(
ctx
context
.
Context
,
refs
[]
types
.
ManagedObjectReference
)
error
{
req
:=
types
.
ModifyListView
{
This
:
v
.
Reference
(),
Add
:
refs
,
}
_
,
err
:=
methods
.
ModifyListView
(
ctx
,
v
.
c
,
&
req
)
return
err
}
func
(
v
ListView
)
Remove
(
ctx
context
.
Context
,
refs
[]
types
.
ManagedObjectReference
)
error
{
req
:=
types
.
ModifyListView
{
This
:
v
.
Reference
(),
Remove
:
refs
,
}
_
,
err
:=
methods
.
ModifyListView
(
ctx
,
v
.
c
,
&
req
)
return
err
}
func
(
v
ListView
)
Reset
(
ctx
context
.
Context
,
refs
[]
types
.
ManagedObjectReference
)
error
{
req
:=
types
.
ResetListView
{
This
:
v
.
Reference
(),
Obj
:
refs
,
}
_
,
err
:=
methods
.
ResetListView
(
ctx
,
v
.
c
,
&
req
)
return
err
}
vendor/github.com/vmware/govmomi/object/opaque_network.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
object
import
(
"context"
"fmt"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type
OpaqueNetwork
struct
{
Common
}
func
NewOpaqueNetwork
(
c
*
vim25
.
Client
,
ref
types
.
ManagedObjectReference
)
*
OpaqueNetwork
{
return
&
OpaqueNetwork
{
Common
:
NewCommon
(
c
,
ref
),
}
}
// EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this Network
func
(
n
OpaqueNetwork
)
EthernetCardBackingInfo
(
ctx
context
.
Context
)
(
types
.
BaseVirtualDeviceBackingInfo
,
error
)
{
var
net
mo
.
OpaqueNetwork
if
err
:=
n
.
Properties
(
ctx
,
n
.
Reference
(),
[]
string
{
"summary"
},
&
net
);
err
!=
nil
{
return
nil
,
err
}
summary
,
ok
:=
net
.
Summary
.
(
*
types
.
OpaqueNetworkSummary
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"%s unsupported network type: %T"
,
n
,
net
.
Summary
)
}
backing
:=
&
types
.
VirtualEthernetCardOpaqueNetworkBackingInfo
{
OpaqueNetworkId
:
summary
.
OpaqueNetworkId
,
OpaqueNetworkType
:
summary
.
OpaqueNetworkType
,
}
return
backing
,
nil
}
vendor/github.com/vmware/govmomi/object/virtual_disk_manager_internal.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
object
import
(
"context"
"reflect"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
func
init
()
{
types
.
Add
(
"ArrayOfVirtualDiskInfo"
,
reflect
.
TypeOf
((
*
arrayOfVirtualDiskInfo
)(
nil
))
.
Elem
())
types
.
Add
(
"VirtualDiskInfo"
,
reflect
.
TypeOf
((
*
VirtualDiskInfo
)(
nil
))
.
Elem
())
}
type
arrayOfVirtualDiskInfo
struct
{
VirtualDiskInfo
[]
VirtualDiskInfo
`xml:"VirtualDiskInfo,omitempty"`
}
type
queryVirtualDiskInfoTaskRequest
struct
{
This
types
.
ManagedObjectReference
`xml:"_this"`
Name
string
`xml:"name"`
Datacenter
*
types
.
ManagedObjectReference
`xml:"datacenter,omitempty"`
IncludeParents
bool
`xml:"includeParents"`
}
type
queryVirtualDiskInfoTaskResponse
struct
{
Returnval
types
.
ManagedObjectReference
`xml:"returnval"`
}
type
queryVirtualDiskInfoTaskBody
struct
{
Req
*
queryVirtualDiskInfoTaskRequest
`xml:"urn:internalvim25 QueryVirtualDiskInfo_Task,omitempty"`
Res
*
queryVirtualDiskInfoTaskResponse
`xml:"urn:vim25 QueryVirtualDiskInfo_TaskResponse,omitempty"`
Err
*
soap
.
Fault
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
}
func
(
b
*
queryVirtualDiskInfoTaskBody
)
Fault
()
*
soap
.
Fault
{
return
b
.
Err
}
func
queryVirtualDiskInfoTask
(
ctx
context
.
Context
,
r
soap
.
RoundTripper
,
req
*
queryVirtualDiskInfoTaskRequest
)
(
*
queryVirtualDiskInfoTaskResponse
,
error
)
{
var
reqBody
,
resBody
queryVirtualDiskInfoTaskBody
reqBody
.
Req
=
req
if
err
:=
r
.
RoundTrip
(
ctx
,
&
reqBody
,
&
resBody
);
err
!=
nil
{
return
nil
,
err
}
return
resBody
.
Res
,
nil
}
type
VirtualDiskInfo
struct
{
Name
string
`xml:"unit>name"`
DiskType
string
`xml:"diskType"`
Parent
string
`xml:"parent,omitempty"`
}
func
(
m
VirtualDiskManager
)
QueryVirtualDiskInfo
(
ctx
context
.
Context
,
name
string
,
dc
*
Datacenter
,
includeParents
bool
)
([]
VirtualDiskInfo
,
error
)
{
req
:=
queryVirtualDiskInfoTaskRequest
{
This
:
m
.
Reference
(),
Name
:
name
,
IncludeParents
:
includeParents
,
}
if
dc
!=
nil
{
ref
:=
dc
.
Reference
()
req
.
Datacenter
=
&
ref
}
res
,
err
:=
queryVirtualDiskInfoTask
(
ctx
,
m
.
Client
(),
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
info
,
err
:=
NewTask
(
m
.
Client
(),
res
.
Returnval
)
.
WaitForResult
(
ctx
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
return
info
.
Result
.
(
arrayOfVirtualDiskInfo
)
.
VirtualDiskInfo
,
nil
}
vendor/github.com/vmware/govmomi/object/virtual_machine.go
View file @
23ee1745
...
...
@@ -725,3 +725,35 @@ func (v VirtualMachine) QueryConfigTarget(ctx context.Context) (*types.ConfigTar
return
res
.
Returnval
,
nil
}
func
(
v
VirtualMachine
)
MountToolsInstaller
(
ctx
context
.
Context
)
error
{
req
:=
types
.
MountToolsInstaller
{
This
:
v
.
Reference
(),
}
_
,
err
:=
methods
.
MountToolsInstaller
(
ctx
,
v
.
Client
(),
&
req
)
return
err
}
func
(
v
VirtualMachine
)
UnmountToolsInstaller
(
ctx
context
.
Context
)
error
{
req
:=
types
.
UnmountToolsInstaller
{
This
:
v
.
Reference
(),
}
_
,
err
:=
methods
.
UnmountToolsInstaller
(
ctx
,
v
.
Client
(),
&
req
)
return
err
}
func
(
v
VirtualMachine
)
UpgradeTools
(
ctx
context
.
Context
,
options
string
)
(
*
Task
,
error
)
{
req
:=
types
.
UpgradeTools_Task
{
This
:
v
.
Reference
(),
InstallerOptions
:
options
,
}
res
,
err
:=
methods
.
UpgradeTools_Task
(
ctx
,
v
.
Client
(),
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
NewTask
(
v
.
c
,
res
.
Returnval
),
nil
}
vendor/github.com/vmware/govmomi/pbm/BUILD
0 → 100644
View file @
23ee1745
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"client.go",
"pbm_util.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/vmware/govmomi/pbm/methods:go_default_library",
"//vendor/github.com/vmware/govmomi/pbm/types:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/soap:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/types:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//vendor/github.com/vmware/govmomi/pbm/methods:all-srcs",
"//vendor/github.com/vmware/govmomi/pbm/types:all-srcs",
],
tags = ["automanaged"],
)
vendor/github.com/vmware/govmomi/pbm/client.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
pbm
import
(
"context"
"fmt"
"github.com/vmware/govmomi/pbm/methods"
"github.com/vmware/govmomi/pbm/types"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
vim
"github.com/vmware/govmomi/vim25/types"
)
type
Client
struct
{
*
soap
.
Client
ServiceContent
types
.
PbmServiceInstanceContent
}
func
NewClient
(
ctx
context
.
Context
,
c
*
vim25
.
Client
)
(
*
Client
,
error
)
{
sc
:=
c
.
Client
.
NewServiceClient
(
"/pbm/sdk"
,
"urn:pbm"
)
req
:=
types
.
PbmRetrieveServiceContent
{
This
:
vim
.
ManagedObjectReference
{
Type
:
"PbmServiceInstance"
,
Value
:
"ServiceInstance"
,
},
}
res
,
err
:=
methods
.
PbmRetrieveServiceContent
(
ctx
,
sc
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
Client
{
sc
,
res
.
Returnval
},
nil
}
func
(
c
*
Client
)
QueryProfile
(
ctx
context
.
Context
,
rtype
types
.
PbmProfileResourceType
,
category
string
)
([]
types
.
PbmProfileId
,
error
)
{
req
:=
types
.
PbmQueryProfile
{
This
:
c
.
ServiceContent
.
ProfileManager
,
ResourceType
:
rtype
,
ProfileCategory
:
category
,
}
res
,
err
:=
methods
.
PbmQueryProfile
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
func
(
c
*
Client
)
RetrieveContent
(
ctx
context
.
Context
,
ids
[]
types
.
PbmProfileId
)
([]
types
.
BasePbmProfile
,
error
)
{
req
:=
types
.
PbmRetrieveContent
{
This
:
c
.
ServiceContent
.
ProfileManager
,
ProfileIds
:
ids
,
}
res
,
err
:=
methods
.
PbmRetrieveContent
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
type
PlacementCompatibilityResult
[]
types
.
PbmPlacementCompatibilityResult
func
(
c
*
Client
)
CheckRequirements
(
ctx
context
.
Context
,
hubs
[]
types
.
PbmPlacementHub
,
ref
*
types
.
PbmServerObjectRef
,
preq
[]
types
.
BasePbmPlacementRequirement
)
(
PlacementCompatibilityResult
,
error
)
{
req
:=
types
.
PbmCheckRequirements
{
This
:
c
.
ServiceContent
.
PlacementSolver
,
HubsToSearch
:
hubs
,
PlacementSubjectRef
:
ref
,
PlacementSubjectRequirement
:
preq
,
}
res
,
err
:=
methods
.
PbmCheckRequirements
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
func
(
l
PlacementCompatibilityResult
)
CompatibleDatastores
()
[]
types
.
PbmPlacementHub
{
var
compatibleDatastores
[]
types
.
PbmPlacementHub
for
_
,
res
:=
range
l
{
if
len
(
res
.
Error
)
==
0
{
compatibleDatastores
=
append
(
compatibleDatastores
,
res
.
Hub
)
}
}
return
compatibleDatastores
}
func
(
l
PlacementCompatibilityResult
)
NonCompatibleDatastores
()
[]
types
.
PbmPlacementHub
{
var
nonCompatibleDatastores
[]
types
.
PbmPlacementHub
for
_
,
res
:=
range
l
{
if
len
(
res
.
Error
)
>
0
{
nonCompatibleDatastores
=
append
(
nonCompatibleDatastores
,
res
.
Hub
)
}
}
return
nonCompatibleDatastores
}
func
(
c
*
Client
)
CreateProfile
(
ctx
context
.
Context
,
capabilityProfileCreateSpec
types
.
PbmCapabilityProfileCreateSpec
)
(
*
types
.
PbmProfileId
,
error
)
{
req
:=
types
.
PbmCreate
{
This
:
c
.
ServiceContent
.
ProfileManager
,
CreateSpec
:
capabilityProfileCreateSpec
,
}
res
,
err
:=
methods
.
PbmCreate
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
res
.
Returnval
,
nil
}
func
(
c
*
Client
)
UpdateProfile
(
ctx
context
.
Context
,
id
types
.
PbmProfileId
,
updateSpec
types
.
PbmCapabilityProfileUpdateSpec
)
error
{
req
:=
types
.
PbmUpdate
{
This
:
c
.
ServiceContent
.
ProfileManager
,
ProfileId
:
id
,
UpdateSpec
:
updateSpec
,
}
_
,
err
:=
methods
.
PbmUpdate
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
(
c
*
Client
)
DeleteProfile
(
ctx
context
.
Context
,
ids
[]
types
.
PbmProfileId
)
([]
types
.
PbmProfileOperationOutcome
,
error
)
{
req
:=
types
.
PbmDelete
{
This
:
c
.
ServiceContent
.
ProfileManager
,
ProfileId
:
ids
,
}
res
,
err
:=
methods
.
PbmDelete
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
func
(
c
*
Client
)
QueryAssociatedEntity
(
ctx
context
.
Context
,
id
types
.
PbmProfileId
,
entityType
string
)
([]
types
.
PbmServerObjectRef
,
error
)
{
req
:=
types
.
PbmQueryAssociatedEntity
{
This
:
c
.
ServiceContent
.
ProfileManager
,
Profile
:
id
,
EntityType
:
entityType
,
}
res
,
err
:=
methods
.
PbmQueryAssociatedEntity
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
func
(
c
*
Client
)
QueryAssociatedEntities
(
ctx
context
.
Context
,
ids
[]
types
.
PbmProfileId
)
([]
types
.
PbmQueryProfileResult
,
error
)
{
req
:=
types
.
PbmQueryAssociatedEntities
{
This
:
c
.
ServiceContent
.
ProfileManager
,
Profiles
:
ids
,
}
res
,
err
:=
methods
.
PbmQueryAssociatedEntities
(
ctx
,
c
,
&
req
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
.
Returnval
,
nil
}
func
(
c
*
Client
)
ProfileIDByName
(
ctx
context
.
Context
,
profileName
string
)
(
string
,
error
)
{
resourceType
:=
types
.
PbmProfileResourceType
{
ResourceType
:
string
(
types
.
PbmProfileResourceTypeEnumSTORAGE
),
}
category
:=
types
.
PbmProfileCategoryEnumREQUIREMENT
ids
,
err
:=
c
.
QueryProfile
(
ctx
,
resourceType
,
string
(
category
))
if
err
!=
nil
{
return
""
,
err
}
profiles
,
err
:=
c
.
RetrieveContent
(
ctx
,
ids
)
if
err
!=
nil
{
return
""
,
err
}
for
i
:=
range
profiles
{
profile
:=
profiles
[
i
]
.
GetPbmProfile
()
if
profile
.
Name
==
profileName
{
return
profile
.
ProfileId
.
UniqueId
,
nil
}
}
return
""
,
fmt
.
Errorf
(
"no pbm profile found with name: %q"
,
profileName
)
}
vendor/github.com/vmware/govmomi/pbm/methods/BUILD
0 → 100644
View file @
23ee1745
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["methods.go"],
tags = ["automanaged"],
deps = [
"//vendor/github.com/vmware/govmomi/pbm/types:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/soap:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
vendor/github.com/vmware/govmomi/pbm/methods/methods.go
0 → 100644
View file @
23ee1745
This diff is collapsed.
Click to expand it.
vendor/github.com/vmware/govmomi/pbm/pbm_util.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
pbm
import
(
"fmt"
"strconv"
"strings"
"github.com/vmware/govmomi/pbm/types"
)
// A struct to capture pbm create spec details.
type
CapabilityProfileCreateSpec
struct
{
Name
string
Description
string
Category
string
CapabilityList
[]
Capability
}
// A struct to capture pbm capability instance details.
type
Capability
struct
{
ID
string
Namespace
string
PropertyList
[]
Property
}
// A struct to capture pbm property instance details.
type
Property
struct
{
ID
string
Operator
string
Value
string
DataType
string
}
func
CreateCapabilityProfileSpec
(
pbmCreateSpec
CapabilityProfileCreateSpec
)
(
*
types
.
PbmCapabilityProfileCreateSpec
,
error
)
{
capabilities
,
err
:=
createCapabilityInstances
(
pbmCreateSpec
.
CapabilityList
)
if
err
!=
nil
{
return
nil
,
err
}
pbmCapabilityProfileSpec
:=
types
.
PbmCapabilityProfileCreateSpec
{
Name
:
pbmCreateSpec
.
Name
,
Description
:
pbmCreateSpec
.
Description
,
Category
:
pbmCreateSpec
.
Category
,
ResourceType
:
types
.
PbmProfileResourceType
{
ResourceType
:
string
(
types
.
PbmProfileResourceTypeEnumSTORAGE
),
},
Constraints
:
&
types
.
PbmCapabilitySubProfileConstraints
{
SubProfiles
:
[]
types
.
PbmCapabilitySubProfile
{
types
.
PbmCapabilitySubProfile
{
Capability
:
capabilities
,
},
},
},
}
return
&
pbmCapabilityProfileSpec
,
nil
}
func
createCapabilityInstances
(
rules
[]
Capability
)
([]
types
.
PbmCapabilityInstance
,
error
)
{
var
capabilityInstances
[]
types
.
PbmCapabilityInstance
for
_
,
capabilityRule
:=
range
rules
{
capability
:=
types
.
PbmCapabilityInstance
{
Id
:
types
.
PbmCapabilityMetadataUniqueId
{
Namespace
:
capabilityRule
.
Namespace
,
Id
:
capabilityRule
.
ID
,
},
}
var
propertyInstances
[]
types
.
PbmCapabilityPropertyInstance
for
_
,
propertyRule
:=
range
capabilityRule
.
PropertyList
{
property
:=
types
.
PbmCapabilityPropertyInstance
{
Id
:
propertyRule
.
ID
,
}
if
propertyRule
.
Operator
!=
""
{
property
.
Operator
=
propertyRule
.
Operator
}
var
err
error
switch
strings
.
ToLower
(
propertyRule
.
DataType
)
{
case
"int"
:
// Go int32 is marshalled to xsi:int whereas Go int is marshalled to xsi:long when sending down the wire.
var
val
int32
val
,
err
=
verifyPropertyValueIsInt
(
propertyRule
.
Value
,
propertyRule
.
DataType
)
property
.
Value
=
val
case
"bool"
:
var
val
bool
val
,
err
=
verifyPropertyValueIsBoolean
(
propertyRule
.
Value
,
propertyRule
.
DataType
)
property
.
Value
=
val
case
"string"
:
property
.
Value
=
propertyRule
.
Value
case
"set"
:
set
:=
types
.
PbmCapabilityDiscreteSet
{}
for
_
,
val
:=
range
strings
.
Split
(
propertyRule
.
Value
,
","
)
{
set
.
Values
=
append
(
set
.
Values
,
val
)
}
property
.
Value
=
set
default
:
return
nil
,
fmt
.
Errorf
(
"invalid value: %q with datatype: %q"
,
propertyRule
.
Value
,
propertyRule
.
Value
)
}
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid value: %q with datatype: %q"
,
propertyRule
.
Value
,
propertyRule
.
Value
)
}
propertyInstances
=
append
(
propertyInstances
,
property
)
}
constraintInstances
:=
[]
types
.
PbmCapabilityConstraintInstance
{
types
.
PbmCapabilityConstraintInstance
{
PropertyInstance
:
propertyInstances
,
},
}
capability
.
Constraint
=
constraintInstances
capabilityInstances
=
append
(
capabilityInstances
,
capability
)
}
return
capabilityInstances
,
nil
}
// Verify if the capability value is of type integer.
func
verifyPropertyValueIsInt
(
propertyValue
string
,
dataType
string
)
(
int32
,
error
)
{
val
,
err
:=
strconv
.
ParseInt
(
propertyValue
,
10
,
32
)
if
err
!=
nil
{
return
-
1
,
err
}
return
int32
(
val
),
nil
}
// Verify if the capability value is of type integer.
func
verifyPropertyValueIsBoolean
(
propertyValue
string
,
dataType
string
)
(
bool
,
error
)
{
val
,
err
:=
strconv
.
ParseBool
(
propertyValue
)
if
err
!=
nil
{
return
false
,
err
}
return
val
,
nil
}
vendor/github.com/vmware/govmomi/pbm/types/BUILD
0 → 100644
View file @
23ee1745
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"enum.go",
"if.go",
"types.go",
],
tags = ["automanaged"],
deps = ["//vendor/github.com/vmware/govmomi/vim25/types:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
vendor/github.com/vmware/govmomi/pbm/types/enum.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2014-2017 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
types
import
(
"reflect"
"github.com/vmware/govmomi/vim25/types"
)
type
PbmBuiltinGenericType
string
const
(
PbmBuiltinGenericTypeVMW_RANGE
=
PbmBuiltinGenericType
(
"VMW_RANGE"
)
PbmBuiltinGenericTypeVMW_SET
=
PbmBuiltinGenericType
(
"VMW_SET"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmBuiltinGenericType"
,
reflect
.
TypeOf
((
*
PbmBuiltinGenericType
)(
nil
))
.
Elem
())
}
type
PbmBuiltinType
string
const
(
PbmBuiltinTypeXSD_LONG
=
PbmBuiltinType
(
"XSD_LONG"
)
PbmBuiltinTypeXSD_SHORT
=
PbmBuiltinType
(
"XSD_SHORT"
)
PbmBuiltinTypeXSD_INTEGER
=
PbmBuiltinType
(
"XSD_INTEGER"
)
PbmBuiltinTypeXSD_INT
=
PbmBuiltinType
(
"XSD_INT"
)
PbmBuiltinTypeXSD_STRING
=
PbmBuiltinType
(
"XSD_STRING"
)
PbmBuiltinTypeXSD_BOOLEAN
=
PbmBuiltinType
(
"XSD_BOOLEAN"
)
PbmBuiltinTypeXSD_DOUBLE
=
PbmBuiltinType
(
"XSD_DOUBLE"
)
PbmBuiltinTypeXSD_DATETIME
=
PbmBuiltinType
(
"XSD_DATETIME"
)
PbmBuiltinTypeVMW_TIMESPAN
=
PbmBuiltinType
(
"VMW_TIMESPAN"
)
PbmBuiltinTypeVMW_POLICY
=
PbmBuiltinType
(
"VMW_POLICY"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmBuiltinType"
,
reflect
.
TypeOf
((
*
PbmBuiltinType
)(
nil
))
.
Elem
())
}
type
PbmCapabilityOperator
string
const
(
PbmCapabilityOperatorNOT
=
PbmCapabilityOperator
(
"NOT"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmCapabilityOperator"
,
reflect
.
TypeOf
((
*
PbmCapabilityOperator
)(
nil
))
.
Elem
())
}
type
PbmCapabilityTimeUnitType
string
const
(
PbmCapabilityTimeUnitTypeSECONDS
=
PbmCapabilityTimeUnitType
(
"SECONDS"
)
PbmCapabilityTimeUnitTypeMINUTES
=
PbmCapabilityTimeUnitType
(
"MINUTES"
)
PbmCapabilityTimeUnitTypeHOURS
=
PbmCapabilityTimeUnitType
(
"HOURS"
)
PbmCapabilityTimeUnitTypeDAYS
=
PbmCapabilityTimeUnitType
(
"DAYS"
)
PbmCapabilityTimeUnitTypeWEEKS
=
PbmCapabilityTimeUnitType
(
"WEEKS"
)
PbmCapabilityTimeUnitTypeMONTHS
=
PbmCapabilityTimeUnitType
(
"MONTHS"
)
PbmCapabilityTimeUnitTypeYEARS
=
PbmCapabilityTimeUnitType
(
"YEARS"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmCapabilityTimeUnitType"
,
reflect
.
TypeOf
((
*
PbmCapabilityTimeUnitType
)(
nil
))
.
Elem
())
}
type
PbmComplianceResultComplianceTaskStatus
string
const
(
PbmComplianceResultComplianceTaskStatusInProgress
=
PbmComplianceResultComplianceTaskStatus
(
"inProgress"
)
PbmComplianceResultComplianceTaskStatusSuccess
=
PbmComplianceResultComplianceTaskStatus
(
"success"
)
PbmComplianceResultComplianceTaskStatusFailed
=
PbmComplianceResultComplianceTaskStatus
(
"failed"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmComplianceResultComplianceTaskStatus"
,
reflect
.
TypeOf
((
*
PbmComplianceResultComplianceTaskStatus
)(
nil
))
.
Elem
())
}
type
PbmComplianceStatus
string
const
(
PbmComplianceStatusCompliant
=
PbmComplianceStatus
(
"compliant"
)
PbmComplianceStatusNonCompliant
=
PbmComplianceStatus
(
"nonCompliant"
)
PbmComplianceStatusUnknown
=
PbmComplianceStatus
(
"unknown"
)
PbmComplianceStatusNotApplicable
=
PbmComplianceStatus
(
"notApplicable"
)
PbmComplianceStatusOutOfDate
=
PbmComplianceStatus
(
"outOfDate"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmComplianceStatus"
,
reflect
.
TypeOf
((
*
PbmComplianceStatus
)(
nil
))
.
Elem
())
}
type
PbmIofilterInfoFilterType
string
const
(
PbmIofilterInfoFilterTypeINSPECTION
=
PbmIofilterInfoFilterType
(
"INSPECTION"
)
PbmIofilterInfoFilterTypeCOMPRESSION
=
PbmIofilterInfoFilterType
(
"COMPRESSION"
)
PbmIofilterInfoFilterTypeENCRYPTION
=
PbmIofilterInfoFilterType
(
"ENCRYPTION"
)
PbmIofilterInfoFilterTypeREPLICATION
=
PbmIofilterInfoFilterType
(
"REPLICATION"
)
PbmIofilterInfoFilterTypeCACHE
=
PbmIofilterInfoFilterType
(
"CACHE"
)
PbmIofilterInfoFilterTypeDATAPROVIDER
=
PbmIofilterInfoFilterType
(
"DATAPROVIDER"
)
PbmIofilterInfoFilterTypeDATASTOREIOCONTROL
=
PbmIofilterInfoFilterType
(
"DATASTOREIOCONTROL"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmIofilterInfoFilterType"
,
reflect
.
TypeOf
((
*
PbmIofilterInfoFilterType
)(
nil
))
.
Elem
())
}
type
PbmLineOfServiceInfoLineOfServiceEnum
string
const
(
PbmLineOfServiceInfoLineOfServiceEnumINSPECTION
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"INSPECTION"
)
PbmLineOfServiceInfoLineOfServiceEnumCOMPRESSION
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"COMPRESSION"
)
PbmLineOfServiceInfoLineOfServiceEnumENCRYPTION
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"ENCRYPTION"
)
PbmLineOfServiceInfoLineOfServiceEnumREPLICATION
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"REPLICATION"
)
PbmLineOfServiceInfoLineOfServiceEnumCACHING
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"CACHING"
)
PbmLineOfServiceInfoLineOfServiceEnumPERSISTENCE
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"PERSISTENCE"
)
PbmLineOfServiceInfoLineOfServiceEnumDATA_PROVIDER
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"DATA_PROVIDER"
)
PbmLineOfServiceInfoLineOfServiceEnumDATASTORE_IO_CONTROL
=
PbmLineOfServiceInfoLineOfServiceEnum
(
"DATASTORE_IO_CONTROL"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmLineOfServiceInfoLineOfServiceEnum"
,
reflect
.
TypeOf
((
*
PbmLineOfServiceInfoLineOfServiceEnum
)(
nil
))
.
Elem
())
}
type
PbmObjectType
string
const
(
PbmObjectTypeVirtualMachine
=
PbmObjectType
(
"virtualMachine"
)
PbmObjectTypeVirtualMachineAndDisks
=
PbmObjectType
(
"virtualMachineAndDisks"
)
PbmObjectTypeVirtualDiskId
=
PbmObjectType
(
"virtualDiskId"
)
PbmObjectTypeVirtualDiskUUID
=
PbmObjectType
(
"virtualDiskUUID"
)
PbmObjectTypeDatastore
=
PbmObjectType
(
"datastore"
)
PbmObjectTypeUnknown
=
PbmObjectType
(
"unknown"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmObjectType"
,
reflect
.
TypeOf
((
*
PbmObjectType
)(
nil
))
.
Elem
())
}
type
PbmProfileCategoryEnum
string
const
(
PbmProfileCategoryEnumREQUIREMENT
=
PbmProfileCategoryEnum
(
"REQUIREMENT"
)
PbmProfileCategoryEnumRESOURCE
=
PbmProfileCategoryEnum
(
"RESOURCE"
)
PbmProfileCategoryEnumDATA_SERVICE_POLICY
=
PbmProfileCategoryEnum
(
"DATA_SERVICE_POLICY"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmProfileCategoryEnum"
,
reflect
.
TypeOf
((
*
PbmProfileCategoryEnum
)(
nil
))
.
Elem
())
}
type
PbmProfileResourceTypeEnum
string
const
(
PbmProfileResourceTypeEnumSTORAGE
=
PbmProfileResourceTypeEnum
(
"STORAGE"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmProfileResourceTypeEnum"
,
reflect
.
TypeOf
((
*
PbmProfileResourceTypeEnum
)(
nil
))
.
Elem
())
}
type
PbmSystemCreatedProfileType
string
const
(
PbmSystemCreatedProfileTypeVsanDefaultProfile
=
PbmSystemCreatedProfileType
(
"VsanDefaultProfile"
)
PbmSystemCreatedProfileTypeVVolDefaultProfile
=
PbmSystemCreatedProfileType
(
"VVolDefaultProfile"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmSystemCreatedProfileType"
,
reflect
.
TypeOf
((
*
PbmSystemCreatedProfileType
)(
nil
))
.
Elem
())
}
type
PbmVmOperation
string
const
(
PbmVmOperationCREATE
=
PbmVmOperation
(
"CREATE"
)
PbmVmOperationRECONFIGURE
=
PbmVmOperation
(
"RECONFIGURE"
)
PbmVmOperationMIGRATE
=
PbmVmOperation
(
"MIGRATE"
)
PbmVmOperationCLONE
=
PbmVmOperation
(
"CLONE"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmVmOperation"
,
reflect
.
TypeOf
((
*
PbmVmOperation
)(
nil
))
.
Elem
())
}
type
PbmVvolType
string
const
(
PbmVvolTypeConfig
=
PbmVvolType
(
"Config"
)
PbmVvolTypeData
=
PbmVvolType
(
"Data"
)
PbmVvolTypeSwap
=
PbmVvolType
(
"Swap"
)
)
func
init
()
{
types
.
Add
(
"pbm:PbmVvolType"
,
reflect
.
TypeOf
((
*
PbmVvolType
)(
nil
))
.
Elem
())
}
vendor/github.com/vmware/govmomi/pbm/types/if.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2014-2017 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
types
import
(
"reflect"
"github.com/vmware/govmomi/vim25/types"
)
func
(
b
*
PbmCapabilityConstraints
)
GetPbmCapabilityConstraints
()
*
PbmCapabilityConstraints
{
return
b
}
type
BasePbmCapabilityConstraints
interface
{
GetPbmCapabilityConstraints
()
*
PbmCapabilityConstraints
}
func
init
()
{
types
.
Add
(
"BasePbmCapabilityConstraints"
,
reflect
.
TypeOf
((
*
PbmCapabilityConstraints
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmCapabilityProfile
)
GetPbmCapabilityProfile
()
*
PbmCapabilityProfile
{
return
b
}
type
BasePbmCapabilityProfile
interface
{
GetPbmCapabilityProfile
()
*
PbmCapabilityProfile
}
func
init
()
{
types
.
Add
(
"BasePbmCapabilityProfile"
,
reflect
.
TypeOf
((
*
PbmCapabilityProfile
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmCapabilityProfilePropertyMismatchFault
)
GetPbmCapabilityProfilePropertyMismatchFault
()
*
PbmCapabilityProfilePropertyMismatchFault
{
return
b
}
type
BasePbmCapabilityProfilePropertyMismatchFault
interface
{
GetPbmCapabilityProfilePropertyMismatchFault
()
*
PbmCapabilityProfilePropertyMismatchFault
}
func
init
()
{
types
.
Add
(
"BasePbmCapabilityProfilePropertyMismatchFault"
,
reflect
.
TypeOf
((
*
PbmCapabilityProfilePropertyMismatchFault
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmCapabilityTypeInfo
)
GetPbmCapabilityTypeInfo
()
*
PbmCapabilityTypeInfo
{
return
b
}
type
BasePbmCapabilityTypeInfo
interface
{
GetPbmCapabilityTypeInfo
()
*
PbmCapabilityTypeInfo
}
func
init
()
{
types
.
Add
(
"BasePbmCapabilityTypeInfo"
,
reflect
.
TypeOf
((
*
PbmCapabilityTypeInfo
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmCompatibilityCheckFault
)
GetPbmCompatibilityCheckFault
()
*
PbmCompatibilityCheckFault
{
return
b
}
type
BasePbmCompatibilityCheckFault
interface
{
GetPbmCompatibilityCheckFault
()
*
PbmCompatibilityCheckFault
}
func
init
()
{
types
.
Add
(
"BasePbmCompatibilityCheckFault"
,
reflect
.
TypeOf
((
*
PbmCompatibilityCheckFault
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmFault
)
GetPbmFault
()
*
PbmFault
{
return
b
}
type
BasePbmFault
interface
{
GetPbmFault
()
*
PbmFault
}
func
init
()
{
types
.
Add
(
"BasePbmFault"
,
reflect
.
TypeOf
((
*
PbmFault
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmLineOfServiceInfo
)
GetPbmLineOfServiceInfo
()
*
PbmLineOfServiceInfo
{
return
b
}
type
BasePbmLineOfServiceInfo
interface
{
GetPbmLineOfServiceInfo
()
*
PbmLineOfServiceInfo
}
func
init
()
{
types
.
Add
(
"BasePbmLineOfServiceInfo"
,
reflect
.
TypeOf
((
*
PbmLineOfServiceInfo
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmPlacementMatchingResources
)
GetPbmPlacementMatchingResources
()
*
PbmPlacementMatchingResources
{
return
b
}
type
BasePbmPlacementMatchingResources
interface
{
GetPbmPlacementMatchingResources
()
*
PbmPlacementMatchingResources
}
func
init
()
{
types
.
Add
(
"BasePbmPlacementMatchingResources"
,
reflect
.
TypeOf
((
*
PbmPlacementMatchingResources
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmPlacementRequirement
)
GetPbmPlacementRequirement
()
*
PbmPlacementRequirement
{
return
b
}
type
BasePbmPlacementRequirement
interface
{
GetPbmPlacementRequirement
()
*
PbmPlacementRequirement
}
func
init
()
{
types
.
Add
(
"BasePbmPlacementRequirement"
,
reflect
.
TypeOf
((
*
PbmPlacementRequirement
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmProfile
)
GetPbmProfile
()
*
PbmProfile
{
return
b
}
type
BasePbmProfile
interface
{
GetPbmProfile
()
*
PbmProfile
}
func
init
()
{
types
.
Add
(
"BasePbmProfile"
,
reflect
.
TypeOf
((
*
PbmProfile
)(
nil
))
.
Elem
())
}
func
(
b
*
PbmPropertyMismatchFault
)
GetPbmPropertyMismatchFault
()
*
PbmPropertyMismatchFault
{
return
b
}
type
BasePbmPropertyMismatchFault
interface
{
GetPbmPropertyMismatchFault
()
*
PbmPropertyMismatchFault
}
func
init
()
{
types
.
Add
(
"BasePbmPropertyMismatchFault"
,
reflect
.
TypeOf
((
*
PbmPropertyMismatchFault
)(
nil
))
.
Elem
())
}
vendor/github.com/vmware/govmomi/pbm/types/types.go
0 → 100644
View file @
23ee1745
This diff is collapsed.
Click to expand it.
vendor/github.com/vmware/govmomi/property/BUILD
View file @
23ee1745
...
...
@@ -11,6 +11,7 @@ go_library(
name = "go_default_library",
srcs = [
"collector.go",
"filter.go",
"wait.go",
],
tags = ["automanaged"],
...
...
vendor/github.com/vmware/govmomi/property/collector.go
View file @
23ee1745
...
...
@@ -164,9 +164,36 @@ func (p *Collector) Retrieve(ctx context.Context, objs []types.ManagedObjectRefe
return
err
}
if
d
,
ok
:=
dst
.
(
*
[]
types
.
ObjectContent
);
ok
{
*
d
=
res
.
Returnval
return
nil
}
return
mo
.
LoadRetrievePropertiesResponse
(
res
,
dst
)
}
// RetrieveWithFilter populates dst as Retrieve does, but only for entities matching the given filter.
func
(
p
*
Collector
)
RetrieveWithFilter
(
ctx
context
.
Context
,
objs
[]
types
.
ManagedObjectReference
,
ps
[]
string
,
dst
interface
{},
filter
Filter
)
error
{
if
len
(
filter
)
==
0
{
return
p
.
Retrieve
(
ctx
,
objs
,
ps
,
dst
)
}
var
content
[]
types
.
ObjectContent
err
:=
p
.
Retrieve
(
ctx
,
objs
,
filter
.
Keys
(),
&
content
)
if
err
!=
nil
{
return
err
}
objs
=
filter
.
MatchObjectContent
(
content
)
if
len
(
objs
)
==
0
{
return
nil
}
return
p
.
Retrieve
(
ctx
,
objs
,
ps
,
dst
)
}
// RetrieveOne calls Retrieve with a single managed object reference.
func
(
p
*
Collector
)
RetrieveOne
(
ctx
context
.
Context
,
obj
types
.
ManagedObjectReference
,
ps
[]
string
,
dst
interface
{})
error
{
var
objs
=
[]
types
.
ManagedObjectReference
{
obj
}
...
...
vendor/github.com/vmware/govmomi/property/filter.go
0 → 100644
View file @
23ee1745
/*
Copyright (c) 2017 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
property
import
(
"fmt"
"path/filepath"
"reflect"
"strconv"
"strings"
"github.com/vmware/govmomi/vim25/types"
)
// Filter provides methods for matching against types.DynamicProperty
type
Filter
map
[
string
]
types
.
AnyType
// Keys returns the Filter map keys as a []string
func
(
f
Filter
)
Keys
()
[]
string
{
keys
:=
make
([]
string
,
0
,
len
(
f
))
for
key
:=
range
f
{
keys
=
append
(
keys
,
key
)
}
return
keys
}
// MatchProperty returns true if a Filter entry matches the given prop.
func
(
f
Filter
)
MatchProperty
(
prop
types
.
DynamicProperty
)
bool
{
match
,
ok
:=
f
[
prop
.
Name
]
if
!
ok
{
return
false
}
if
match
==
prop
.
Val
{
return
true
}
ptype
:=
reflect
.
TypeOf
(
prop
.
Val
)
if
strings
.
HasPrefix
(
ptype
.
Name
(),
"ArrayOf"
)
{
pval
:=
reflect
.
ValueOf
(
prop
.
Val
)
.
Field
(
0
)
for
i
:=
0
;
i
<
pval
.
Len
();
i
++
{
prop
.
Val
=
pval
.
Index
(
i
)
.
Interface
()
if
f
.
MatchProperty
(
prop
)
{
return
true
}
}
return
false
}
if
reflect
.
TypeOf
(
match
)
!=
ptype
{
s
,
ok
:=
match
.
(
string
)
if
!
ok
{
return
false
}
// convert if we can
switch
prop
.
Val
.
(
type
)
{
case
bool
:
match
,
_
=
strconv
.
ParseBool
(
s
)
case
int16
:
x
,
_
:=
strconv
.
ParseInt
(
s
,
10
,
16
)
match
=
int16
(
x
)
case
int32
:
x
,
_
:=
strconv
.
ParseInt
(
s
,
10
,
32
)
match
=
int32
(
x
)
case
int64
:
match
,
_
=
strconv
.
ParseInt
(
s
,
10
,
64
)
case
float32
:
x
,
_
:=
strconv
.
ParseFloat
(
s
,
32
)
match
=
float32
(
x
)
case
float64
:
match
,
_
=
strconv
.
ParseFloat
(
s
,
64
)
case
fmt
.
Stringer
:
prop
.
Val
=
prop
.
Val
.
(
fmt
.
Stringer
)
.
String
()
default
:
if
ptype
.
Kind
()
!=
reflect
.
String
{
return
false
}
// An enum type we can convert to a string type
prop
.
Val
=
reflect
.
ValueOf
(
prop
.
Val
)
.
String
()
}
}
switch
pval
:=
prop
.
Val
.
(
type
)
{
case
string
:
m
,
_
:=
filepath
.
Match
(
match
.
(
string
),
pval
)
return
m
default
:
return
reflect
.
DeepEqual
(
match
,
pval
)
}
}
// MatchPropertyList returns true if all given props match the Filter.
func
(
f
Filter
)
MatchPropertyList
(
props
[]
types
.
DynamicProperty
)
bool
{
for
_
,
p
:=
range
props
{
if
!
f
.
MatchProperty
(
p
)
{
return
false
}
}
return
true
}
// MatchObjectContent returns a list of ObjectContent.Obj where the ObjectContent.PropSet matches the Filter.
func
(
f
Filter
)
MatchObjectContent
(
objects
[]
types
.
ObjectContent
)
[]
types
.
ManagedObjectReference
{
var
refs
[]
types
.
ManagedObjectReference
for
_
,
o
:=
range
objects
{
if
f
.
MatchPropertyList
(
o
.
PropSet
)
{
refs
=
append
(
refs
,
o
.
Obj
)
}
}
return
refs
}
vendor/github.com/vmware/govmomi/task/wait.go
View file @
23ee1745
...
...
@@ -68,6 +68,11 @@ func (t *taskCallback) fn(pc []types.PropertyChange) bool {
t
.
info
=
&
ti
}
// t.info could be nil if pc can't satify the rules above
if
t
.
info
==
nil
{
return
false
}
pr
:=
taskProgress
{
t
.
info
}
// Store copy of error, so Wait() can return it as well.
...
...
vendor/github.com/vmware/govmomi/vim25/methods/methods.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
...
...
vendor/github.com/vmware/govmomi/vim25/mo/ancestors.go
View file @
23ee1745
...
...
@@ -104,6 +104,8 @@ func Ancestors(ctx context.Context, rt soap.RoundTripper, pc, obj types.ManagedO
me
.
Name
=
x
.
Name
case
DistributedVirtualPortgroup
:
me
.
Name
=
x
.
Name
case
OpaqueNetwork
:
me
.
Name
=
x
.
Name
default
:
// ManagedEntity always has a Name, if we hit this point we missed a case above.
panic
(
fmt
.
Sprintf
(
"%#v Name is empty"
,
me
.
Reference
()))
...
...
vendor/github.com/vmware/govmomi/vim25/mo/mo.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
...
...
@@ -150,6 +150,30 @@ func init() {
t
[
"ContainerView"
]
=
reflect
.
TypeOf
((
*
ContainerView
)(
nil
))
.
Elem
()
}
type
CryptoManager
struct
{
Self
types
.
ManagedObjectReference
Enabled
bool
`mo:"enabled"`
}
func
(
m
CryptoManager
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"CryptoManager"
]
=
reflect
.
TypeOf
((
*
CryptoManager
)(
nil
))
.
Elem
()
}
type
CryptoManagerKmip
struct
{
CryptoManager
KmipServers
[]
types
.
KmipClusterInfo
`mo:"kmipServers"`
}
func
init
()
{
t
[
"CryptoManagerKmip"
]
=
reflect
.
TypeOf
((
*
CryptoManagerKmip
)(
nil
))
.
Elem
()
}
type
CustomFieldsManager
struct
{
Self
types
.
ManagedObjectReference
...
...
@@ -356,6 +380,34 @@ func init() {
t
[
"ExtensionManager"
]
=
reflect
.
TypeOf
((
*
ExtensionManager
)(
nil
))
.
Elem
()
}
type
FailoverClusterConfigurator
struct
{
Self
types
.
ManagedObjectReference
DisabledConfigureMethod
[]
string
`mo:"disabledConfigureMethod"`
}
func
(
m
FailoverClusterConfigurator
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"FailoverClusterConfigurator"
]
=
reflect
.
TypeOf
((
*
FailoverClusterConfigurator
)(
nil
))
.
Elem
()
}
type
FailoverClusterManager
struct
{
Self
types
.
ManagedObjectReference
DisabledClusterMethod
[]
string
`mo:"disabledClusterMethod"`
}
func
(
m
FailoverClusterManager
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"FailoverClusterManager"
]
=
reflect
.
TypeOf
((
*
FailoverClusterManager
)(
nil
))
.
Elem
()
}
type
FileManager
struct
{
Self
types
.
ManagedObjectReference
}
...
...
@@ -461,6 +513,18 @@ func init() {
t
[
"GuestWindowsRegistryManager"
]
=
reflect
.
TypeOf
((
*
GuestWindowsRegistryManager
)(
nil
))
.
Elem
()
}
type
HealthUpdateManager
struct
{
Self
types
.
ManagedObjectReference
}
func
(
m
HealthUpdateManager
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"HealthUpdateManager"
]
=
reflect
.
TypeOf
((
*
HealthUpdateManager
)(
nil
))
.
Elem
()
}
type
HistoryCollector
struct
{
Self
types
.
ManagedObjectReference
...
...
@@ -695,8 +759,9 @@ func init() {
type
HostGraphicsManager
struct
{
ExtensibleManagedObject
GraphicsInfo
[]
types
.
HostGraphicsInfo
`mo:"graphicsInfo"`
SharedPassthruGpuTypes
[]
string
`mo:"sharedPassthruGpuTypes"`
GraphicsInfo
[]
types
.
HostGraphicsInfo
`mo:"graphicsInfo"`
GraphicsConfig
*
types
.
HostGraphicsConfig
`mo:"graphicsConfig"`
SharedPassthruGpuTypes
[]
string
`mo:"sharedPassthruGpuTypes"`
}
func
init
()
{
...
...
@@ -803,7 +868,8 @@ func init() {
type
HostPciPassthruSystem
struct
{
ExtensibleManagedObject
PciPassthruInfo
[]
types
.
BaseHostPciPassthruInfo
`mo:"pciPassthruInfo"`
PciPassthruInfo
[]
types
.
BaseHostPciPassthruInfo
`mo:"pciPassthruInfo"`
SriovDevicePoolInfo
[]
types
.
BaseHostSriovDevicePoolInfo
`mo:"sriovDevicePoolInfo"`
}
func
init
()
{
...
...
@@ -868,6 +934,18 @@ func init() {
t
[
"HostSnmpSystem"
]
=
reflect
.
TypeOf
((
*
HostSnmpSystem
)(
nil
))
.
Elem
()
}
type
HostSpecificationManager
struct
{
Self
types
.
ManagedObjectReference
}
func
(
m
HostSpecificationManager
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"HostSpecificationManager"
]
=
reflect
.
TypeOf
((
*
HostSpecificationManager
)(
nil
))
.
Elem
()
}
type
HostStorageSystem
struct
{
ExtensibleManagedObject
...
...
@@ -931,6 +1009,14 @@ func init() {
t
[
"HostVMotionSystem"
]
=
reflect
.
TypeOf
((
*
HostVMotionSystem
)(
nil
))
.
Elem
()
}
type
HostVStorageObjectManager
struct
{
VStorageObjectManagerBase
}
func
init
()
{
t
[
"HostVStorageObjectManager"
]
=
reflect
.
TypeOf
((
*
HostVStorageObjectManager
)(
nil
))
.
Elem
()
}
type
HostVirtualNicManager
struct
{
ExtensibleManagedObject
...
...
@@ -984,18 +1070,6 @@ func init() {
t
[
"HttpNfcLease"
]
=
reflect
.
TypeOf
((
*
HttpNfcLease
)(
nil
))
.
Elem
()
}
type
InternalDynamicTypeManager
struct
{
Self
types
.
ManagedObjectReference
}
func
(
m
InternalDynamicTypeManager
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"InternalDynamicTypeManager"
]
=
reflect
.
TypeOf
((
*
InternalDynamicTypeManager
)(
nil
))
.
Elem
()
}
type
InventoryView
struct
{
ManagedObjectView
}
...
...
@@ -1163,6 +1237,9 @@ func init() {
type
OpaqueNetwork
struct
{
Network
Capability
*
types
.
OpaqueNetworkCapability
`mo:"capability"`
ExtraConfig
[]
types
.
BaseOptionValue
`mo:"extraConfig"`
}
func
init
()
{
...
...
@@ -1302,18 +1379,6 @@ func init() {
t
[
"PropertyFilter"
]
=
reflect
.
TypeOf
((
*
PropertyFilter
)(
nil
))
.
Elem
()
}
type
ReflectManagedMethodExecuter
struct
{
Self
types
.
ManagedObjectReference
}
func
(
m
ReflectManagedMethodExecuter
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"ReflectManagedMethodExecuter"
]
=
reflect
.
TypeOf
((
*
ReflectManagedMethodExecuter
)(
nil
))
.
Elem
()
}
type
ResourcePlanningManager
struct
{
Self
types
.
ManagedObjectReference
}
...
...
@@ -1520,6 +1585,26 @@ func init() {
t
[
"UserDirectory"
]
=
reflect
.
TypeOf
((
*
UserDirectory
)(
nil
))
.
Elem
()
}
type
VStorageObjectManagerBase
struct
{
Self
types
.
ManagedObjectReference
}
func
(
m
VStorageObjectManagerBase
)
Reference
()
types
.
ManagedObjectReference
{
return
m
.
Self
}
func
init
()
{
t
[
"VStorageObjectManagerBase"
]
=
reflect
.
TypeOf
((
*
VStorageObjectManagerBase
)(
nil
))
.
Elem
()
}
type
VcenterVStorageObjectManager
struct
{
VStorageObjectManagerBase
}
func
init
()
{
t
[
"VcenterVStorageObjectManager"
]
=
reflect
.
TypeOf
((
*
VcenterVStorageObjectManager
)(
nil
))
.
Elem
()
}
type
View
struct
{
Self
types
.
ManagedObjectReference
}
...
...
vendor/github.com/vmware/govmomi/vim25/soap/client.go
View file @
23ee1745
...
...
@@ -58,6 +58,10 @@ const (
DefaultMinVimVersion
=
"5.5"
)
type
header
struct
{
Cookie
string
`xml:"vcSessionCookie,omitempty"`
}
type
Client
struct
{
http
.
Client
...
...
@@ -73,6 +77,8 @@ type Client struct {
Namespace
string
// Vim namespace
Version
string
// Vim version
UserAgent
string
header
*
header
}
var
schemeMatch
=
regexp
.
MustCompile
(
`^\w+://`
)
...
...
@@ -147,6 +153,32 @@ func NewClient(u *url.URL, insecure bool) *Client {
return
&
c
}
// NewServiceClient creates a NewClient with the given URL.Path and namespace.
func
(
c
*
Client
)
NewServiceClient
(
path
string
,
namespace
string
)
*
Client
{
u
:=
c
.
URL
()
u
.
Path
=
path
client
:=
NewClient
(
u
,
c
.
k
)
client
.
Namespace
=
namespace
// Copy the cookies
client
.
Client
.
Jar
.
SetCookies
(
u
,
c
.
Client
.
Jar
.
Cookies
(
u
))
// Set SOAP Header cookie
for
_
,
cookie
:=
range
client
.
Jar
.
Cookies
(
u
)
{
if
cookie
.
Name
==
"vmware_soap_session"
{
client
.
header
=
&
header
{
Cookie
:
cookie
.
Value
,
}
break
}
}
return
client
}
// SetRootCAs defines the set of root certificate authorities
// that clients use when verifying server certificates.
// By default TLS uses the host's root CA set.
...
...
@@ -401,6 +433,8 @@ func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error
reqEnv
:=
Envelope
{
Body
:
reqBody
}
resEnv
:=
Envelope
{
Body
:
resBody
}
reqEnv
.
Header
=
c
.
header
// Create debugging context for this round trip
d
:=
c
.
d
.
newRoundTrip
()
if
d
.
enabled
()
{
...
...
vendor/github.com/vmware/govmomi/vim25/soap/error.go
View file @
23ee1745
...
...
@@ -36,7 +36,13 @@ type soapFaultError struct {
}
func
(
s
soapFaultError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"%s: %s"
,
s
.
fault
.
Code
,
s
.
fault
.
String
)
msg
:=
s
.
fault
.
String
if
msg
==
""
{
msg
=
reflect
.
TypeOf
(
s
.
fault
.
Detail
.
Fault
)
.
Name
()
}
return
fmt
.
Sprintf
(
"%s: %s"
,
s
.
fault
.
Code
,
msg
)
}
type
vimFaultError
struct
{
...
...
vendor/github.com/vmware/govmomi/vim25/soap/soap.go
View file @
23ee1745
...
...
@@ -22,15 +22,11 @@ import (
)
type
Envelope
struct
{
XMLName
xml
.
Name
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Header
*
Header
`xml:",omitempty"`
XMLName
xml
.
Name
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Header
interface
{}
`xml:",omitempty"`
Body
interface
{}
}
type
Header
struct
{
XMLName
xml
.
Name
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"`
}
type
Fault
struct
{
XMLName
xml
.
Name
`xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
Code
string
`xml:"faultcode"`
...
...
vendor/github.com/vmware/govmomi/vim25/types/enum.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
...
...
vendor/github.com/vmware/govmomi/vim25/types/helpers.go
View file @
23ee1745
...
...
@@ -46,3 +46,7 @@ func (r *ManagedObjectReference) FromString(o string) bool {
return
true
}
func
(
c
*
PerfCounterInfo
)
Name
()
string
{
return
c
.
GroupInfo
.
GetElementDescription
()
.
Key
+
"."
+
c
.
NameInfo
.
GetElementDescription
()
.
Key
+
"."
+
string
(
c
.
RollupType
)
}
vendor/github.com/vmware/govmomi/vim25/types/if.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
...
...
vendor/github.com/vmware/govmomi/vim25/types/registry.go
View file @
23ee1745
...
...
@@ -16,15 +16,28 @@ limitations under the License.
package
types
import
"reflect"
import
(
"reflect"
"strings"
)
var
t
=
map
[
string
]
reflect
.
Type
{}
func
Add
(
name
string
,
kind
reflect
.
Type
)
{
t
[
name
]
=
kind
}
type
Func
func
(
string
)
(
reflect
.
Type
,
bool
)
func
TypeFunc
()
Func
{
return
func
(
name
string
)
(
reflect
.
Type
,
bool
)
{
typ
,
ok
:=
t
[
name
]
if
!
ok
{
// The /sdk endpoint does not prefix types with the namespace,
// but extension endpoints, such as /pbm/sdk do.
name
=
strings
.
TrimPrefix
(
name
,
"vim25:"
)
typ
,
ok
=
t
[
name
]
}
return
typ
,
ok
}
}
vendor/github.com/vmware/govmomi/vim25/types/types.go
View file @
23ee1745
/*
Copyright (c) 2014-201
6
VMware, Inc. All Rights Reserved.
Copyright (c) 2014-201
7
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.
vendor/github.com/vmware/govmomi/vim25/xml/extras.go
View file @
23ee1745
...
...
@@ -23,6 +23,8 @@ import (
var
xmlSchemaInstance
=
Name
{
Space
:
"http://www.w3.org/2001/XMLSchema-instance"
,
Local
:
"type"
}
var
xsiType
=
Name
{
Space
:
"xsi"
,
Local
:
"type"
}
var
stringToTypeMap
=
map
[
string
]
reflect
.
Type
{
"xsd:boolean"
:
reflect
.
TypeOf
((
*
bool
)(
nil
))
.
Elem
(),
"xsd:byte"
:
reflect
.
TypeOf
((
*
int8
)(
nil
))
.
Elem
(),
...
...
vendor/github.com/vmware/govmomi/vim25/xml/read.go
View file @
23ee1745
...
...
@@ -272,13 +272,15 @@ var (
func
(
p
*
Decoder
)
typeForElement
(
val
reflect
.
Value
,
start
*
StartElement
)
reflect
.
Type
{
t
:=
""
for
i
,
a
:=
range
start
.
Attr
{
if
a
.
Name
==
xmlSchemaInstance
{
if
a
.
Name
==
xmlSchemaInstance
||
a
.
Name
==
xsiType
{
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.
// Note: govmomi uses xmlSchemaInstance, other clients (e.g. rbvmomi) use xsiType.
// They are the same thing to XML parsers, but not to this hack here.
x
:=
len
(
start
.
Attr
)
-
1
if
i
!=
x
{
start
.
Attr
[
i
]
=
start
.
Attr
[
x
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment