Get plugin up to parity with v1.5.0. Remove custom jetbrains-internal testing logic; disable acceptance tests (for now) until we can set up a test rig inside of HashiCorp. Regenerate code based on vendoring changes.
This commit is contained in:
parent
073eda76aa
commit
e87aa237dd
|
@ -1,2 +0,0 @@
|
|||
*.iml
|
||||
target/
|
|
@ -1,104 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>PackerVSphere Config DSL Script</name>
|
||||
<groupId>PackerVSphere</groupId>
|
||||
<artifactId>PackerVSphere_dsl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>https://download.jetbrains.com/teamcity-repository</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>teamcity-server</id>
|
||||
<url>https://teamcity.jetbrains.com/app/dsl-plugins-repository</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>JetBrains</id>
|
||||
<url>https://download.jetbrains.com/teamcity-repository</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>.</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<configuration/>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>process-test-sources</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>teamcity-configs-maven-plugin</artifactId>
|
||||
<version>${teamcity.dsl.version}</version>
|
||||
<configuration>
|
||||
<format>kotlin</format>
|
||||
<dstDir>target/generated-configs</dstDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin</artifactId>
|
||||
<version>${teamcity.dsl.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin-plugins</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-runtime</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,137 +0,0 @@
|
|||
import jetbrains.buildServer.configs.kotlin.v2018_2.*
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.PullRequests
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.commitStatusPublisher
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.pullRequests
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dockerCompose
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.script
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.triggers.vcs
|
||||
import jetbrains.buildServer.configs.kotlin.v2018_2.vcs.GitVcsRoot
|
||||
|
||||
version = "2018.2"
|
||||
|
||||
project {
|
||||
description = "https://github.com/jetbrains-infra/packer-builder-vsphere"
|
||||
|
||||
vcsRoot(GitHub)
|
||||
buildType(Build)
|
||||
|
||||
features {
|
||||
feature {
|
||||
type = "OAuthProvider"
|
||||
param("providerType", "GitHub")
|
||||
param("displayName", "GitHub.com")
|
||||
param("gitHubUrl", "https://github.com/")
|
||||
param("clientId", "1abfd46417d7795298a1")
|
||||
param("secure:clientSecret", "credentialsJSON:5fe99dc3-4d1d-4fd6-9f5c-e87fbcbd9a4e")
|
||||
param("defaultTokenScope", "public_repo,repo,repo:status,write:repo_hook")
|
||||
}
|
||||
feature {
|
||||
type = "IssueTracker"
|
||||
param("name", "packer-builder-vsphere")
|
||||
param("type", "GithubIssues")
|
||||
param("repository", "https://github.com/jetbrains-infra/packer-builder-vsphere")
|
||||
param("authType", "anonymous")
|
||||
param("pattern", """#(\d+)""")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object GitHub : GitVcsRoot({
|
||||
name = "packer-builder-vsphere"
|
||||
url = "https://github.com/jetbrains-infra/packer-builder-vsphere"
|
||||
branch = "master"
|
||||
branchSpec = "+:refs/heads/(*)"
|
||||
userNameStyle = GitVcsRoot.UserNameStyle.FULL
|
||||
})
|
||||
|
||||
object Build : BuildType({
|
||||
val golangImage = "jetbrainsinfra/golang:1.11.4"
|
||||
|
||||
name = "Build"
|
||||
|
||||
vcs {
|
||||
root(GitHub)
|
||||
}
|
||||
|
||||
requirements {
|
||||
equals("docker.server.osType", "linux")
|
||||
exists("dockerCompose.version")
|
||||
|
||||
doesNotContain("teamcity.agent.name", "ubuntu-single-build")
|
||||
}
|
||||
|
||||
params {
|
||||
param("env.GOPATH", "%teamcity.build.checkoutDir%/build/modules")
|
||||
param("env.GOCACHE", "%teamcity.build.checkoutDir%/build/cache")
|
||||
|
||||
password("env.VPN_PASSWORD", "credentialsJSON:8c355e81-9a26-4788-8fea-c854cd646c35")
|
||||
param ("env.VSPHERE_USERNAME", """vsphere65.test\teamcity""")
|
||||
password("env.VSPHERE_PASSWORD", "credentialsJSON:d5e7ac7f-357b-464a-b2fa-ddd4c433b22b")
|
||||
}
|
||||
|
||||
steps {
|
||||
script {
|
||||
name = "Build"
|
||||
scriptContent = "make build -j 3"
|
||||
dockerImage = golangImage
|
||||
dockerPull = true
|
||||
}
|
||||
|
||||
dockerCompose {
|
||||
name = "Start VPN tunnel"
|
||||
file = "teamcity-services.yml"
|
||||
}
|
||||
|
||||
script {
|
||||
name = "Test"
|
||||
scriptContent = "make test | go-test-teamcity"
|
||||
dockerImage = golangImage
|
||||
dockerPull = true
|
||||
dockerRunParameters = "--network=container:vpn"
|
||||
}
|
||||
script {
|
||||
name = "gofmt"
|
||||
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
|
||||
scriptContent = "./gofmt.sh"
|
||||
dockerImage = golangImage
|
||||
dockerPull = true
|
||||
}
|
||||
}
|
||||
|
||||
features {
|
||||
commitStatusPublisher {
|
||||
publisher = github {
|
||||
githubUrl = "https://api.github.com"
|
||||
authType = personalToken {
|
||||
token = "credentialsJSON:5ead3bb1-c370-4589-beb8-24f8d02c36bc"
|
||||
}
|
||||
}
|
||||
}
|
||||
pullRequests {
|
||||
provider = github {
|
||||
authType = token {
|
||||
token = "credentialsJSON:5ead3bb1-c370-4589-beb8-24f8d02c36bc"
|
||||
}
|
||||
filterAuthorRole = PullRequests.GitHubRoleFilter.EVERYBODY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
triggers {
|
||||
vcs {
|
||||
triggerRules = """
|
||||
-:*.md
|
||||
-:.teamcity/
|
||||
""".trimIndent()
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:temp-*
|
||||
-:pull/*
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
maxRunningBuilds = 2
|
||||
|
||||
artifactRules = "bin/* => packer-builder-vsphere-%build.number%.zip"
|
||||
allowExternalStatus = true
|
||||
})
|
|
@ -2,6 +2,7 @@ package clone
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/hashicorp/packer/builder/vsphere/common"
|
||||
"github.com/hashicorp/packer/builder/vsphere/driver"
|
||||
packerCommon "github.com/hashicorp/packer/common"
|
||||
|
@ -15,14 +16,16 @@ type Builder struct {
|
|||
runner multistep.Runner
|
||||
}
|
||||
|
||||
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }
|
||||
|
||||
func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
||||
c, warnings, errs := NewConfig(raws...)
|
||||
if errs != nil {
|
||||
return warnings, errs
|
||||
return warnings, nil, errs
|
||||
}
|
||||
b.config = c
|
||||
|
||||
return warnings, nil
|
||||
return warnings, nil, nil
|
||||
}
|
||||
|
||||
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCloneBuilderAcc_default(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
config := defaultConfig()
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
|
@ -101,6 +102,7 @@ func checkDefault(t *testing.T, name string, host string, datastore string) buil
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_artifact(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
config := defaultConfig()
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
|
@ -126,6 +128,7 @@ func checkArtifact(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_folder(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: folderConfig(),
|
||||
|
@ -163,6 +166,7 @@ func checkFolder(t *testing.T, folder string) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_resourcePool(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: resourcePoolConfig(),
|
||||
|
@ -200,6 +204,7 @@ func checkResourcePool(t *testing.T, pool string) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_datastore(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: datastoreConfig(),
|
||||
|
@ -259,6 +264,7 @@ func multipleDatastoresConfig() string {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_fullClone(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: fullCloneConfig(),
|
||||
|
@ -291,6 +297,7 @@ func checkFullClone(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_linkedClone(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: linkedCloneConfig(),
|
||||
|
@ -323,6 +330,7 @@ func checkLinkedClone(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_network(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: networkConfig(),
|
||||
|
@ -368,6 +376,7 @@ func checkNetwork(t *testing.T, name string) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_hardware(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: hardwareConfig(),
|
||||
|
@ -457,6 +466,7 @@ func checkHardware(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_RAMReservation(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: RAMReservationConfig(),
|
||||
|
@ -490,6 +500,7 @@ func checkRAMReservation(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_sshPassword(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: sshPasswordConfig(),
|
||||
|
@ -525,6 +536,7 @@ func checkDefaultBootOrder(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_sshKey(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: sshKeyConfig(),
|
||||
|
@ -540,6 +552,7 @@ func sshKeyConfig() string {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_snapshot(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: snapshotConfig(),
|
||||
|
@ -574,6 +587,7 @@ func checkSnapshot(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_template(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: templateConfig(),
|
||||
|
@ -606,6 +620,7 @@ func checkTemplate(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_bootOrder(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: bootOrderConfig(),
|
||||
|
@ -644,6 +659,7 @@ func checkBootOrder(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_notes(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: notesConfig(),
|
||||
|
@ -678,6 +694,7 @@ func checkNotes(t *testing.T) builderT.TestCheckFunc {
|
|||
}
|
||||
|
||||
func TestCloneBuilderAcc_windows(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
t.Skip("test is too slow")
|
||||
config := windowsConfig()
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//go:generate struct-markdown
|
||||
//go:generate mapstructure-to-hcl2 -type ShutdownConfig
|
||||
//go:generate mapstructure-to-hcl2 -type Config
|
||||
|
||||
package clone
|
||||
|
||||
|
|
|
@ -1,7 +1,192 @@
|
|||
// Code generated by "mapstructure-to-hcl2 -type ShutdownConfig"; DO NOT EDIT.
|
||||
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
|
||||
package clone
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||
type FlatConfig struct {
|
||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||
VCenterServer *string `mapstructure:"vcenter_server" cty:"vcenter_server"`
|
||||
Username *string `mapstructure:"username" cty:"username"`
|
||||
Password *string `mapstructure:"password" cty:"password"`
|
||||
InsecureConnection *bool `mapstructure:"insecure_connection" cty:"insecure_connection"`
|
||||
Datacenter *string `mapstructure:"datacenter" cty:"datacenter"`
|
||||
Template *string `mapstructure:"template" cty:"template"`
|
||||
DiskSize *int64 `mapstructure:"disk_size" cty:"disk_size"`
|
||||
LinkedClone *bool `mapstructure:"linked_clone" cty:"linked_clone"`
|
||||
Network *string `mapstructure:"network" cty:"network"`
|
||||
Notes *string `mapstructure:"notes" cty:"notes"`
|
||||
VMName *string `mapstructure:"vm_name" cty:"vm_name"`
|
||||
Folder *string `mapstructure:"folder" cty:"folder"`
|
||||
Cluster *string `mapstructure:"cluster" cty:"cluster"`
|
||||
Host *string `mapstructure:"host" cty:"host"`
|
||||
ResourcePool *string `mapstructure:"resource_pool" cty:"resource_pool"`
|
||||
Datastore *string `mapstructure:"datastore" cty:"datastore"`
|
||||
CPUs *int32 `mapstructure:"CPUs" cty:"CPUs"`
|
||||
CpuCores *int32 `mapstructure:"cpu_cores" cty:"cpu_cores"`
|
||||
CPUReservation *int64 `mapstructure:"CPU_reservation" cty:"CPU_reservation"`
|
||||
CPULimit *int64 `mapstructure:"CPU_limit" cty:"CPU_limit"`
|
||||
CpuHotAddEnabled *bool `mapstructure:"CPU_hot_plug" cty:"CPU_hot_plug"`
|
||||
RAM *int64 `mapstructure:"RAM" cty:"RAM"`
|
||||
RAMReservation *int64 `mapstructure:"RAM_reservation" cty:"RAM_reservation"`
|
||||
RAMReserveAll *bool `mapstructure:"RAM_reserve_all" cty:"RAM_reserve_all"`
|
||||
MemoryHotAddEnabled *bool `mapstructure:"RAM_hot_plug" cty:"RAM_hot_plug"`
|
||||
VideoRAM *int64 `mapstructure:"video_ram" cty:"video_ram"`
|
||||
NestedHV *bool `mapstructure:"NestedHV" cty:"NestedHV"`
|
||||
ConfigParams map[string]string `mapstructure:"configuration_parameters" cty:"configuration_parameters"`
|
||||
BootOrder *string `mapstructure:"boot_order" cty:"boot_order"`
|
||||
WaitTimeout *string `mapstructure:"ip_wait_timeout" cty:"ip_wait_timeout"`
|
||||
SettleTimeout *string `mapstructure:"ip_settle_timeout" cty:"ip_settle_timeout"`
|
||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||
Command *string `mapstructure:"shutdown_command" cty:"shutdown_command"`
|
||||
Timeout *string `mapstructure:"shutdown_timeout" cty:"shutdown_timeout"`
|
||||
CreateSnapshot *bool `mapstructure:"create_snapshot" cty:"create_snapshot"`
|
||||
ConvertToTemplate *bool `mapstructure:"convert_to_template" cty:"convert_to_template"`
|
||||
}
|
||||
|
||||
// FlatMapstructure returns a new FlatConfig.
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||
func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||
return new(FlatConfig)
|
||||
}
|
||||
|
||||
// HCL2Spec returns the hcl spec of a Config.
|
||||
// This spec is used by HCL to read the fields of Config.
|
||||
// The decoded values from this spec will then be applied to a FlatConfig.
|
||||
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||
s := map[string]hcldec.Spec{
|
||||
"packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false},
|
||||
"packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false},
|
||||
"packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false},
|
||||
"packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false},
|
||||
"packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false},
|
||||
"packer_user_variables": &hcldec.BlockAttrsSpec{TypeName: "packer_user_variables", ElementType: cty.String, Required: false},
|
||||
"packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false},
|
||||
"vcenter_server": &hcldec.AttrSpec{Name: "vcenter_server", Type: cty.String, Required: false},
|
||||
"username": &hcldec.AttrSpec{Name: "username", Type: cty.String, Required: false},
|
||||
"password": &hcldec.AttrSpec{Name: "password", Type: cty.String, Required: false},
|
||||
"insecure_connection": &hcldec.AttrSpec{Name: "insecure_connection", Type: cty.Bool, Required: false},
|
||||
"datacenter": &hcldec.AttrSpec{Name: "datacenter", Type: cty.String, Required: false},
|
||||
"template": &hcldec.AttrSpec{Name: "template", Type: cty.String, Required: false},
|
||||
"disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false},
|
||||
"linked_clone": &hcldec.AttrSpec{Name: "linked_clone", Type: cty.Bool, Required: false},
|
||||
"network": &hcldec.AttrSpec{Name: "network", Type: cty.String, Required: false},
|
||||
"notes": &hcldec.AttrSpec{Name: "notes", Type: cty.String, Required: false},
|
||||
"vm_name": &hcldec.AttrSpec{Name: "vm_name", Type: cty.String, Required: false},
|
||||
"folder": &hcldec.AttrSpec{Name: "folder", Type: cty.String, Required: false},
|
||||
"cluster": &hcldec.AttrSpec{Name: "cluster", Type: cty.String, Required: false},
|
||||
"host": &hcldec.AttrSpec{Name: "host", Type: cty.String, Required: false},
|
||||
"resource_pool": &hcldec.AttrSpec{Name: "resource_pool", Type: cty.String, Required: false},
|
||||
"datastore": &hcldec.AttrSpec{Name: "datastore", Type: cty.String, Required: false},
|
||||
"CPUs": &hcldec.AttrSpec{Name: "CPUs", Type: cty.Number, Required: false},
|
||||
"cpu_cores": &hcldec.AttrSpec{Name: "cpu_cores", Type: cty.Number, Required: false},
|
||||
"CPU_reservation": &hcldec.AttrSpec{Name: "CPU_reservation", Type: cty.Number, Required: false},
|
||||
"CPU_limit": &hcldec.AttrSpec{Name: "CPU_limit", Type: cty.Number, Required: false},
|
||||
"CPU_hot_plug": &hcldec.AttrSpec{Name: "CPU_hot_plug", Type: cty.Bool, Required: false},
|
||||
"RAM": &hcldec.AttrSpec{Name: "RAM", Type: cty.Number, Required: false},
|
||||
"RAM_reservation": &hcldec.AttrSpec{Name: "RAM_reservation", Type: cty.Number, Required: false},
|
||||
"RAM_reserve_all": &hcldec.AttrSpec{Name: "RAM_reserve_all", Type: cty.Bool, Required: false},
|
||||
"RAM_hot_plug": &hcldec.AttrSpec{Name: "RAM_hot_plug", Type: cty.Bool, Required: false},
|
||||
"video_ram": &hcldec.AttrSpec{Name: "video_ram", Type: cty.Number, Required: false},
|
||||
"NestedHV": &hcldec.AttrSpec{Name: "NestedHV", Type: cty.Bool, Required: false},
|
||||
"configuration_parameters": &hcldec.BlockAttrsSpec{TypeName: "configuration_parameters", ElementType: cty.String, Required: false},
|
||||
"boot_order": &hcldec.AttrSpec{Name: "boot_order", Type: cty.String, Required: false},
|
||||
"ip_wait_timeout": &hcldec.AttrSpec{Name: "ip_wait_timeout", Type: cty.String, Required: false},
|
||||
"ip_settle_timeout": &hcldec.AttrSpec{Name: "ip_settle_timeout", Type: cty.String, Required: false},
|
||||
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
||||
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
||||
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
||||
"ssh_port": &hcldec.AttrSpec{Name: "ssh_port", Type: cty.Number, Required: false},
|
||||
"ssh_username": &hcldec.AttrSpec{Name: "ssh_username", Type: cty.String, Required: false},
|
||||
"ssh_password": &hcldec.AttrSpec{Name: "ssh_password", Type: cty.String, Required: false},
|
||||
"ssh_keypair_name": &hcldec.AttrSpec{Name: "ssh_keypair_name", Type: cty.String, Required: false},
|
||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||
"ssh_clear_authorized_keys": &hcldec.AttrSpec{Name: "ssh_clear_authorized_keys", Type: cty.Bool, Required: false},
|
||||
"ssh_private_key_file": &hcldec.AttrSpec{Name: "ssh_private_key_file", Type: cty.String, Required: false},
|
||||
"ssh_pty": &hcldec.AttrSpec{Name: "ssh_pty", Type: cty.Bool, Required: false},
|
||||
"ssh_timeout": &hcldec.AttrSpec{Name: "ssh_timeout", Type: cty.String, Required: false},
|
||||
"ssh_agent_auth": &hcldec.AttrSpec{Name: "ssh_agent_auth", Type: cty.Bool, Required: false},
|
||||
"ssh_disable_agent_forwarding": &hcldec.AttrSpec{Name: "ssh_disable_agent_forwarding", Type: cty.Bool, Required: false},
|
||||
"ssh_handshake_attempts": &hcldec.AttrSpec{Name: "ssh_handshake_attempts", Type: cty.Number, Required: false},
|
||||
"ssh_bastion_host": &hcldec.AttrSpec{Name: "ssh_bastion_host", Type: cty.String, Required: false},
|
||||
"ssh_bastion_port": &hcldec.AttrSpec{Name: "ssh_bastion_port", Type: cty.Number, Required: false},
|
||||
"ssh_bastion_agent_auth": &hcldec.AttrSpec{Name: "ssh_bastion_agent_auth", Type: cty.Bool, Required: false},
|
||||
"ssh_bastion_username": &hcldec.AttrSpec{Name: "ssh_bastion_username", Type: cty.String, Required: false},
|
||||
"ssh_bastion_password": &hcldec.AttrSpec{Name: "ssh_bastion_password", Type: cty.String, Required: false},
|
||||
"ssh_bastion_private_key_file": &hcldec.AttrSpec{Name: "ssh_bastion_private_key_file", Type: cty.String, Required: false},
|
||||
"ssh_file_transfer_method": &hcldec.AttrSpec{Name: "ssh_file_transfer_method", Type: cty.String, Required: false},
|
||||
"ssh_proxy_host": &hcldec.AttrSpec{Name: "ssh_proxy_host", Type: cty.String, Required: false},
|
||||
"ssh_proxy_port": &hcldec.AttrSpec{Name: "ssh_proxy_port", Type: cty.Number, Required: false},
|
||||
"ssh_proxy_username": &hcldec.AttrSpec{Name: "ssh_proxy_username", Type: cty.String, Required: false},
|
||||
"ssh_proxy_password": &hcldec.AttrSpec{Name: "ssh_proxy_password", Type: cty.String, Required: false},
|
||||
"ssh_keep_alive_interval": &hcldec.AttrSpec{Name: "ssh_keep_alive_interval", Type: cty.String, Required: false},
|
||||
"ssh_read_write_timeout": &hcldec.AttrSpec{Name: "ssh_read_write_timeout", Type: cty.String, Required: false},
|
||||
"ssh_remote_tunnels": &hcldec.AttrSpec{Name: "ssh_remote_tunnels", Type: cty.List(cty.String), Required: false},
|
||||
"ssh_local_tunnels": &hcldec.AttrSpec{Name: "ssh_local_tunnels", Type: cty.List(cty.String), Required: false},
|
||||
"ssh_public_key": &hcldec.AttrSpec{Name: "ssh_public_key", Type: cty.List(cty.Number), Required: false},
|
||||
"ssh_private_key": &hcldec.AttrSpec{Name: "ssh_private_key", Type: cty.List(cty.Number), Required: false},
|
||||
"winrm_username": &hcldec.AttrSpec{Name: "winrm_username", Type: cty.String, Required: false},
|
||||
"winrm_password": &hcldec.AttrSpec{Name: "winrm_password", Type: cty.String, Required: false},
|
||||
"winrm_host": &hcldec.AttrSpec{Name: "winrm_host", Type: cty.String, Required: false},
|
||||
"winrm_port": &hcldec.AttrSpec{Name: "winrm_port", Type: cty.Number, Required: false},
|
||||
"winrm_timeout": &hcldec.AttrSpec{Name: "winrm_timeout", Type: cty.String, Required: false},
|
||||
"winrm_use_ssl": &hcldec.AttrSpec{Name: "winrm_use_ssl", Type: cty.Bool, Required: false},
|
||||
"winrm_insecure": &hcldec.AttrSpec{Name: "winrm_insecure", Type: cty.Bool, Required: false},
|
||||
"winrm_use_ntlm": &hcldec.AttrSpec{Name: "winrm_use_ntlm", Type: cty.Bool, Required: false},
|
||||
"shutdown_command": &hcldec.AttrSpec{Name: "shutdown_command", Type: cty.String, Required: false},
|
||||
"shutdown_timeout": &hcldec.AttrSpec{Name: "shutdown_timeout", Type: cty.String, Required: false},
|
||||
"create_snapshot": &hcldec.AttrSpec{Name: "create_snapshot", Type: cty.Bool, Required: false},
|
||||
"convert_to_template": &hcldec.AttrSpec{Name: "convert_to_template", Type: cty.Bool, Required: false},
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package clone
|
||||
|
||||
import "testing"
|
||||
import "go.uber.org/goleak"
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
|
||||
}
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestDatastoreAcc(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
d := newTestDriver(t)
|
||||
ds, err := d.FindDatastore("datastore1", "")
|
||||
if err != nil {
|
||||
|
@ -23,6 +24,7 @@ func TestDatastoreAcc(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFileUpload(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
dsName := "datastore1"
|
||||
hostName := "esxi-1.vsphere65.test"
|
||||
|
||||
|
@ -58,6 +60,7 @@ func TestFileUpload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFileUploadDRS(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
dsName := "datastore3"
|
||||
hostName := ""
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package driver
|
|||
import "testing"
|
||||
|
||||
func TestFolderAcc(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
d := newTestDriver(t)
|
||||
f, err := d.FindFolder("folder1/folder2")
|
||||
if err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func TestHostAcc(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
d := newTestDriver(t)
|
||||
host, err := d.FindHost(TestHostName)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package driver
|
||||
|
||||
import "testing"
|
||||
import "go.uber.org/goleak"
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
|
||||
}
|
|
@ -3,6 +3,7 @@ package driver
|
|||
import "testing"
|
||||
|
||||
func TestResourcePoolAcc(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
d := newTestDriver(t)
|
||||
p, err := d.FindResourcePool("", "esxi-1.vsphere65.test", "pool1/pool2")
|
||||
if err != nil {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestVMAcc_clone(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
testCases := []struct {
|
||||
name string
|
||||
config *CloneConfig
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
)
|
||||
|
||||
func TestVMAcc_create(t *testing.T) {
|
||||
t.Skip("Acceptance tests not configured yet.")
|
||||
testCases := []struct {
|
||||
name string
|
||||
config *CreateConfig
|
||||
|
|
|
@ -2,6 +2,7 @@ package iso
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/hashicorp/packer/builder/vsphere/common"
|
||||
"github.com/hashicorp/packer/builder/vsphere/driver"
|
||||
packerCommon "github.com/hashicorp/packer/common"
|
||||
|
@ -15,14 +16,16 @@ type Builder struct {
|
|||
runner multistep.Runner
|
||||
}
|
||||
|
||||
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }
|
||||
|
||||
func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
||||
c, warnings, errs := NewConfig(raws...)
|
||||
if errs != nil {
|
||||
return warnings, errs
|
||||
return warnings, nil, errs
|
||||
}
|
||||
b.config = c
|
||||
|
||||
return warnings, nil
|
||||
return warnings, nil, nil
|
||||
}
|
||||
|
||||
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
//go:generate mapstructure-to-hcl2 -type Config
|
||||
|
||||
package iso
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/packer/builder/vsphere/common"
|
||||
packerCommon "github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/bootcommand"
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -22,12 +23,12 @@ type Config struct {
|
|||
|
||||
packerCommon.ISOConfig `mapstructure:",squash"`
|
||||
|
||||
CDRomConfig `mapstructure:",squash"`
|
||||
FloppyConfig `mapstructure:",squash"`
|
||||
common.RunConfig `mapstructure:",squash"`
|
||||
bootcommand.BootConfig `mapstructure:",squash"`
|
||||
common.WaitIpConfig `mapstructure:",squash"`
|
||||
Comm communicator.Config `mapstructure:",squash"`
|
||||
CDRomConfig `mapstructure:",squash"`
|
||||
FloppyConfig `mapstructure:",squash"`
|
||||
common.RunConfig `mapstructure:",squash"`
|
||||
BootConfig `mapstructure:",squash"`
|
||||
common.WaitIpConfig `mapstructure:",squash"`
|
||||
Comm communicator.Config `mapstructure:",squash"`
|
||||
|
||||
common.ShutdownConfig `mapstructure:",squash"`
|
||||
|
||||
|
|
|
@ -0,0 +1,238 @@
|
|||
// Code generated by "mapstructure-to-hcl2 -type Config"; DO NOT EDIT.
|
||||
package iso
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.
|
||||
type FlatConfig struct {
|
||||
PackerBuildName *string `mapstructure:"packer_build_name" cty:"packer_build_name"`
|
||||
PackerBuilderType *string `mapstructure:"packer_builder_type" cty:"packer_builder_type"`
|
||||
PackerDebug *bool `mapstructure:"packer_debug" cty:"packer_debug"`
|
||||
PackerForce *bool `mapstructure:"packer_force" cty:"packer_force"`
|
||||
PackerOnError *string `mapstructure:"packer_on_error" cty:"packer_on_error"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables"`
|
||||
PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables"`
|
||||
HTTPDir *string `mapstructure:"http_directory" cty:"http_directory"`
|
||||
HTTPPortMin *int `mapstructure:"http_port_min" cty:"http_port_min"`
|
||||
HTTPPortMax *int `mapstructure:"http_port_max" cty:"http_port_max"`
|
||||
VCenterServer *string `mapstructure:"vcenter_server" cty:"vcenter_server"`
|
||||
Username *string `mapstructure:"username" cty:"username"`
|
||||
Password *string `mapstructure:"password" cty:"password"`
|
||||
InsecureConnection *bool `mapstructure:"insecure_connection" cty:"insecure_connection"`
|
||||
Datacenter *string `mapstructure:"datacenter" cty:"datacenter"`
|
||||
Version *uint `mapstructure:"vm_version" cty:"vm_version"`
|
||||
GuestOSType *string `mapstructure:"guest_os_type" cty:"guest_os_type"`
|
||||
Firmware *string `mapstructure:"firmware" cty:"firmware"`
|
||||
DiskControllerType *string `mapstructure:"disk_controller_type" cty:"disk_controller_type"`
|
||||
DiskSize *int64 `mapstructure:"disk_size" cty:"disk_size"`
|
||||
DiskThinProvisioned *bool `mapstructure:"disk_thin_provisioned" cty:"disk_thin_provisioned"`
|
||||
Network *string `mapstructure:"network" cty:"network"`
|
||||
NetworkCard *string `mapstructure:"network_card" cty:"network_card"`
|
||||
USBController *bool `mapstructure:"usb_controller" cty:"usb_controller"`
|
||||
Notes *string `mapstructure:"notes" cty:"notes"`
|
||||
VMName *string `mapstructure:"vm_name" cty:"vm_name"`
|
||||
Folder *string `mapstructure:"folder" cty:"folder"`
|
||||
Cluster *string `mapstructure:"cluster" cty:"cluster"`
|
||||
Host *string `mapstructure:"host" cty:"host"`
|
||||
ResourcePool *string `mapstructure:"resource_pool" cty:"resource_pool"`
|
||||
Datastore *string `mapstructure:"datastore" cty:"datastore"`
|
||||
CPUs *int32 `mapstructure:"CPUs" cty:"CPUs"`
|
||||
CpuCores *int32 `mapstructure:"cpu_cores" cty:"cpu_cores"`
|
||||
CPUReservation *int64 `mapstructure:"CPU_reservation" cty:"CPU_reservation"`
|
||||
CPULimit *int64 `mapstructure:"CPU_limit" cty:"CPU_limit"`
|
||||
CpuHotAddEnabled *bool `mapstructure:"CPU_hot_plug" cty:"CPU_hot_plug"`
|
||||
RAM *int64 `mapstructure:"RAM" cty:"RAM"`
|
||||
RAMReservation *int64 `mapstructure:"RAM_reservation" cty:"RAM_reservation"`
|
||||
RAMReserveAll *bool `mapstructure:"RAM_reserve_all" cty:"RAM_reserve_all"`
|
||||
MemoryHotAddEnabled *bool `mapstructure:"RAM_hot_plug" cty:"RAM_hot_plug"`
|
||||
VideoRAM *int64 `mapstructure:"video_ram" cty:"video_ram"`
|
||||
NestedHV *bool `mapstructure:"NestedHV" cty:"NestedHV"`
|
||||
ConfigParams map[string]string `mapstructure:"configuration_parameters" cty:"configuration_parameters"`
|
||||
ISOChecksum *string `mapstructure:"iso_checksum" required:"true" cty:"iso_checksum"`
|
||||
ISOChecksumURL *string `mapstructure:"iso_checksum_url" cty:"iso_checksum_url"`
|
||||
ISOChecksumType *string `mapstructure:"iso_checksum_type" cty:"iso_checksum_type"`
|
||||
RawSingleISOUrl *string `mapstructure:"iso_url" required:"true" cty:"iso_url"`
|
||||
ISOUrls []string `mapstructure:"iso_urls" cty:"iso_urls"`
|
||||
TargetPath *string `mapstructure:"iso_target_path" cty:"iso_target_path"`
|
||||
TargetExtension *string `mapstructure:"iso_target_extension" cty:"iso_target_extension"`
|
||||
CdromType *string `mapstructure:"cdrom_type" cty:"cdrom_type"`
|
||||
ISOPaths []string `mapstructure:"iso_paths" cty:"iso_paths"`
|
||||
FloppyIMGPath *string `mapstructure:"floppy_img_path" cty:"floppy_img_path"`
|
||||
FloppyFiles []string `mapstructure:"floppy_files" cty:"floppy_files"`
|
||||
FloppyDirectories []string `mapstructure:"floppy_dirs" cty:"floppy_dirs"`
|
||||
BootOrder *string `mapstructure:"boot_order" cty:"boot_order"`
|
||||
BootCommand []string `mapstructure:"boot_command" cty:"boot_command"`
|
||||
BootWait *string `mapstructure:"boot_wait" cty:"boot_wait"`
|
||||
HTTPIP *string `mapstructure:"http_ip" cty:"http_ip"`
|
||||
WaitTimeout *string `mapstructure:"ip_wait_timeout" cty:"ip_wait_timeout"`
|
||||
SettleTimeout *string `mapstructure:"ip_settle_timeout" cty:"ip_settle_timeout"`
|
||||
Type *string `mapstructure:"communicator" cty:"communicator"`
|
||||
PauseBeforeConnect *string `mapstructure:"pause_before_connecting" cty:"pause_before_connecting"`
|
||||
SSHHost *string `mapstructure:"ssh_host" cty:"ssh_host"`
|
||||
SSHPort *int `mapstructure:"ssh_port" cty:"ssh_port"`
|
||||
SSHUsername *string `mapstructure:"ssh_username" cty:"ssh_username"`
|
||||
SSHPassword *string `mapstructure:"ssh_password" cty:"ssh_password"`
|
||||
SSHKeyPairName *string `mapstructure:"ssh_keypair_name" cty:"ssh_keypair_name"`
|
||||
SSHTemporaryKeyPairName *string `mapstructure:"temporary_key_pair_name" cty:"temporary_key_pair_name"`
|
||||
SSHClearAuthorizedKeys *bool `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys"`
|
||||
SSHPrivateKeyFile *string `mapstructure:"ssh_private_key_file" cty:"ssh_private_key_file"`
|
||||
SSHPty *bool `mapstructure:"ssh_pty" cty:"ssh_pty"`
|
||||
SSHTimeout *string `mapstructure:"ssh_timeout" cty:"ssh_timeout"`
|
||||
SSHAgentAuth *bool `mapstructure:"ssh_agent_auth" cty:"ssh_agent_auth"`
|
||||
SSHDisableAgentForwarding *bool `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding"`
|
||||
SSHHandshakeAttempts *int `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts"`
|
||||
SSHBastionHost *string `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host"`
|
||||
SSHBastionPort *int `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port"`
|
||||
SSHBastionAgentAuth *bool `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth"`
|
||||
SSHBastionUsername *string `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username"`
|
||||
SSHBastionPassword *string `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password"`
|
||||
SSHBastionPrivateKeyFile *string `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file"`
|
||||
SSHFileTransferMethod *string `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method"`
|
||||
SSHProxyHost *string `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host"`
|
||||
SSHProxyPort *int `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port"`
|
||||
SSHProxyUsername *string `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username"`
|
||||
SSHProxyPassword *string `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password"`
|
||||
SSHKeepAliveInterval *string `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval"`
|
||||
SSHReadWriteTimeout *string `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout"`
|
||||
SSHRemoteTunnels []string `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels"`
|
||||
SSHLocalTunnels []string `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels"`
|
||||
SSHPublicKey []byte `mapstructure:"ssh_public_key" cty:"ssh_public_key"`
|
||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key" cty:"ssh_private_key"`
|
||||
WinRMUser *string `mapstructure:"winrm_username" cty:"winrm_username"`
|
||||
WinRMPassword *string `mapstructure:"winrm_password" cty:"winrm_password"`
|
||||
WinRMHost *string `mapstructure:"winrm_host" cty:"winrm_host"`
|
||||
WinRMPort *int `mapstructure:"winrm_port" cty:"winrm_port"`
|
||||
WinRMTimeout *string `mapstructure:"winrm_timeout" cty:"winrm_timeout"`
|
||||
WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"`
|
||||
WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"`
|
||||
WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"`
|
||||
Command *string `mapstructure:"shutdown_command" cty:"shutdown_command"`
|
||||
Timeout *string `mapstructure:"shutdown_timeout" cty:"shutdown_timeout"`
|
||||
CreateSnapshot *bool `mapstructure:"create_snapshot" cty:"create_snapshot"`
|
||||
ConvertToTemplate *bool `mapstructure:"convert_to_template" cty:"convert_to_template"`
|
||||
}
|
||||
|
||||
// FlatMapstructure returns a new FlatConfig.
|
||||
// FlatConfig is an auto-generated flat version of Config.
|
||||
// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.
|
||||
func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } {
|
||||
return new(FlatConfig)
|
||||
}
|
||||
|
||||
// HCL2Spec returns the hcl spec of a Config.
|
||||
// This spec is used by HCL to read the fields of Config.
|
||||
// The decoded values from this spec will then be applied to a FlatConfig.
|
||||
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
|
||||
s := map[string]hcldec.Spec{
|
||||
"packer_build_name": &hcldec.AttrSpec{Name: "packer_build_name", Type: cty.String, Required: false},
|
||||
"packer_builder_type": &hcldec.AttrSpec{Name: "packer_builder_type", Type: cty.String, Required: false},
|
||||
"packer_debug": &hcldec.AttrSpec{Name: "packer_debug", Type: cty.Bool, Required: false},
|
||||
"packer_force": &hcldec.AttrSpec{Name: "packer_force", Type: cty.Bool, Required: false},
|
||||
"packer_on_error": &hcldec.AttrSpec{Name: "packer_on_error", Type: cty.String, Required: false},
|
||||
"packer_user_variables": &hcldec.BlockAttrsSpec{TypeName: "packer_user_variables", ElementType: cty.String, Required: false},
|
||||
"packer_sensitive_variables": &hcldec.AttrSpec{Name: "packer_sensitive_variables", Type: cty.List(cty.String), Required: false},
|
||||
"http_directory": &hcldec.AttrSpec{Name: "http_directory", Type: cty.String, Required: false},
|
||||
"http_port_min": &hcldec.AttrSpec{Name: "http_port_min", Type: cty.Number, Required: false},
|
||||
"http_port_max": &hcldec.AttrSpec{Name: "http_port_max", Type: cty.Number, Required: false},
|
||||
"vcenter_server": &hcldec.AttrSpec{Name: "vcenter_server", Type: cty.String, Required: false},
|
||||
"username": &hcldec.AttrSpec{Name: "username", Type: cty.String, Required: false},
|
||||
"password": &hcldec.AttrSpec{Name: "password", Type: cty.String, Required: false},
|
||||
"insecure_connection": &hcldec.AttrSpec{Name: "insecure_connection", Type: cty.Bool, Required: false},
|
||||
"datacenter": &hcldec.AttrSpec{Name: "datacenter", Type: cty.String, Required: false},
|
||||
"vm_version": &hcldec.AttrSpec{Name: "vm_version", Type: cty.Number, Required: false},
|
||||
"guest_os_type": &hcldec.AttrSpec{Name: "guest_os_type", Type: cty.String, Required: false},
|
||||
"firmware": &hcldec.AttrSpec{Name: "firmware", Type: cty.String, Required: false},
|
||||
"disk_controller_type": &hcldec.AttrSpec{Name: "disk_controller_type", Type: cty.String, Required: false},
|
||||
"disk_size": &hcldec.AttrSpec{Name: "disk_size", Type: cty.Number, Required: false},
|
||||
"disk_thin_provisioned": &hcldec.AttrSpec{Name: "disk_thin_provisioned", Type: cty.Bool, Required: false},
|
||||
"network": &hcldec.AttrSpec{Name: "network", Type: cty.String, Required: false},
|
||||
"network_card": &hcldec.AttrSpec{Name: "network_card", Type: cty.String, Required: false},
|
||||
"usb_controller": &hcldec.AttrSpec{Name: "usb_controller", Type: cty.Bool, Required: false},
|
||||
"notes": &hcldec.AttrSpec{Name: "notes", Type: cty.String, Required: false},
|
||||
"vm_name": &hcldec.AttrSpec{Name: "vm_name", Type: cty.String, Required: false},
|
||||
"folder": &hcldec.AttrSpec{Name: "folder", Type: cty.String, Required: false},
|
||||
"cluster": &hcldec.AttrSpec{Name: "cluster", Type: cty.String, Required: false},
|
||||
"host": &hcldec.AttrSpec{Name: "host", Type: cty.String, Required: false},
|
||||
"resource_pool": &hcldec.AttrSpec{Name: "resource_pool", Type: cty.String, Required: false},
|
||||
"datastore": &hcldec.AttrSpec{Name: "datastore", Type: cty.String, Required: false},
|
||||
"CPUs": &hcldec.AttrSpec{Name: "CPUs", Type: cty.Number, Required: false},
|
||||
"cpu_cores": &hcldec.AttrSpec{Name: "cpu_cores", Type: cty.Number, Required: false},
|
||||
"CPU_reservation": &hcldec.AttrSpec{Name: "CPU_reservation", Type: cty.Number, Required: false},
|
||||
"CPU_limit": &hcldec.AttrSpec{Name: "CPU_limit", Type: cty.Number, Required: false},
|
||||
"CPU_hot_plug": &hcldec.AttrSpec{Name: "CPU_hot_plug", Type: cty.Bool, Required: false},
|
||||
"RAM": &hcldec.AttrSpec{Name: "RAM", Type: cty.Number, Required: false},
|
||||
"RAM_reservation": &hcldec.AttrSpec{Name: "RAM_reservation", Type: cty.Number, Required: false},
|
||||
"RAM_reserve_all": &hcldec.AttrSpec{Name: "RAM_reserve_all", Type: cty.Bool, Required: false},
|
||||
"RAM_hot_plug": &hcldec.AttrSpec{Name: "RAM_hot_plug", Type: cty.Bool, Required: false},
|
||||
"video_ram": &hcldec.AttrSpec{Name: "video_ram", Type: cty.Number, Required: false},
|
||||
"NestedHV": &hcldec.AttrSpec{Name: "NestedHV", Type: cty.Bool, Required: false},
|
||||
"configuration_parameters": &hcldec.BlockAttrsSpec{TypeName: "configuration_parameters", ElementType: cty.String, Required: false},
|
||||
"iso_checksum": &hcldec.AttrSpec{Name: "iso_checksum", Type: cty.String, Required: false},
|
||||
"iso_checksum_url": &hcldec.AttrSpec{Name: "iso_checksum_url", Type: cty.String, Required: false},
|
||||
"iso_checksum_type": &hcldec.AttrSpec{Name: "iso_checksum_type", Type: cty.String, Required: false},
|
||||
"iso_url": &hcldec.AttrSpec{Name: "iso_url", Type: cty.String, Required: false},
|
||||
"iso_urls": &hcldec.AttrSpec{Name: "iso_urls", Type: cty.List(cty.String), Required: false},
|
||||
"iso_target_path": &hcldec.AttrSpec{Name: "iso_target_path", Type: cty.String, Required: false},
|
||||
"iso_target_extension": &hcldec.AttrSpec{Name: "iso_target_extension", Type: cty.String, Required: false},
|
||||
"cdrom_type": &hcldec.AttrSpec{Name: "cdrom_type", Type: cty.String, Required: false},
|
||||
"iso_paths": &hcldec.AttrSpec{Name: "iso_paths", Type: cty.List(cty.String), Required: false},
|
||||
"floppy_img_path": &hcldec.AttrSpec{Name: "floppy_img_path", Type: cty.String, Required: false},
|
||||
"floppy_files": &hcldec.AttrSpec{Name: "floppy_files", Type: cty.List(cty.String), Required: false},
|
||||
"floppy_dirs": &hcldec.AttrSpec{Name: "floppy_dirs", Type: cty.List(cty.String), Required: false},
|
||||
"boot_order": &hcldec.AttrSpec{Name: "boot_order", Type: cty.String, Required: false},
|
||||
"boot_command": &hcldec.AttrSpec{Name: "boot_command", Type: cty.List(cty.String), Required: false},
|
||||
"boot_wait": &hcldec.AttrSpec{Name: "boot_wait", Type: cty.String, Required: false},
|
||||
"http_ip": &hcldec.AttrSpec{Name: "http_ip", Type: cty.String, Required: false},
|
||||
"ip_wait_timeout": &hcldec.AttrSpec{Name: "ip_wait_timeout", Type: cty.String, Required: false},
|
||||
"ip_settle_timeout": &hcldec.AttrSpec{Name: "ip_settle_timeout", Type: cty.String, Required: false},
|
||||
"communicator": &hcldec.AttrSpec{Name: "communicator", Type: cty.String, Required: false},
|
||||
"pause_before_connecting": &hcldec.AttrSpec{Name: "pause_before_connecting", Type: cty.String, Required: false},
|
||||
"ssh_host": &hcldec.AttrSpec{Name: "ssh_host", Type: cty.String, Required: false},
|
||||
"ssh_port": &hcldec.AttrSpec{Name: "ssh_port", Type: cty.Number, Required: false},
|
||||
"ssh_username": &hcldec.AttrSpec{Name: "ssh_username", Type: cty.String, Required: false},
|
||||
"ssh_password": &hcldec.AttrSpec{Name: "ssh_password", Type: cty.String, Required: false},
|
||||
"ssh_keypair_name": &hcldec.AttrSpec{Name: "ssh_keypair_name", Type: cty.String, Required: false},
|
||||
"temporary_key_pair_name": &hcldec.AttrSpec{Name: "temporary_key_pair_name", Type: cty.String, Required: false},
|
||||
"ssh_clear_authorized_keys": &hcldec.AttrSpec{Name: "ssh_clear_authorized_keys", Type: cty.Bool, Required: false},
|
||||
"ssh_private_key_file": &hcldec.AttrSpec{Name: "ssh_private_key_file", Type: cty.String, Required: false},
|
||||
"ssh_pty": &hcldec.AttrSpec{Name: "ssh_pty", Type: cty.Bool, Required: false},
|
||||
"ssh_timeout": &hcldec.AttrSpec{Name: "ssh_timeout", Type: cty.String, Required: false},
|
||||
"ssh_agent_auth": &hcldec.AttrSpec{Name: "ssh_agent_auth", Type: cty.Bool, Required: false},
|
||||
"ssh_disable_agent_forwarding": &hcldec.AttrSpec{Name: "ssh_disable_agent_forwarding", Type: cty.Bool, Required: false},
|
||||
"ssh_handshake_attempts": &hcldec.AttrSpec{Name: "ssh_handshake_attempts", Type: cty.Number, Required: false},
|
||||
"ssh_bastion_host": &hcldec.AttrSpec{Name: "ssh_bastion_host", Type: cty.String, Required: false},
|
||||
"ssh_bastion_port": &hcldec.AttrSpec{Name: "ssh_bastion_port", Type: cty.Number, Required: false},
|
||||
"ssh_bastion_agent_auth": &hcldec.AttrSpec{Name: "ssh_bastion_agent_auth", Type: cty.Bool, Required: false},
|
||||
"ssh_bastion_username": &hcldec.AttrSpec{Name: "ssh_bastion_username", Type: cty.String, Required: false},
|
||||
"ssh_bastion_password": &hcldec.AttrSpec{Name: "ssh_bastion_password", Type: cty.String, Required: false},
|
||||
"ssh_bastion_private_key_file": &hcldec.AttrSpec{Name: "ssh_bastion_private_key_file", Type: cty.String, Required: false},
|
||||
"ssh_file_transfer_method": &hcldec.AttrSpec{Name: "ssh_file_transfer_method", Type: cty.String, Required: false},
|
||||
"ssh_proxy_host": &hcldec.AttrSpec{Name: "ssh_proxy_host", Type: cty.String, Required: false},
|
||||
"ssh_proxy_port": &hcldec.AttrSpec{Name: "ssh_proxy_port", Type: cty.Number, Required: false},
|
||||
"ssh_proxy_username": &hcldec.AttrSpec{Name: "ssh_proxy_username", Type: cty.String, Required: false},
|
||||
"ssh_proxy_password": &hcldec.AttrSpec{Name: "ssh_proxy_password", Type: cty.String, Required: false},
|
||||
"ssh_keep_alive_interval": &hcldec.AttrSpec{Name: "ssh_keep_alive_interval", Type: cty.String, Required: false},
|
||||
"ssh_read_write_timeout": &hcldec.AttrSpec{Name: "ssh_read_write_timeout", Type: cty.String, Required: false},
|
||||
"ssh_remote_tunnels": &hcldec.AttrSpec{Name: "ssh_remote_tunnels", Type: cty.List(cty.String), Required: false},
|
||||
"ssh_local_tunnels": &hcldec.AttrSpec{Name: "ssh_local_tunnels", Type: cty.List(cty.String), Required: false},
|
||||
"ssh_public_key": &hcldec.AttrSpec{Name: "ssh_public_key", Type: cty.List(cty.Number), Required: false},
|
||||
"ssh_private_key": &hcldec.AttrSpec{Name: "ssh_private_key", Type: cty.List(cty.Number), Required: false},
|
||||
"winrm_username": &hcldec.AttrSpec{Name: "winrm_username", Type: cty.String, Required: false},
|
||||
"winrm_password": &hcldec.AttrSpec{Name: "winrm_password", Type: cty.String, Required: false},
|
||||
"winrm_host": &hcldec.AttrSpec{Name: "winrm_host", Type: cty.String, Required: false},
|
||||
"winrm_port": &hcldec.AttrSpec{Name: "winrm_port", Type: cty.Number, Required: false},
|
||||
"winrm_timeout": &hcldec.AttrSpec{Name: "winrm_timeout", Type: cty.String, Required: false},
|
||||
"winrm_use_ssl": &hcldec.AttrSpec{Name: "winrm_use_ssl", Type: cty.Bool, Required: false},
|
||||
"winrm_insecure": &hcldec.AttrSpec{Name: "winrm_insecure", Type: cty.Bool, Required: false},
|
||||
"winrm_use_ntlm": &hcldec.AttrSpec{Name: "winrm_use_ntlm", Type: cty.Bool, Required: false},
|
||||
"shutdown_command": &hcldec.AttrSpec{Name: "shutdown_command", Type: cty.String, Required: false},
|
||||
"shutdown_timeout": &hcldec.AttrSpec{Name: "shutdown_timeout", Type: cty.String, Required: false},
|
||||
"create_snapshot": &hcldec.AttrSpec{Name: "create_snapshot", Type: cty.Bool, Required: false},
|
||||
"convert_to_template": &hcldec.AttrSpec{Name: "convert_to_template", Type: cty.Bool, Required: false},
|
||||
}
|
||||
return s
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package iso
|
||||
|
||||
import "testing"
|
||||
import "go.uber.org/goleak"
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
|
||||
}
|
3
go.mod
3
go.mod
|
@ -145,13 +145,12 @@ require (
|
|||
github.com/ufilesdk-dev/ufile-gosdk v0.0.0-20190830075812-b4dbc4ef43a6
|
||||
github.com/ugorji/go v0.0.0-20151218193438-646ae4a518c1
|
||||
github.com/ulikunitz/xz v0.5.5
|
||||
github.com/vmware/govmomi v0.0.0-20170707011325-c2105a174311
|
||||
github.com/vmware/govmomi v0.21.0
|
||||
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0
|
||||
github.com/yandex-cloud/go-genproto v0.0.0-20190916101622-7617782d381e
|
||||
github.com/yandex-cloud/go-sdk v0.0.0-20190916101744-c781afa45829
|
||||
github.com/zclconf/go-cty v1.1.2-0.20191126233707-f0f7fd24c4af
|
||||
go.opencensus.io v0.22.2 // indirect
|
||||
go.uber.org/goleak v1.0.0
|
||||
golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587 // indirect
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
|
||||
|
|
10
go.sum
10
go.sum
|
@ -107,6 +107,7 @@ github.com/creack/goselect v0.1.0/go.mod h1:gHrIcH/9UZDn2qgeTUeW5K9eZsVYCH6/60J/
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/digitalocean/go-libvirt v0.0.0-20190626172931-4d226dd6c437 h1:phR13shVFOIpa1pnLBmewI9p16NEladLPvVylLPeexo=
|
||||
|
@ -196,6 +197,7 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI
|
|||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/shlex v0.0.0-20150127133951-6f45313302b9 h1:JM174NTeGNJ2m/oLH3UOWOvWQQKd+BoL3hcSCUWFLt0=
|
||||
github.com/google/shlex v0.0.0-20150127133951-6f45313302b9/go.mod h1:RpwtwJQFrIEPstU94h88MWPXP2ektJZ8cZ0YntAmXiE=
|
||||
github.com/google/uuid v0.0.0-20170306145142-6a5e28554805/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
|
@ -459,8 +461,9 @@ github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
|
|||
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/vmware/govmomi v0.0.0-20170707011325-c2105a174311 h1:s5pyxd5S6wRs2WpEE0xRfWUF46Wbz44h203KnbX0ecI=
|
||||
github.com/vmware/govmomi v0.0.0-20170707011325-c2105a174311/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
|
||||
github.com/vmware/govmomi v0.21.0 h1:jc8uMuxpcV2xMAA/cnEDlnsIjvqcMra5Y8onh/U3VuY=
|
||||
github.com/vmware/govmomi v0.21.0/go.mod h1:zbnFoBQ9GIjs2RVETy8CNEpb+L+Lwkjs3XZUL0B3/m0=
|
||||
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
|
||||
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0 h1:NJrcIkdzq0C3I8ypAZwFE9RHtGbfp+mJvqIcoFATZuk=
|
||||
github.com/xanzy/go-cloudstack v0.0.0-20190526095453-42f262b63ed0/go.mod h1:sBh287mCRwCz6zyXHMmw7sSZGPohVpnx+o+OY4M+i3A=
|
||||
github.com/yandex-cloud/go-genproto v0.0.0-20190916101622-7617782d381e h1:hzwq5GUKP0aQzDja1XP4sBYyOmnezs/RVtzP+xiLbfI=
|
||||
|
@ -478,8 +481,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
|||
go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/goleak v1.0.0 h1:qsup4IcBdlmsnGfqyLl4Ntn3C2XCCuKAE7DwHpScyUo=
|
||||
go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
@ -613,7 +614,6 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn
|
|||
golang.org/x/tools v0.0.0-20190909214602-067311248421/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.kK6pryC8R-O1R0Gj9ydLvQuIZlcYLGze23WdW7xbpiEEKdz6nweJrMm7ysy8lgu1tM47JVo19p2_b26bNKSQshCUOETvd7Hb2UMZOjnyUnqdyAAyoi6UkIquXfUUbHTNS0iMxwSxxW9KMp2GXNq8-o6T8xQZTDirBJFKKd8ZNUasTaoa5j8U9IfdR1aCavTBuOhvk8IVs-jSbY5TVJMJiE0IOPXois7aRJ6uAiANQBk9VKLegEcZD_qAewecXHDsHi-u0jbmg3o3PPaJaK_Qv5dsPlR2M-E2kE3AGUn0-zn5zYRngoAZ8WZr2O4GvLdltJKq9i2z7jOrdOzzRcDRow.96qvwl_E1Hj15u7Q.hWs-jQ8FsqQFD7pE9N-UEP1BWQ9rsJIcCaPvQRIp8Fukm_vvlw9YEaEq0ERLrsUWsJWpd1ca8_h8x7xD6f_d5YppwRqRHIeGIsdBOTMhNs0lG8ikkQXLat-UroCpy8EC17nuUtDE2E2Kdxrk4Cdd6Bk-dKk0Ta4w3Ud0YBKa.P8zrO7xizgv0i98eVWWzEg
|
|
@ -1,17 +0,0 @@
|
|||
clone:
|
||||
tags: true
|
||||
path: github.com/vmware/govmomi
|
||||
build:
|
||||
image: golang:1.7
|
||||
pull: true
|
||||
environment:
|
||||
- GOVC_TEST_URL=$$GOVC_TEST_URL
|
||||
- GOVC_INSECURE=1
|
||||
- VCA=1
|
||||
commands:
|
||||
- make all install
|
||||
- git clone https://github.com/sstephenson/bats.git /tmp/bats
|
||||
- /tmp/bats/install.sh /usr/local
|
||||
- apt-get -qq update && apt-get install -yqq uuid-runtime bsdmainutils jq
|
||||
- govc/test/images/update.sh
|
||||
- bats govc/test
|
|
@ -1 +1,6 @@
|
|||
secrets.yml
|
||||
dist/
|
||||
.idea/
|
||||
|
||||
# Ignore editor temp files
|
||||
*~
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
---
|
||||
project_name: govmomi
|
||||
builds:
|
||||
- id: govc
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
- arm64
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
main: ./govc/main.go
|
||||
binary: govc
|
||||
flags: -compiler gc
|
||||
ldflags: -X github.com/vmware/govmomi/govc/flags.GitVersion={{.Version}}
|
||||
- id: vcsim
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
- arm64
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
main: ./vcsim/main.go
|
||||
binary: vcsim
|
||||
flags: -compiler gc
|
||||
ldflags: -X github.com/vmware/govmomi/vcsim/flags.GitVersion={{.Version}}
|
||||
archives:
|
||||
- id: govcbuild
|
||||
builds: ['govc']
|
||||
name_template: 'govc_{{ .Os }}_{{ .Arch }}'
|
||||
format: gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- none*
|
||||
- id: vcsimbuild
|
||||
builds: ['vcsim']
|
||||
name_template: 'vcsim_{{ .Os }}_{{ .Arch }}'
|
||||
format: gz
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
files:
|
||||
- none*
|
||||
checksum:
|
||||
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
- Merge pull request
|
||||
- Merge branch
|
||||
brews:
|
||||
- name: govc
|
||||
ids:
|
||||
- govc
|
||||
github:
|
||||
owner: govmomi
|
||||
name: homebrew-tap
|
||||
commit_author:
|
||||
name: Alfred the Narwhal
|
||||
email: cna-alfred@vmware.com
|
||||
folder: Formula
|
||||
homepage: "https://github.com/vmware/govmomi/blob/master/govc/README.md"
|
||||
description: "govc is a vSphere CLI built on top of govmomi."
|
||||
test: |
|
||||
system "#{bin}/govc version"
|
||||
install: |
|
||||
bin.install "govc"
|
||||
- name: vcsim
|
||||
ids:
|
||||
- vcsim
|
||||
github:
|
||||
owner: govmomi
|
||||
name: homebrew-tap
|
||||
commit_author:
|
||||
name: Alfred the Narwhal
|
||||
email: cna-alfred@vmware.com
|
||||
folder: Formula
|
||||
homepage: "https://github.com/vmware/govmomi/blob/master/vcsim/README.md"
|
||||
description: "vcsim is a vSphere API simulator built on top of govmomi."
|
||||
test: |
|
||||
system "#{bin}/vcsim -h"
|
||||
install: |
|
||||
bin.install "vcsim"
|
||||
dockers:
|
||||
- image_templates:
|
||||
- "vmware/govc:{{ .Tag }}"
|
||||
- "vmware/govc:v{{ .Major }}"
|
||||
- "vmware/govc:v{{ .Major }}.{{ .Minor }}"
|
||||
- "vmware/govc:latest"
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: Dockerfile.govc
|
||||
binaries:
|
||||
- govc
|
||||
- image_templates:
|
||||
- "vmware/vcsim:{{ .Tag }}"
|
||||
- "vmware/vcsim:v{{ .Major }}"
|
||||
- "vmware/vcsim:v{{ .Major }}.{{ .Minor }}"
|
||||
- "vmware/vcsim:latest"
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: Dockerfile.vcsim
|
||||
binaries:
|
||||
- vcsim
|
|
@ -1,17 +1,29 @@
|
|||
Amanda H. L. de Andrade <amanda.andrade@serpro.gov.br> amandahla <amanda.andrade@serpro.gov.br>
|
||||
Amanda H. L. de Andrade <amanda.andrade@serpro.gov.br> Amanda Hager Lopes de Andrade Katz <amanda.katz@serpro.gov.br>
|
||||
Amit Bathla <abathla@.vmware.com> <abathla@promb-1s-dhcp216.eng.vmware.com>
|
||||
Andrew Kutz <akutz@vmware.com> akutz <akutz@vmware.com>
|
||||
Andrew Kutz <akutz@vmware.com> <sakutz@gmail.com>
|
||||
Andrew Kutz <akutz@vmware.com> Andrew Kutz <101085+akutz@users.noreply.github.com>
|
||||
Bruce Downs <bruceadowns@gmail.com> <bdowns@vmware.com>
|
||||
Bruce Downs <bruceadowns@gmail.com> <bruce.downs@jivesoftware.com>
|
||||
Bruce Downs <bruceadowns@gmail.com> <bruce.downs@autodesk.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>
|
||||
Fabio Rapposelli <fabio@vmware.com> <fabio@rapposelli.org>
|
||||
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>
|
||||
Anfernee Yongkun Gui <agui@vmware.com> <anfernee.gui@gmail.com>
|
||||
Anfernee Yongkun Gui <agui@vmware.com> Yongkun Anfernee Gui <agui@vmware.com>
|
||||
Zach Tucker <ztucker@vmware.com> <jzt@users.noreply.github.com>
|
||||
Zee Yang <zeey@vmware.com> <zee.yang@gmail.com>
|
||||
Jiatong Wang <wjiatong@vmware.com> jiatongw <wjiatong@vmware.com>
|
||||
Uwe Bessle <Uwe.Bessle@iteratec.de> Uwe Bessle <u.bessle.extern@eos-ts.com>
|
||||
Uwe Bessle <Uwe.Bessle@iteratec.de> Uwe Bessle <uwe.bessle@web.de>
|
||||
|
|
|
@ -1,12 +1,95 @@
|
|||
sudo: false
|
||||
# Use the newer Travis-CI build templates based on the
|
||||
# Ubuntu Linux distribution "Xenial Xerus" release.
|
||||
os: linux
|
||||
dist: xenial
|
||||
|
||||
language: go
|
||||
# Disable sudo for all builds by default. This ensures all jobs use
|
||||
# Travis-CI's containerized build environment unless specified otherwise.
|
||||
# The container builds have *much* shorter queue times than the VM-based
|
||||
# build environment on which the sudo builds depend.
|
||||
sudo: false
|
||||
services: false
|
||||
|
||||
go:
|
||||
- 1.8
|
||||
# Set the version of Go.
|
||||
language: go
|
||||
go: 1.12
|
||||
|
||||
before_install:
|
||||
- make vendor
|
||||
# Always set the project's Go import path to ensure that forked
|
||||
# builds get cloned to the correct location.
|
||||
go_import_path: github.com/vmware/govmomi
|
||||
|
||||
script:
|
||||
- make check test
|
||||
# Ensure all the jobs know where the temp directory is.
|
||||
env:
|
||||
global: TMPDIR=/tmp
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
||||
# The "lint" stage runs the various linters against the project.
|
||||
- &lint-stage
|
||||
stage: lint
|
||||
env: LINTER=govet
|
||||
install: true
|
||||
script: make "${LINTER}"
|
||||
|
||||
- <<: *lint-stage
|
||||
env: LINTER=goimports
|
||||
|
||||
# The "build" stage verifies the program can be built against the
|
||||
# various GOOS and GOARCH combinations found in the Go releaser
|
||||
# config file, ".goreleaser.yml".
|
||||
- &build-stage
|
||||
stage: build
|
||||
env: GOOS=linux GOARCH=amd64
|
||||
install: true
|
||||
script: make install
|
||||
|
||||
- <<: *build-stage
|
||||
env: GOOS=linux GOARCH=386
|
||||
|
||||
- <<: *build-stage
|
||||
env: GOOS=darwin GOARCH=amd64
|
||||
- <<: *build-stage
|
||||
env: GOOS=darwin GOARCH=386
|
||||
|
||||
- <<: *build-stage
|
||||
env: GOOS=freebsd GOARCH=amd64
|
||||
- <<: *build-stage
|
||||
env: GOOS=freebsd GOARCH=386
|
||||
|
||||
- <<: *build-stage
|
||||
env: GOOS=windows GOARCH=amd64
|
||||
- <<: *build-stage
|
||||
env: GOOS=windows GOARCH=386
|
||||
|
||||
# The test stage executes the test target.
|
||||
- stage: test
|
||||
install: true
|
||||
script: make test
|
||||
|
||||
# The deploy stage deploys the build artifacts using goreleaser.
|
||||
#
|
||||
# This stage will only be activated when there is an annotated tag present
|
||||
# or when the text "/ci-deploy" is present in the commit message. However,
|
||||
# the "deploy" phase of the build will still only be executed on non-PR
|
||||
# builds as that restriction is baked into Travis-CI.
|
||||
#
|
||||
# Finally, this stage requires the Travis-CI VM infrastructure in order to
|
||||
# leverage Docker. This will increase the amount of time the jobs sit
|
||||
# in the queue, waiting to be built. However, it's a necessity as Travis-CI
|
||||
# only allows the use of Docker with VM builds.
|
||||
- stage: deploy
|
||||
if: tag IS present OR commit_message =~ /\/ci-deploy/
|
||||
sudo: required
|
||||
services: docker
|
||||
install: true
|
||||
script: make install
|
||||
after_success: docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
|
||||
deploy:
|
||||
- provider: script
|
||||
skip_cleanup: true
|
||||
script: curl -sL http://git.io/goreleaser | bash
|
||||
addons:
|
||||
apt:
|
||||
update: true
|
||||
packages: xmlstarlet
|
||||
|
|
|
@ -1,5 +1,81 @@
|
|||
# changelog
|
||||
|
||||
### 0.21.0 (2019-07-24)
|
||||
|
||||
* Add vsan package
|
||||
|
||||
* Add vslm (FCD) global catalog support
|
||||
|
||||
* Add content library support
|
||||
|
||||
### 0.20.0 (2019-02-06)
|
||||
|
||||
* Add vslm package for managing First Class Disks
|
||||
|
||||
* Add LoginByToken to session KeepAliveHandler
|
||||
|
||||
### 0.19.0 (2018-09-30)
|
||||
|
||||
* New vapi/rest and and vapi/tags packages
|
||||
|
||||
* Allowing the use of STS for exchanging tokens
|
||||
|
||||
* Add object.VirtualMachine.UUID method
|
||||
|
||||
* SetRootCAs on the soap.Client returns an error for invalid certificates
|
||||
|
||||
* Add ClusterComputeResource.MoveInto method
|
||||
|
||||
### 0.18.0 (2018-05-24)
|
||||
|
||||
* Add VirtualDiskManager wrapper to set UUID
|
||||
|
||||
* Add vmxnet2, pcnet32 and sriov to VirtualDeviceList.EthernetCardTypes
|
||||
|
||||
* Add new vSphere 6.7 APIs
|
||||
|
||||
* Decrease LoginExtensionByCertificate tunnel usage
|
||||
|
||||
* SAML token authentication support via SessionManager.LoginByToken
|
||||
|
||||
* New SSO admin client for managing users
|
||||
|
||||
* New STS client for issuing and renewing SAML tokens
|
||||
|
||||
* New Lookup Service client for discovering endpoints such as STS and ssoadmin
|
||||
|
||||
* Switch from gvt to go dep for managing dependencies
|
||||
|
||||
### 0.17.1 (2018-03-19)
|
||||
|
||||
* vcsim: add Destroy method for Folder and Datacenter types
|
||||
|
||||
* In progress.Reader emit final report on EOF.
|
||||
|
||||
* vcsim: add EventManager.QueryEvents
|
||||
|
||||
### 0.17.0 (2018-02-28)
|
||||
|
||||
* Add HostStorageSystem.AttachScsiLun method
|
||||
|
||||
* Avoid possible panic in Datastore.Stat (#969)
|
||||
|
||||
* Destroy event history collectors (#962)
|
||||
|
||||
* Add VirtualDiskManager.CreateChildDisk method
|
||||
|
||||
### 0.16.0 (2017-11-08)
|
||||
|
||||
* Add support for SOAP request operation ID header
|
||||
|
||||
* Moved ovf helpers from govc import.ovf command to ovf and nfc packages
|
||||
|
||||
* Added guest/toolbox (client) package
|
||||
|
||||
* Added toolbox package and toolbox command
|
||||
|
||||
* Added simulator package and vcsim command
|
||||
|
||||
### 0.15.0 (2017-06-19)
|
||||
|
||||
* WaitOptions.MaxWaitSeconds is now optional
|
||||
|
|
|
@ -3,34 +3,55 @@
|
|||
# This script is generated by contributors.sh
|
||||
#
|
||||
|
||||
Abhijeet Kasurde <akasurde@redhat.com>
|
||||
abrarshivani <abrarshivani@users.noreply.github.com>
|
||||
Adam Shannon <adamkshannon@gmail.com>
|
||||
Alessandro Cortiana <alessandro.cortiana@gmail.com>
|
||||
Alex Bozhenko <alexbozhenko@fb.com>
|
||||
Alex Ellis (VMware) <alexellis2@gmail.com>
|
||||
Alex <puzo2002@gmail.com>
|
||||
Alvaro Miranda <kikitux@gmail.com>
|
||||
amandahla <amanda.andrade@serpro.gov.br>
|
||||
Amanda H. L. de Andrade <amanda.andrade@serpro.gov.br>
|
||||
Amit Bathla <abathla@.vmware.com>
|
||||
amit bezalel <amit.bezalel@hpe.com>
|
||||
Andrew <AndrewDi@users.noreply.github.com>
|
||||
Andrew Chin <andrew@andrewtchin.com>
|
||||
Andrew Kutz <akutz@vmware.com>
|
||||
Andrey Klimentyev <andrey.klimentyev@flant.com>
|
||||
Anfernee Yongkun Gui <agui@vmware.com>
|
||||
angystardust <angystardust@users.noreply.github.com>
|
||||
aniketGslab <aniket.shinde@gslab.com>
|
||||
Arran Walker <arran.walker@zopa.com>
|
||||
Aryeh Weinreb <aryehweinreb@gmail.com>
|
||||
Austin Parker <aparker@apprenda.com>
|
||||
Balu Dontu <bdontu@vmware.com>
|
||||
bastienbc <bastien.barbe.creuly@gmail.com>
|
||||
Benjamin Peterson <benjamin@python.org>
|
||||
Bob Killen <killen.bob@gmail.com>
|
||||
Brad Fitzpatrick <bradfitz@golang.org>
|
||||
Bruce Downs <bruceadowns@gmail.com>
|
||||
Cédric Blomart <cblomart@gmail.com>
|
||||
Chris Marchesi <chrism@vancluevertech.com>
|
||||
Christian Höltje <docwhat@gerf.org>
|
||||
Clint Greenwood <cgreenwood@vmware.com>
|
||||
CuiHaozhi <cuihaozhi@chinacloud.com.cn>
|
||||
Danny Lockard <danny.lockard@banno.com>
|
||||
Dave Smith-Uchida <dsmithuchida@vmware.com>
|
||||
Dave Tucker <dave@dtucker.co.uk>
|
||||
Davide Agnello <dagnello@hp.com>
|
||||
David Stark <dave@davidstark.name>
|
||||
Davinder Kumar <davinderk@vmware.com>
|
||||
Deric Crago <deric.crago@gmail.com>
|
||||
Doug MacEachern <dougm@vmware.com>
|
||||
Eloy Coto <eloy.coto@gmail.com>
|
||||
Eric Gray <egray@vmware.com>
|
||||
Eric Yutao <eric.yutao@gmail.com>
|
||||
Erik Hollensbe <github@hollensbe.org>
|
||||
Ethan Kaley <ethan.kaley@emc.com>
|
||||
Fabio Rapposelli <fabio@vmware.com>
|
||||
Faiyaz Ahmed <ahmedf@vmware.com>
|
||||
forkbomber <forkbomber@users.noreply.github.com>
|
||||
freebsdly <qinhuajun@outlook.com>
|
||||
Gavin Gray <gavin@infinio.com>
|
||||
Gavrie Philipson <gavrie.philipson@elastifile.com>
|
||||
George Hicken <ghicken@vmware.com>
|
||||
|
@ -38,24 +59,65 @@ Gerrit Renker <Gerrit.Renker@ctl.io>
|
|||
gthombare <gthombare@vmware.com>
|
||||
Hasan Mahmood <mahmoodh@vmware.com>
|
||||
Henrik Hodne <henrik@travis-ci.com>
|
||||
hui luo <luoh@vmware.com>
|
||||
Isaac Rodman <isaac@eyz.us>
|
||||
Ivan Porto Carrero <icarrero@vmware.com>
|
||||
James King <james.king@emc.com>
|
||||
Jason Kincl <jkincl@gmail.com>
|
||||
Jeremy Canady <jcanady@jackhenry.com>
|
||||
jeremy-clerc <jeremy@clerc.io>
|
||||
Jiatong Wang <wjiatong@vmware.com>
|
||||
João Pereira <joaodrp@gmail.com>
|
||||
Jonas Ausevicius <jonas.ausevicius@virtustream.com>
|
||||
Jorge Sevilla <jorge.sevilla@rstor.io>
|
||||
kayrus <kay.diam@gmail.com>
|
||||
Kevin George <georgek@vmware.com>
|
||||
leslie-qiwa <leslie.qiwa@gmail.com>
|
||||
Louie Jiang <jiangl@vmware.com>
|
||||
maplain <fangyuanl@vmware.com>
|
||||
Marc Carmier <mcarmier@gmail.com>
|
||||
Maria Ntalla <maria.ntalla@gmail.com>
|
||||
Marin Atanasov Nikolov <mnikolov@vmware.com>
|
||||
Mario Trangoni <mjtrangoni@gmail.com>
|
||||
Mark Peek <markpeek@vmware.com>
|
||||
Matt Clay <matt@mystile.com>
|
||||
Matthew Cosgrove <matthew.cosgrove@dell.com>
|
||||
Matt Moriarity <matt@mattmoriarity.com>
|
||||
Mevan Samaratunga <mevansam@gmail.com>
|
||||
Michal Jankowski <mjankowski@vmware.com>
|
||||
mingwei <mingwei@smartx.com>
|
||||
Nicolas Lamirault <nicolas.lamirault@gmail.com>
|
||||
Omar Kohl <omarkohl@gmail.com>
|
||||
Parham Alvani <parham.alvani@gmail.com>
|
||||
Pierre Gronlier <pierre.gronlier@corp.ovh.com>
|
||||
Pieter Noordhuis <pnoordhuis@vmware.com>
|
||||
prydin <prydin@vmware.com>
|
||||
rHermes <teodor_spaeren@riseup.net>
|
||||
Rowan Jacobs <rojacobs@pivotal.io>
|
||||
runner.mei <runner.mei@gmail.com>
|
||||
S.Çağlar Onur <conur@vmware.com>
|
||||
Sergey Ignatov <sergey.ignatov@jetbrains.com>
|
||||
Sten Feldman <exile@chamber.ee>
|
||||
Stepan Mazurov <smazurov@gmail.com>
|
||||
Steve Purcell <steve@sanityinc.com>
|
||||
Takaaki Furukawa <takaaki.frkw@gmail.com>
|
||||
Tamas Eger <tamas.eger@bitrise.io>
|
||||
tanishi <tanishi503@gmail.com>
|
||||
Ted Zlatanov <tzz@lifelogs.com>
|
||||
Thibaut Ackermann <thibaut.ackermann@alcatel-lucent.com>
|
||||
Tim McNamara <tim.mcnamara@canonical.com>
|
||||
Tjeu Kayim <15987676+TjeuKayim@users.noreply.github.com>
|
||||
Trevor Dawe <trevor.dawe@gmail.com>
|
||||
Uwe Bessle <Uwe.Bessle@iteratec.de>
|
||||
Vadim Egorov <vegorov@vmware.com>
|
||||
Vikram Krishnamurthy <vikramkrishnamu@vmware.com>
|
||||
Volodymyr Bobyr <pupsua@gmail.com>
|
||||
William Lam <info.virtuallyghetto@gmail.com>
|
||||
Witold Krecicki <wpk@culm.net>
|
||||
Yang Yang <yangy@vmware.com>
|
||||
ykakarap <yuva2811@gmail.com>
|
||||
Yuya Kusakabe <yuya.kusakabe@gmail.com>
|
||||
Zacharias Taubert <zacharias.taubert@gmail.com>
|
||||
Zach Tucker <ztucker@vmware.com>
|
||||
Zee Yang <zeey@vmware.com>
|
||||
zyuxin <zyuxin@vmware.com>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
FROM scratch
|
||||
LABEL maintainer="fabio@vmware.com"
|
||||
COPY govc /
|
||||
ENTRYPOINT [ "/govc" ]
|
|
@ -0,0 +1,4 @@
|
|||
FROM scratch
|
||||
LABEL maintainer="fabio@vmware.com"
|
||||
COPY vcsim /
|
||||
ENTRYPOINT [ "/vcsim" ]
|
|
@ -0,0 +1,60 @@
|
|||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
branch = "improvements"
|
||||
digest = "1:b183578c34fabccaf65f1a57d2efeec2086abdce1446978d69ab3a0016cb750c"
|
||||
name = "github.com/davecgh/go-xdr"
|
||||
packages = ["xdr2"]
|
||||
pruneopts = "NUT"
|
||||
revision = "4930550ba2e22f87187498acfd78348b15f4e7a8"
|
||||
source = "https://github.com/rasky/go-xdr"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:1ab18cf8c2084968d6dca0dd46fbda9efba08664ecd7957b63c7ca57bb2455df"
|
||||
name = "github.com/google/uuid"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "6a5e28554805e78ea6141142aba763936c4761c0"
|
||||
|
||||
[[projects]]
|
||||
branch = "govmomi"
|
||||
digest = "1:f49ed6cb2129e9a3ce9dde5037cb243b5849c0ec0c7973b9d1e987872d8b8cc6"
|
||||
name = "github.com/kr/pretty"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "2ee9d7453c02ef7fa518a83ae23644eb8872186a"
|
||||
source = "https://github.com/dougm/pretty"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:c3a7836b5904db0f8b609595b619916a6831cb35b8b714aec39f96d00c6155d8"
|
||||
name = "github.com/kr/text"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "7cafcd837844e784b526369c9bce262804aebc60"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:4bea31865971675c482ed875caeabe7d2182dcb47d52900b7da5236d66dc9970"
|
||||
name = "github.com/vmware/vmw-guestinfo"
|
||||
packages = [
|
||||
"bdoor",
|
||||
"message",
|
||||
"vmcheck",
|
||||
]
|
||||
pruneopts = "NUT"
|
||||
revision = "25eff159a728be87e103a0b8045e08273f4dbec4"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/davecgh/go-xdr/xdr2",
|
||||
"github.com/google/uuid",
|
||||
"github.com/kr/pretty",
|
||||
"github.com/vmware/vmw-guestinfo/message",
|
||||
"github.com/vmware/vmw-guestinfo/vmcheck",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
|
@ -0,0 +1,19 @@
|
|||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# Refer to https://github.com/toml-lang/toml for detailed TOML docs.
|
||||
|
||||
[prune]
|
||||
non-go = true
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
|
||||
[[constraint]]
|
||||
branch = "improvements"
|
||||
name = "github.com/davecgh/go-xdr"
|
||||
source = "https://github.com/rasky/go-xdr"
|
||||
|
||||
[[constraint]]
|
||||
branch = "govmomi"
|
||||
name = "github.com/kr/pretty"
|
||||
source = "https://github.com/dougm/pretty"
|
|
@ -1,4 +1,5 @@
|
|||
.PHONY: test
|
||||
GO ?= go
|
||||
pkgs = $(shell $(GO) list ./... | grep -v 'github.com/vmware/govmomi/vim25/xml')
|
||||
|
||||
all: check test
|
||||
|
||||
|
@ -6,19 +7,26 @@ check: goimports govet
|
|||
|
||||
goimports:
|
||||
@echo checking go imports...
|
||||
@go get golang.org/x/tools/cmd/goimports
|
||||
@command -v goimports >/dev/null 2>&1 || $(GO) get golang.org/x/tools/cmd/goimports
|
||||
@! goimports -d . 2>&1 | egrep -v '^$$'
|
||||
|
||||
govet:
|
||||
@echo checking go vet...
|
||||
@go tool vet -structtags=false -methods=false $$(find . -mindepth 1 -maxdepth 1 -type d -not -name vendor)
|
||||
|
||||
test:
|
||||
go test -v $(TEST_OPTS) ./...
|
||||
@$(GO) vet -structtag=false -methods=false $(pkgs)
|
||||
|
||||
install:
|
||||
go install -v github.com/vmware/govmomi/govc
|
||||
go install -v github.com/vmware/govmomi/vcsim
|
||||
$(MAKE) -C govc install
|
||||
$(MAKE) -C vcsim install
|
||||
|
||||
go-test:
|
||||
GORACE=history_size=5 $(GO) test -timeout 5m -count 1 -race -v $(TEST_OPTS) ./...
|
||||
|
||||
govc-test: install
|
||||
./govc/test/images/update.sh
|
||||
(cd govc/test && ./vendor/github.com/sstephenson/bats/libexec/bats -t .)
|
||||
|
||||
.PHONY: test
|
||||
test: go-test govc-test
|
||||
|
||||
doc: install
|
||||
./govc/usage.sh > ./govc/USAGE.md
|
||||
|
|
|
@ -5,14 +5,19 @@
|
|||
|
||||
A Go library for interacting with VMware vSphere APIs (ESXi and/or vCenter).
|
||||
|
||||
For `govc`, a CLI built on top of govmomi, check out the [govc](./govc) directory and [USAGE](./govc/USAGE.md) document.
|
||||
In addition to the vSphere API client, this repository includes:
|
||||
|
||||
* [govc](./govc) - vSphere CLI
|
||||
|
||||
* [vcsim](./vcsim) - vSphere API mock framework
|
||||
|
||||
* [toolbox](./toolbox) - VM guest tools framework
|
||||
|
||||
## Compatibility
|
||||
|
||||
This library is built for and tested against ESXi and vCenter 5.5, 6.0 and 6.5.
|
||||
This library is built for and tested against ESXi and vCenter 6.0, 6.5 and 6.7.
|
||||
|
||||
If you're able to use it against older versions of ESXi and/or vCenter, please
|
||||
leave a note and we'll include it in this compatibility list.
|
||||
It may work with versions 5.5 and 5.1, but neither are officially supported.
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -25,17 +30,12 @@ See [godoc.org][godoc] for documentation.
|
|||
|
||||
[apiref]:http://pubs.vmware.com/vsphere-6-5/index.jsp#com.vmware.wssdk.apiref.doc/right-pane.html
|
||||
[godoc]:http://godoc.org/github.com/vmware/govmomi
|
||||
[drone]:https://drone.io
|
||||
[dronesrc]:https://github.com/drone/drone
|
||||
[dronecli]:http://readme.drone.io/devs/cli/
|
||||
|
||||
#### Building with CI
|
||||
Merges to this repository will trigger builds in both Travis and [Drone][drone].
|
||||
## Installation
|
||||
|
||||
To build locally with Drone:
|
||||
- Ensure that you have Docker 1.6 or higher installed.
|
||||
- Install the [Drone command line tools][dronecli].
|
||||
- Run `drone exec` from within the root directory of the govmomi repository.
|
||||
```sh
|
||||
go get -u github.com/vmware/govmomi
|
||||
```
|
||||
|
||||
## Discussion
|
||||
|
||||
|
@ -53,9 +53,21 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes.
|
|||
|
||||
* [Docker Machine](https://github.com/docker/machine/tree/master/drivers/vmwarevsphere)
|
||||
|
||||
* [Docker InfraKit](https://github.com/docker/infrakit/tree/master/pkg/provider/vsphere)
|
||||
|
||||
* [Docker LinuxKit](https://github.com/linuxkit/linuxkit/tree/master/src/cmd/linuxkit)
|
||||
|
||||
* [Kubernetes](https://github.com/kubernetes/kubernetes/tree/master/pkg/cloudprovider/providers/vsphere)
|
||||
|
||||
* [Terraform](https://github.com/hashicorp/terraform/tree/master/builtin/providers/vsphere)
|
||||
* [Kubernetes Cloud Provider](https://github.com/kubernetes/cloud-provider-vsphere)
|
||||
|
||||
* [Kubernetes Cluster API](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere)
|
||||
|
||||
* [Kubernetes kops](https://github.com/kubernetes/kops/tree/master/upup/pkg/fi/cloudup/vsphere)
|
||||
|
||||
* [Terraform](https://github.com/terraform-providers/terraform-provider-vsphere)
|
||||
|
||||
* [Packer](https://github.com/jetbrains-infra/packer-builder-vsphere)
|
||||
|
||||
* [VMware VIC Engine](https://github.com/vmware/vic)
|
||||
|
||||
|
@ -67,6 +79,12 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes.
|
|||
|
||||
* [Libretto](https://github.com/apcera/libretto/tree/master/virtualmachine/vsphere)
|
||||
|
||||
* [Telegraf](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/vsphere)
|
||||
|
||||
* [Open Storage](https://github.com/libopenstorage/openstorage/tree/master/pkg/storageops/vsphere)
|
||||
|
||||
* [Juju](https://github.com/juju/juju)
|
||||
|
||||
## Related projects
|
||||
|
||||
* [rbvmomi](https://github.com/vmware/rbvmomi)
|
||||
|
@ -75,4 +93,4 @@ Refer to the [CHANGELOG](CHANGELOG.md) for version to version changes.
|
|||
|
||||
## License
|
||||
|
||||
govmomi is available under the [Apache 2 license](LICENSE).
|
||||
govmomi is available under the [Apache 2 license](LICENSE.txt).
|
||||
|
|
|
@ -58,7 +58,6 @@ package govmomi
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net/url"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
|
@ -99,41 +98,11 @@ func NewClient(ctx context.Context, u *url.URL, insecure bool) (*Client, error)
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// NewClientWithCertificate creates a new client from a URL. The client authenticates with the
|
||||
// server with the certificate before returning if the URL contains user information.
|
||||
func NewClientWithCertificate(ctx context.Context, u *url.URL, insecure bool, cert tls.Certificate) (*Client, error) {
|
||||
soapClient := soap.NewClient(u, insecure)
|
||||
soapClient.SetCertificate(cert)
|
||||
vimClient, err := vim25.NewClient(ctx, soapClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c := &Client{
|
||||
Client: vimClient,
|
||||
SessionManager: session.NewManager(vimClient),
|
||||
}
|
||||
|
||||
if u.User != nil {
|
||||
err = c.LoginExtensionByCertificate(ctx, u.User.Username(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Login dispatches to the SessionManager.
|
||||
func (c *Client) Login(ctx context.Context, u *url.Userinfo) error {
|
||||
return c.SessionManager.Login(ctx, u)
|
||||
}
|
||||
|
||||
// Login dispatches to the SessionManager.
|
||||
func (c *Client) LoginExtensionByCertificate(ctx context.Context, key string, locale string) error {
|
||||
return c.SessionManager.LoginExtensionByCertificate(ctx, key, locale)
|
||||
}
|
||||
|
||||
// Logout dispatches to the SessionManager.
|
||||
func (c *Client) Logout(ctx context.Context) error {
|
||||
// Close any idle connections after logging out.
|
||||
|
|
|
@ -38,16 +38,26 @@ type Finder struct {
|
|||
folders *object.DatacenterFolders
|
||||
}
|
||||
|
||||
func NewFinder(client *vim25.Client, all bool) *Finder {
|
||||
func NewFinder(client *vim25.Client, all ...bool) *Finder {
|
||||
props := false
|
||||
if len(all) == 1 {
|
||||
props = all[0]
|
||||
}
|
||||
|
||||
f := &Finder{
|
||||
client: client,
|
||||
si: object.NewSearchIndex(client),
|
||||
r: recurser{
|
||||
Collector: property.DefaultCollector(client),
|
||||
All: all,
|
||||
All: props,
|
||||
},
|
||||
}
|
||||
|
||||
if len(all) == 0 {
|
||||
// attempt to avoid SetDatacenter() requirement
|
||||
f.dc, _ = f.DefaultDatacenter(context.Background())
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
|
@ -253,7 +263,7 @@ func (f *Finder) managedObjectList(ctx context.Context, path string, tl bool, in
|
|||
fn = f.dcReference
|
||||
}
|
||||
|
||||
if len(path) == 0 {
|
||||
if path == "" {
|
||||
path = "."
|
||||
}
|
||||
|
||||
|
@ -625,6 +635,15 @@ func (f *Finder) ClusterComputeResourceList(ctx context.Context, path string) ([
|
|||
return ccrs, nil
|
||||
}
|
||||
|
||||
func (f *Finder) DefaultClusterComputeResource(ctx context.Context) (*object.ClusterComputeResource, error) {
|
||||
cr, err := f.ClusterComputeResource(ctx, "*")
|
||||
if err != nil {
|
||||
return nil, toDefaultError(err)
|
||||
}
|
||||
|
||||
return cr, nil
|
||||
}
|
||||
|
||||
func (f *Finder) ClusterComputeResource(ctx context.Context, path string) (*object.ClusterComputeResource, error) {
|
||||
ccrs, err := f.ClusterComputeResourceList(ctx, path)
|
||||
if err != nil {
|
||||
|
@ -638,6 +657,18 @@ func (f *Finder) ClusterComputeResource(ctx context.Context, path string) (*obje
|
|||
return ccrs[0], nil
|
||||
}
|
||||
|
||||
func (f *Finder) ClusterComputeResourceOrDefault(ctx context.Context, path string) (*object.ClusterComputeResource, error) {
|
||||
if path != "" {
|
||||
cr, err := f.ClusterComputeResource(ctx, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cr, nil
|
||||
}
|
||||
|
||||
return f.DefaultClusterComputeResource(ctx)
|
||||
}
|
||||
|
||||
func (f *Finder) HostSystemList(ctx context.Context, path string) ([]*object.HostSystem, error) {
|
||||
s := &spec{
|
||||
Relative: f.hostFolder,
|
||||
|
@ -695,7 +726,7 @@ func (f *Finder) HostSystem(ctx context.Context, path string) (*object.HostSyste
|
|||
}
|
||||
|
||||
func (f *Finder) DefaultHostSystem(ctx context.Context) (*object.HostSystem, error) {
|
||||
hs, err := f.HostSystem(ctx, "*/*")
|
||||
hs, err := f.HostSystem(ctx, "*")
|
||||
if err != nil {
|
||||
return nil, toDefaultError(err)
|
||||
}
|
||||
|
@ -885,6 +916,12 @@ func (f *Finder) DefaultFolder(ctx context.Context) (*object.Folder, error) {
|
|||
}
|
||||
folder := object.NewFolder(f.client, ref.Reference())
|
||||
|
||||
// Set the InventoryPath of the newly created folder object
|
||||
// The default foler becomes the datacenter's "vm" folder.
|
||||
// The "vm" folder always exists for a datacenter. It cannot be
|
||||
// removed or replaced
|
||||
folder.SetInventoryPath(path.Join(f.dc.InventoryPath, "vm"))
|
||||
|
||||
return folder, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ func (r recurser) List(ctx context.Context, s *spec, root list.Element, parts []
|
|||
}
|
||||
|
||||
if !matched {
|
||||
matched = strings.HasSuffix(e.Path, path.Join(all...))
|
||||
matched = strings.HasSuffix(e.Path, "/"+path.Join(all...))
|
||||
if matched {
|
||||
// name contains a '/'
|
||||
out = append(out, e)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module github.com/vmware/govmomi
|
||||
|
||||
replace github.com/davecgh/go-xdr => github.com/rasky/go-xdr v0.0.0-20170217172119-4930550ba2e2
|
||||
|
||||
replace github.com/kr/pretty v0.1.0 => github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892
|
||||
github.com/google/uuid v0.0.0-20170306145142-6a5e28554805
|
||||
github.com/kr/pretty v0.1.0
|
||||
github.com/kr/text v0.1.0 // indirect
|
||||
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728
|
||||
)
|
|
@ -0,0 +1,13 @@
|
|||
github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892 h1:qg9VbHo1TlL0KDM0vYvBG9EY0X0Yku5WYIPoFWt8f6o=
|
||||
github.com/davecgh/go-xdr v0.0.0-20161123171359-e6a2ba005892/go.mod h1:CTDl0pzVzE5DEzZhPfvhY/9sPFMQIxaJ9VAMs9AagrE=
|
||||
github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02 h1:tR3jsKPiO/mb6ntzk/dJlHZtm37CPfVp1C9KIo534+4=
|
||||
github.com/dougm/pretty v0.0.0-20171025230240-2ee9d7453c02/go.mod h1:7NQ3kWOx2cZOSjtcveTa5nqupVr2s6/83sG+rTlI7uA=
|
||||
github.com/google/uuid v0.0.0-20170306145142-6a5e28554805 h1:skl44gU1qEIcRpwKjb9bhlRwjvr96wLdvpTogCBBJe8=
|
||||
github.com/google/uuid v0.0.0-20170306145142-6a5e28554805/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/rasky/go-xdr v0.0.0-20170217172119-4930550ba2e2 h1:lbe6PJ3nOQAUvpx9P3GtsQ/jyNBOHLV+cj2++uZrpa4=
|
||||
github.com/rasky/go-xdr v0.0.0-20170217172119-4930550ba2e2/go.mod h1:Nfe4efndBz4TibWycNE+lqyJZiMX4ycx+QKV8Ta0f/o=
|
||||
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728 h1:sH9mEk+flyDxiUa5BuPiuhDETMbzrt9A20I2wktMvRQ=
|
||||
github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk=
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
Copyright (c) 2015-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 nfc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/soap"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type Lease struct {
|
||||
types.ManagedObjectReference
|
||||
|
||||
c *vim25.Client
|
||||
}
|
||||
|
||||
func NewLease(c *vim25.Client, ref types.ManagedObjectReference) *Lease {
|
||||
return &Lease{ref, c}
|
||||
}
|
||||
|
||||
// Abort wraps methods.Abort
|
||||
func (l *Lease) Abort(ctx context.Context, fault *types.LocalizedMethodFault) error {
|
||||
req := types.HttpNfcLeaseAbort{
|
||||
This: l.Reference(),
|
||||
Fault: fault,
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseAbort(ctx, l.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Complete wraps methods.Complete
|
||||
func (l *Lease) Complete(ctx context.Context) error {
|
||||
req := types.HttpNfcLeaseComplete{
|
||||
This: l.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseComplete(ctx, l.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetManifest wraps methods.GetManifest
|
||||
func (l *Lease) GetManifest(ctx context.Context) error {
|
||||
req := types.HttpNfcLeaseGetManifest{
|
||||
This: l.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseGetManifest(ctx, l.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Progress wraps methods.Progress
|
||||
func (l *Lease) Progress(ctx context.Context, percent int32) error {
|
||||
req := types.HttpNfcLeaseProgress{
|
||||
This: l.Reference(),
|
||||
Percent: percent,
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseProgress(ctx, l.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type LeaseInfo struct {
|
||||
types.HttpNfcLeaseInfo
|
||||
|
||||
Items []FileItem
|
||||
}
|
||||
|
||||
func (l *Lease) newLeaseInfo(li *types.HttpNfcLeaseInfo, items []types.OvfFileItem) (*LeaseInfo, error) {
|
||||
info := &LeaseInfo{
|
||||
HttpNfcLeaseInfo: *li,
|
||||
}
|
||||
|
||||
for _, device := range li.DeviceUrl {
|
||||
u, err := l.c.ParseURL(device.Url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if device.SslThumbprint != "" {
|
||||
// TODO: prefer host management IP
|
||||
l.c.SetThumbprint(u.Host, device.SslThumbprint)
|
||||
}
|
||||
|
||||
if len(items) == 0 {
|
||||
// this is an export
|
||||
item := types.OvfFileItem{
|
||||
DeviceId: device.Key,
|
||||
Path: device.TargetId,
|
||||
Size: device.FileSize,
|
||||
}
|
||||
|
||||
if item.Size == 0 {
|
||||
item.Size = li.TotalDiskCapacityInKB * 1024
|
||||
}
|
||||
|
||||
if item.Path == "" {
|
||||
item.Path = path.Base(device.Url)
|
||||
}
|
||||
|
||||
info.Items = append(info.Items, NewFileItem(u, item))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// this is an import
|
||||
for _, item := range items {
|
||||
if device.ImportKey == item.DeviceId {
|
||||
info.Items = append(info.Items, NewFileItem(u, item))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (l *Lease) Wait(ctx context.Context, items []types.OvfFileItem) (*LeaseInfo, error) {
|
||||
var lease mo.HttpNfcLease
|
||||
|
||||
pc := property.DefaultCollector(l.c)
|
||||
err := property.Wait(ctx, pc, l.Reference(), []string{"state", "info", "error"}, func(pc []types.PropertyChange) bool {
|
||||
done := false
|
||||
|
||||
for _, c := range pc {
|
||||
if c.Val == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
switch c.Name {
|
||||
case "error":
|
||||
val := c.Val.(types.LocalizedMethodFault)
|
||||
lease.Error = &val
|
||||
done = true
|
||||
case "info":
|
||||
val := c.Val.(types.HttpNfcLeaseInfo)
|
||||
lease.Info = &val
|
||||
case "state":
|
||||
lease.State = c.Val.(types.HttpNfcLeaseState)
|
||||
if lease.State != types.HttpNfcLeaseStateInitializing {
|
||||
done = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return done
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if lease.State == types.HttpNfcLeaseStateReady {
|
||||
return l.newLeaseInfo(lease.Info, items)
|
||||
}
|
||||
|
||||
if lease.Error != nil {
|
||||
return nil, errors.New(lease.Error.LocalizedMessage)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unexpected nfc lease state: %s", lease.State)
|
||||
}
|
||||
|
||||
func (l *Lease) StartUpdater(ctx context.Context, info *LeaseInfo) *LeaseUpdater {
|
||||
return newLeaseUpdater(ctx, l, info)
|
||||
}
|
||||
|
||||
func (l *Lease) Upload(ctx context.Context, item FileItem, f io.Reader, opts soap.Upload) error {
|
||||
if opts.Progress == nil {
|
||||
opts.Progress = item
|
||||
}
|
||||
|
||||
// Non-disk files (such as .iso) use the PUT method.
|
||||
// Overwrite: t header is also required in this case (ovftool does the same)
|
||||
if item.Create {
|
||||
opts.Method = "PUT"
|
||||
opts.Headers = map[string]string{
|
||||
"Overwrite": "t",
|
||||
}
|
||||
} else {
|
||||
opts.Method = "POST"
|
||||
opts.Type = "application/x-vnd.vmware-streamVmdk"
|
||||
}
|
||||
|
||||
return l.c.Upload(ctx, f, item.URL, &opts)
|
||||
}
|
||||
|
||||
func (l *Lease) DownloadFile(ctx context.Context, file string, item FileItem, opts soap.Download) error {
|
||||
if opts.Progress == nil {
|
||||
opts.Progress = item
|
||||
}
|
||||
|
||||
return l.c.DownloadFile(ctx, file, item.URL, &opts)
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
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 nfc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/url"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/progress"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type FileItem struct {
|
||||
types.OvfFileItem
|
||||
URL *url.URL
|
||||
|
||||
ch chan progress.Report
|
||||
}
|
||||
|
||||
func NewFileItem(u *url.URL, item types.OvfFileItem) FileItem {
|
||||
return FileItem{
|
||||
OvfFileItem: item,
|
||||
URL: u,
|
||||
ch: make(chan progress.Report),
|
||||
}
|
||||
}
|
||||
|
||||
func (o FileItem) Sink() chan<- progress.Report {
|
||||
return o.ch
|
||||
}
|
||||
|
||||
// File converts the FileItem.OvfFileItem to an OvfFile
|
||||
func (o FileItem) File() types.OvfFile {
|
||||
return types.OvfFile{
|
||||
DeviceId: o.DeviceId,
|
||||
Path: o.Path,
|
||||
Size: o.Size,
|
||||
}
|
||||
}
|
||||
|
||||
type LeaseUpdater struct {
|
||||
pos int64 // Number of bytes (keep first to ensure 64 bit alignment)
|
||||
total int64 // Total number of bytes (keep first to ensure 64 bit alignment)
|
||||
|
||||
lease *Lease
|
||||
|
||||
done chan struct{} // When lease updater should stop
|
||||
|
||||
wg sync.WaitGroup // Track when update loop is done
|
||||
}
|
||||
|
||||
func newLeaseUpdater(ctx context.Context, lease *Lease, info *LeaseInfo) *LeaseUpdater {
|
||||
l := LeaseUpdater{
|
||||
lease: lease,
|
||||
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
|
||||
for _, item := range info.Items {
|
||||
l.total += item.Size
|
||||
go l.waitForProgress(item)
|
||||
}
|
||||
|
||||
// Kickstart update loop
|
||||
l.wg.Add(1)
|
||||
go l.run()
|
||||
|
||||
return &l
|
||||
}
|
||||
|
||||
func (l *LeaseUpdater) waitForProgress(item FileItem) {
|
||||
var pos, total int64
|
||||
|
||||
total = item.Size
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-l.done:
|
||||
return
|
||||
case p, ok := <-item.ch:
|
||||
// Return in case of error
|
||||
if ok && p.Error() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !ok {
|
||||
// Last element on the channel, add to total
|
||||
atomic.AddInt64(&l.pos, total-pos)
|
||||
return
|
||||
}
|
||||
|
||||
// Approximate progress in number of bytes
|
||||
x := int64(float32(total) * (p.Percentage() / 100.0))
|
||||
atomic.AddInt64(&l.pos, x-pos)
|
||||
pos = x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LeaseUpdater) run() {
|
||||
defer l.wg.Done()
|
||||
|
||||
tick := time.NewTicker(2 * time.Second)
|
||||
defer tick.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-l.done:
|
||||
return
|
||||
case <-tick.C:
|
||||
// From the vim api HttpNfcLeaseProgress(percent) doc, percent ==
|
||||
// "Completion status represented as an integer in the 0-100 range."
|
||||
// Always report the current value of percent, as it will renew the
|
||||
// lease even if the value hasn't changed or is 0.
|
||||
percent := int32(float32(100*atomic.LoadInt64(&l.pos)) / float32(l.total))
|
||||
err := l.lease.Progress(context.TODO(), percent)
|
||||
if err != nil {
|
||||
log.Printf("NFC lease progress: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LeaseUpdater) Done() {
|
||||
close(l.done)
|
||||
l.wg.Wait()
|
||||
}
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
|
@ -34,19 +35,15 @@ func NewClusterComputeResource(c *vim25.Client, ref types.ManagedObjectReference
|
|||
}
|
||||
}
|
||||
|
||||
func (c ClusterComputeResource) ReconfigureCluster(ctx context.Context, spec types.ClusterConfigSpec) (*Task, error) {
|
||||
req := types.ReconfigureCluster_Task{
|
||||
This: c.Reference(),
|
||||
Spec: spec,
|
||||
Modify: true,
|
||||
}
|
||||
func (c ClusterComputeResource) Configuration(ctx context.Context) (*types.ClusterConfigInfoEx, error) {
|
||||
var obj mo.ClusterComputeResource
|
||||
|
||||
res, err := methods.ReconfigureCluster_Task(ctx, c.c, &req)
|
||||
err := c.Properties(ctx, c.Reference(), []string{"configurationEx"}, &obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(c.c, res.Returnval), nil
|
||||
return obj.ConfigurationEx.(*types.ClusterConfigInfoEx), nil
|
||||
}
|
||||
|
||||
func (c ClusterComputeResource) AddHost(ctx context.Context, spec types.HostConnectSpec, asConnected bool, license *string, resourcePool *types.ManagedObjectReference) (*Task, error) {
|
||||
|
@ -72,12 +69,18 @@ func (c ClusterComputeResource) AddHost(ctx context.Context, spec types.HostConn
|
|||
return NewTask(c.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (c ClusterComputeResource) Destroy(ctx context.Context) (*Task, error) {
|
||||
req := types.Destroy_Task{
|
||||
func (c ClusterComputeResource) MoveInto(ctx context.Context, hosts ...*HostSystem) (*Task, error) {
|
||||
req := types.MoveInto_Task{
|
||||
This: c.Reference(),
|
||||
}
|
||||
|
||||
res, err := methods.Destroy_Task(ctx, c.c, &req)
|
||||
hostReferences := make([]types.ManagedObjectReference, len(hosts))
|
||||
for i, host := range hosts {
|
||||
hostReferences[i] = host.Reference()
|
||||
}
|
||||
req.Host = hostReferences
|
||||
|
||||
res, err := methods.MoveInto_Task(ctx, c.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -85,9 +85,22 @@ func (c Common) ObjectName(ctx context.Context) (string, error) {
|
|||
return "", err
|
||||
}
|
||||
|
||||
return o.Name, nil
|
||||
if o.Name != "" {
|
||||
return o.Name, nil
|
||||
}
|
||||
|
||||
// Network has its own "name" field...
|
||||
var n mo.Network
|
||||
|
||||
err = c.Properties(ctx, c.Reference(), []string{"name"}, &n)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return n.Name, nil
|
||||
}
|
||||
|
||||
// Properties is a wrapper for property.DefaultCollector().RetrieveOne()
|
||||
func (c Common) Properties(ctx context.Context, r types.ManagedObjectReference, ps []string, dst interface{}) error {
|
||||
return property.DefaultCollector(c.c).RetrieveOne(ctx, r, ps, dst)
|
||||
}
|
||||
|
@ -118,3 +131,14 @@ func (c Common) Rename(ctx context.Context, name string) (*Task, error) {
|
|||
|
||||
return NewTask(c.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (c Common) SetCustomValue(ctx context.Context, key string, value string) error {
|
||||
req := types.SetCustomValue{
|
||||
This: c.Reference(),
|
||||
Key: key,
|
||||
Value: value,
|
||||
}
|
||||
|
||||
_, err := methods.SetCustomValue(ctx, c.c, &req)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -109,16 +109,3 @@ func (c ComputeResource) Reconfigure(ctx context.Context, spec types.BaseCompute
|
|||
|
||||
return NewTask(c.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (c ComputeResource) Destroy(ctx context.Context) (*Task, error) {
|
||||
req := types.Destroy_Task{
|
||||
This: c.Reference(),
|
||||
}
|
||||
|
||||
res, err := methods.Destroy_Task(ctx, c.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(c.c, res.Returnval), nil
|
||||
}
|
||||
|
|
|
@ -102,7 +102,9 @@ func (m CustomFieldsManager) Set(ctx context.Context, entity types.ManagedObject
|
|||
return err
|
||||
}
|
||||
|
||||
func (m CustomFieldsManager) Field(ctx context.Context) ([]types.CustomFieldDef, error) {
|
||||
type CustomFieldDefList []types.CustomFieldDef
|
||||
|
||||
func (m CustomFieldsManager) Field(ctx context.Context) (CustomFieldDefList, error) {
|
||||
var fm mo.CustomFieldsManager
|
||||
|
||||
err := m.Properties(ctx, m.Reference(), []string{"field"}, &fm)
|
||||
|
@ -113,19 +115,19 @@ func (m CustomFieldsManager) Field(ctx context.Context) ([]types.CustomFieldDef,
|
|||
return fm.Field, nil
|
||||
}
|
||||
|
||||
func (m CustomFieldsManager) FindKey(ctx context.Context, key string) (int32, error) {
|
||||
func (m CustomFieldsManager) FindKey(ctx context.Context, name string) (int32, error) {
|
||||
field, err := m.Field(ctx)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
for _, def := range field {
|
||||
if def.Name == key {
|
||||
if def.Name == name {
|
||||
return def.Key, nil
|
||||
}
|
||||
}
|
||||
|
||||
k, err := strconv.Atoi(key)
|
||||
k, err := strconv.Atoi(name)
|
||||
if err == nil {
|
||||
// assume literal int key
|
||||
return int32(k), nil
|
||||
|
@ -133,3 +135,12 @@ func (m CustomFieldsManager) FindKey(ctx context.Context, key string) (int32, er
|
|||
|
||||
return -1, ErrKeyNameNotFound
|
||||
}
|
||||
|
||||
func (l CustomFieldDefList) ByKey(key int32) *types.CustomFieldDef {
|
||||
for _, def := range l {
|
||||
if def.Key == key {
|
||||
return &def
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -88,3 +88,42 @@ func (d Datacenter) Destroy(ctx context.Context) (*Task, error) {
|
|||
|
||||
return NewTask(d.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
// PowerOnVM powers on multiple virtual machines with a single vCenter call.
|
||||
// If called against ESX, serially powers on the list of VMs and the returned *Task will always be nil.
|
||||
func (d Datacenter) PowerOnVM(ctx context.Context, vm []types.ManagedObjectReference, option ...types.BaseOptionValue) (*Task, error) {
|
||||
if d.Client().IsVC() {
|
||||
req := types.PowerOnMultiVM_Task{
|
||||
This: d.Reference(),
|
||||
Vm: vm,
|
||||
Option: option,
|
||||
}
|
||||
|
||||
res, err := methods.PowerOnMultiVM_Task(ctx, d.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(d.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
for _, ref := range vm {
|
||||
obj := NewVirtualMachine(d.Client(), ref)
|
||||
task, err := obj.PowerOn(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = task.Wait(ctx)
|
||||
if err != nil {
|
||||
// Ignore any InvalidPowerState fault, as it indicates the VM is already powered on
|
||||
if f, ok := err.(types.HasFault); ok {
|
||||
if _, ok = f.Fault().(*types.InvalidPowerState); !ok {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -17,17 +17,16 @@ limitations under the License.
|
|||
package object
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/session"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
|
@ -69,6 +68,11 @@ func NewDatastore(c *vim25.Client, ref types.ManagedObjectReference) *Datastore
|
|||
}
|
||||
|
||||
func (d Datastore) Path(path string) string {
|
||||
var p DatastorePath
|
||||
if p.FromString(path) {
|
||||
return p.String() // already in "[datastore] path" format
|
||||
}
|
||||
|
||||
return (&DatastorePath{
|
||||
Datastore: d.Name(),
|
||||
Path: path,
|
||||
|
@ -284,7 +288,7 @@ func (d Datastore) Upload(ctx context.Context, f io.Reader, path string, param *
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.Client().Upload(f, u, p)
|
||||
return d.Client().Upload(ctx, f, u, p)
|
||||
}
|
||||
|
||||
// UploadFile via soap.Upload with an http service ticket
|
||||
|
@ -293,7 +297,7 @@ func (d Datastore) UploadFile(ctx context.Context, file string, path string, par
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.Client().UploadFile(file, u, p)
|
||||
return d.Client().UploadFile(ctx, file, u, p)
|
||||
}
|
||||
|
||||
// Download via soap.Download with an http service ticket
|
||||
|
@ -302,7 +306,7 @@ func (d Datastore) Download(ctx context.Context, path string, param *soap.Downlo
|
|||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return d.Client().Download(u, p)
|
||||
return d.Client().Download(ctx, u, p)
|
||||
}
|
||||
|
||||
// DownloadFile via soap.Download with an http service ticket
|
||||
|
@ -311,7 +315,7 @@ func (d Datastore) DownloadFile(ctx context.Context, path string, file string, p
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.Client().DownloadFile(file, u, p)
|
||||
return d.Client().DownloadFile(ctx, file, u, p)
|
||||
}
|
||||
|
||||
// AttachedHosts returns hosts that have this Datastore attached, accessible and writable.
|
||||
|
@ -406,12 +410,9 @@ func (d Datastore) Stat(ctx context.Context, file string) (types.BaseFileInfo, e
|
|||
|
||||
info, err := task.WaitForResult(ctx, nil)
|
||||
if err != nil {
|
||||
if info == nil || info.Error != nil {
|
||||
_, ok := info.Error.Fault.(*types.FileNotFound)
|
||||
if ok {
|
||||
// FileNotFound means the base path doesn't exist.
|
||||
return nil, DatastoreNoSuchDirectoryError{"stat", dsPath}
|
||||
}
|
||||
if types.IsFileNotFound(err) {
|
||||
// FileNotFound means the base path doesn't exist.
|
||||
return nil, DatastoreNoSuchDirectoryError{"stat", dsPath}
|
||||
}
|
||||
|
||||
return nil, err
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/soap"
|
||||
|
@ -171,7 +172,7 @@ func (f *DatastoreFile) Stat() (os.FileInfo, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := f.d.Client().DownloadRequest(u, p)
|
||||
res, err := f.d.Client().DownloadRequest(f.ctx, u, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ func (f *DatastoreFile) get() (io.Reader, error) {
|
|||
}
|
||||
}
|
||||
|
||||
res, err := f.d.Client().DownloadRequest(u, p)
|
||||
res, err := f.d.Client().DownloadRequest(f.ctx, u, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -296,10 +297,8 @@ func (f *DatastoreFile) TailFunc(lines int, include func(line int, message strin
|
|||
|
||||
nread = bsize + remain
|
||||
eof = true
|
||||
} else {
|
||||
if pos, err = f.Seek(offset, io.SeekEnd); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if pos, err = f.Seek(offset, io.SeekEnd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = io.CopyN(buf, f, nread); err != nil {
|
||||
|
@ -347,6 +346,7 @@ type followDatastoreFile struct {
|
|||
r *DatastoreFile
|
||||
c chan struct{}
|
||||
i time.Duration
|
||||
o sync.Once
|
||||
}
|
||||
|
||||
// Read reads up to len(b) bytes from the DatastoreFile being followed.
|
||||
|
@ -398,11 +398,15 @@ func (f *followDatastoreFile) Read(p []byte) (int, error) {
|
|||
|
||||
// Close will stop Follow polling and close the underlying DatastoreFile.
|
||||
func (f *followDatastoreFile) Close() error {
|
||||
close(f.c)
|
||||
f.o.Do(func() { close(f.c) })
|
||||
return nil
|
||||
}
|
||||
|
||||
// Follow returns an io.ReadCloser to stream the file contents as data is appended.
|
||||
func (f *DatastoreFile) Follow(interval time.Duration) io.ReadCloser {
|
||||
return &followDatastoreFile{f, make(chan struct{}), interval}
|
||||
return &followDatastoreFile{
|
||||
r: f,
|
||||
c: make(chan struct{}),
|
||||
i: interval,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2017-2018 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.
|
||||
|
@ -26,6 +26,7 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/progress"
|
||||
"github.com/vmware/govmomi/vim25/soap"
|
||||
)
|
||||
|
||||
|
@ -36,7 +37,8 @@ type DatastoreFileManager struct {
|
|||
FileManager *FileManager
|
||||
VirtualDiskManager *VirtualDiskManager
|
||||
|
||||
Force bool
|
||||
Force bool
|
||||
DatacenterTarget *Datacenter
|
||||
}
|
||||
|
||||
// NewFileManager creates a new instance of DatastoreFileManager
|
||||
|
@ -49,11 +51,25 @@ func (d Datastore) NewFileManager(dc *Datacenter, force bool) *DatastoreFileMana
|
|||
FileManager: NewFileManager(c),
|
||||
VirtualDiskManager: NewVirtualDiskManager(c),
|
||||
Force: force,
|
||||
DatacenterTarget: dc,
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *DatastoreFileManager) WithProgress(ctx context.Context, s progress.Sinker) context.Context {
|
||||
return context.WithValue(ctx, m, s)
|
||||
}
|
||||
|
||||
func (m *DatastoreFileManager) wait(ctx context.Context, task *Task) error {
|
||||
var logger progress.Sinker
|
||||
if s, ok := ctx.Value(m).(progress.Sinker); ok {
|
||||
logger = s
|
||||
}
|
||||
_, err := task.WaitForResult(ctx, logger)
|
||||
return err
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
@ -73,7 +89,7 @@ func (m *DatastoreFileManager) DeleteFile(ctx context.Context, name string) erro
|
|||
return err
|
||||
}
|
||||
|
||||
return task.Wait(ctx)
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// DeleteVirtualDisk calls VirtualDiskManager.DeleteVirtualDisk
|
||||
|
@ -94,7 +110,74 @@ func (m *DatastoreFileManager) DeleteVirtualDisk(ctx context.Context, name strin
|
|||
return err
|
||||
}
|
||||
|
||||
return task.Wait(ctx)
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// CopyFile calls FileManager.CopyDatastoreFile
|
||||
func (m *DatastoreFileManager) CopyFile(ctx context.Context, src string, dst string) error {
|
||||
srcp := m.Path(src)
|
||||
dstp := m.Path(dst)
|
||||
|
||||
task, err := m.FileManager.CopyDatastoreFile(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// Copy dispatches to the appropriate FileManager or VirtualDiskManager Copy method based on file name extension
|
||||
func (m *DatastoreFileManager) Copy(ctx context.Context, src string, dst string) error {
|
||||
srcp := m.Path(src)
|
||||
dstp := m.Path(dst)
|
||||
|
||||
f := m.FileManager.CopyDatastoreFile
|
||||
|
||||
if srcp.IsVMDK() {
|
||||
// types.VirtualDiskSpec=nil as it is not implemented by vCenter
|
||||
f = func(ctx context.Context, src string, srcDC *Datacenter, dst string, dstDC *Datacenter, force bool) (*Task, error) {
|
||||
return m.VirtualDiskManager.CopyVirtualDisk(ctx, src, srcDC, dst, dstDC, nil, force)
|
||||
}
|
||||
}
|
||||
|
||||
task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// MoveFile calls FileManager.MoveDatastoreFile
|
||||
func (m *DatastoreFileManager) MoveFile(ctx context.Context, src string, dst string) error {
|
||||
srcp := m.Path(src)
|
||||
dstp := m.Path(dst)
|
||||
|
||||
task, err := m.FileManager.MoveDatastoreFile(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// Move dispatches to the appropriate FileManager or VirtualDiskManager Move method based on file name extension
|
||||
func (m *DatastoreFileManager) Move(ctx context.Context, src string, dst string) error {
|
||||
srcp := m.Path(src)
|
||||
dstp := m.Path(dst)
|
||||
|
||||
f := m.FileManager.MoveDatastoreFile
|
||||
|
||||
if srcp.IsVMDK() {
|
||||
f = m.VirtualDiskManager.MoveVirtualDisk
|
||||
}
|
||||
|
||||
task, err := f(ctx, srcp.String(), m.Datacenter, dstp.String(), m.DatacenterTarget, m.Force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return m.wait(ctx, task)
|
||||
}
|
||||
|
||||
// Path converts path name to a DatastorePath
|
||||
|
|
|
@ -18,6 +18,7 @@ package object
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -30,7 +31,7 @@ type DatastorePath struct {
|
|||
// FromString parses a datastore path.
|
||||
// Returns true if the path could be parsed, false otherwise.
|
||||
func (p *DatastorePath) FromString(s string) bool {
|
||||
if len(s) == 0 {
|
||||
if s == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -63,3 +64,8 @@ func (p *DatastorePath) String() string {
|
|||
|
||||
return strings.Join([]string{s, p.Path}, " ")
|
||||
}
|
||||
|
||||
// IsVMDK returns true if Path has a ".vmdk" extension
|
||||
func (p *DatastorePath) IsVMDK() bool {
|
||||
return path.Ext(p.Path) == ".vmdk"
|
||||
}
|
||||
|
|
|
@ -71,10 +71,8 @@ func (m DiagnosticManager) GenerateLogBundles(ctx context.Context, includeDefaul
|
|||
IncludeDefault: includeDefault,
|
||||
}
|
||||
|
||||
if host != nil {
|
||||
for _, h := range host {
|
||||
req.Host = append(req.Host, h.Reference())
|
||||
}
|
||||
for _, h := range host {
|
||||
req.Host = append(req.Host, h.Reference())
|
||||
}
|
||||
|
||||
res, err := methods.GenerateLogBundles_Task(ctx, m.c, &req)
|
||||
|
|
|
@ -18,6 +18,7 @@ package object
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
|
@ -38,12 +39,18 @@ func NewDistributedVirtualPortgroup(c *vim25.Client, ref types.ManagedObjectRefe
|
|||
// EthernetCardBackingInfo returns the VirtualDeviceBackingInfo for this DistributedVirtualPortgroup
|
||||
func (p DistributedVirtualPortgroup) EthernetCardBackingInfo(ctx context.Context) (types.BaseVirtualDeviceBackingInfo, error) {
|
||||
var dvp mo.DistributedVirtualPortgroup
|
||||
var dvs mo.VmwareDistributedVirtualSwitch // TODO: should be mo.BaseDistributedVirtualSwitch
|
||||
var dvs mo.DistributedVirtualSwitch
|
||||
prop := "config.distributedVirtualSwitch"
|
||||
|
||||
if err := p.Properties(ctx, p.Reference(), []string{"key", "config.distributedVirtualSwitch"}, &dvp); err != nil {
|
||||
if err := p.Properties(ctx, p.Reference(), []string{"key", prop}, &dvp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// "This property should always be set unless the user's setting does not have System.Read privilege on the object referred to by this property."
|
||||
if dvp.Config.DistributedVirtualSwitch == nil {
|
||||
return nil, fmt.Errorf("no System.Read privilege on: %s.%s", p.Reference(), prop)
|
||||
}
|
||||
|
||||
if err := p.Properties(ctx, *dvp.Config.DistributedVirtualSwitch, []string{"uuid"}, &dvs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -65,3 +65,16 @@ func (s DistributedVirtualSwitch) AddPortgroup(ctx context.Context, spec []types
|
|||
|
||||
return NewTask(s.Client(), res.Returnval), nil
|
||||
}
|
||||
|
||||
func (s DistributedVirtualSwitch) FetchDVPorts(ctx context.Context, criteria *types.DistributedVirtualSwitchPortCriteria) ([]types.DistributedVirtualPort, error) {
|
||||
req := &types.FetchDVPorts{
|
||||
This: s.Reference(),
|
||||
Criteria: criteria,
|
||||
}
|
||||
|
||||
res, err := methods.FetchDVPorts(ctx, s.Client(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ func (f FileManager) DeleteDatastoreFile(ctx context.Context, name string, dc *D
|
|||
// MakeDirectory creates a folder using the specified name.
|
||||
func (f FileManager) MakeDirectory(ctx context.Context, name string, dc *Datacenter, createParentDirectories bool) error {
|
||||
req := types.MakeDirectory{
|
||||
This: f.Reference(),
|
||||
Name: name,
|
||||
This: f.Reference(),
|
||||
Name: name,
|
||||
CreateParentDirectories: types.NewBool(createParentDirectories),
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func (m HostCertificateManager) CertificateInfo(ctx context.Context) (*HostCerti
|
|||
// Use InstallServerCertificate to import this certificate.
|
||||
func (m HostCertificateManager) GenerateCertificateSigningRequest(ctx context.Context, useIPAddressAsCommonName bool) (string, error) {
|
||||
req := types.GenerateCertificateSigningRequest{
|
||||
This: m.Reference(),
|
||||
This: m.Reference(),
|
||||
UseIpAddressAsCommonName: useIPAddressAsCommonName,
|
||||
}
|
||||
|
||||
|
|
|
@ -117,3 +117,19 @@ func (s HostDatastoreSystem) QueryVmfsDatastoreCreateOptions(ctx context.Context
|
|||
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (s HostDatastoreSystem) ResignatureUnresolvedVmfsVolumes(ctx context.Context, devicePaths []string) (*Task, error) {
|
||||
req := &types.ResignatureUnresolvedVmfsVolume_Task{
|
||||
This: s.Reference(),
|
||||
ResolutionSpec: types.HostUnresolvedVmfsResignatureSpec{
|
||||
ExtentDevicePath: devicePaths,
|
||||
},
|
||||
}
|
||||
|
||||
res, err := methods.ResignatureUnresolvedVmfsVolume_Task(ctx, s.Client(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(s.c, res.Returnval), nil
|
||||
}
|
||||
|
|
|
@ -98,18 +98,18 @@ func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName str
|
|||
}
|
||||
|
||||
// QueryNetworkHint wraps methods.QueryNetworkHint
|
||||
func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) error {
|
||||
func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) ([]types.PhysicalNicHintInfo, error) {
|
||||
req := types.QueryNetworkHint{
|
||||
This: o.Reference(),
|
||||
Device: device,
|
||||
}
|
||||
|
||||
_, err := methods.QueryNetworkHint(ctx, o.c, &req)
|
||||
res, err := methods.QueryNetworkHint(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil
|
||||
return res.Returnval, err
|
||||
}
|
||||
|
||||
// RefreshNetworkSystem wraps methods.RefreshNetworkSystem
|
||||
|
|
|
@ -88,6 +88,24 @@ func (s HostStorageSystem) RescanAllHba(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) Refresh(ctx context.Context) error {
|
||||
req := types.RefreshStorageSystem{
|
||||
This: s.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.RefreshStorageSystem(ctx, s.c, &req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) RescanVmfs(ctx context.Context) error {
|
||||
req := types.RescanVmfs{
|
||||
This: s.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.RescanVmfs(ctx, s.c, &req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) MarkAsSsd(ctx context.Context, uuid string) (*Task, error) {
|
||||
req := types.MarkAsSsd_Task{
|
||||
This: s.Reference(),
|
||||
|
@ -143,3 +161,40 @@ func (s HostStorageSystem) MarkAsNonLocal(ctx context.Context, uuid string) (*Ta
|
|||
|
||||
return NewTask(s.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) AttachScsiLun(ctx context.Context, uuid string) error {
|
||||
req := types.AttachScsiLun{
|
||||
This: s.Reference(),
|
||||
LunUuid: uuid,
|
||||
}
|
||||
|
||||
_, err := methods.AttachScsiLun(ctx, s.c, &req)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) QueryUnresolvedVmfsVolumes(ctx context.Context) ([]types.HostUnresolvedVmfsVolume, error) {
|
||||
req := &types.QueryUnresolvedVmfsVolume{
|
||||
This: s.Reference(),
|
||||
}
|
||||
|
||||
res, err := methods.QueryUnresolvedVmfsVolume(ctx, s.Client(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (s HostStorageSystem) UnmountVmfsVolume(ctx context.Context, vmfsUuid string) error {
|
||||
req := &types.UnmountVmfsVolume{
|
||||
This: s.Reference(),
|
||||
VmfsUuid: vmfsUuid,
|
||||
}
|
||||
|
||||
_, err := methods.UnmountVmfsVolume(ctx, s.Client(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (m HostVsanInternalSystem) QueryVsanObjectUuidsByFilter(ctx context.Context
|
|||
req := types.QueryVsanObjectUuidsByFilter{
|
||||
This: m.Reference(),
|
||||
Uuids: uuids,
|
||||
Limit: limit,
|
||||
Limit: &limit,
|
||||
Version: version,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
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"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/mo"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type HttpNfcLease struct {
|
||||
Common
|
||||
}
|
||||
|
||||
func NewHttpNfcLease(c *vim25.Client, ref types.ManagedObjectReference) *HttpNfcLease {
|
||||
return &HttpNfcLease{
|
||||
Common: NewCommon(c, ref),
|
||||
}
|
||||
}
|
||||
|
||||
// HttpNfcLeaseAbort wraps methods.HttpNfcLeaseAbort
|
||||
func (o HttpNfcLease) HttpNfcLeaseAbort(ctx context.Context, fault *types.LocalizedMethodFault) error {
|
||||
req := types.HttpNfcLeaseAbort{
|
||||
This: o.Reference(),
|
||||
Fault: fault,
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseAbort(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HttpNfcLeaseComplete wraps methods.HttpNfcLeaseComplete
|
||||
func (o HttpNfcLease) HttpNfcLeaseComplete(ctx context.Context) error {
|
||||
req := types.HttpNfcLeaseComplete{
|
||||
This: o.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseComplete(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HttpNfcLeaseGetManifest wraps methods.HttpNfcLeaseGetManifest
|
||||
func (o HttpNfcLease) HttpNfcLeaseGetManifest(ctx context.Context) error {
|
||||
req := types.HttpNfcLeaseGetManifest{
|
||||
This: o.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseGetManifest(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HttpNfcLeaseProgress wraps methods.HttpNfcLeaseProgress
|
||||
func (o HttpNfcLease) HttpNfcLeaseProgress(ctx context.Context, percent int32) error {
|
||||
req := types.HttpNfcLeaseProgress{
|
||||
This: o.Reference(),
|
||||
Percent: percent,
|
||||
}
|
||||
|
||||
_, err := methods.HttpNfcLeaseProgress(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o HttpNfcLease) Wait(ctx context.Context) (*types.HttpNfcLeaseInfo, error) {
|
||||
var lease mo.HttpNfcLease
|
||||
|
||||
pc := property.DefaultCollector(o.c)
|
||||
err := property.Wait(ctx, pc, o.Reference(), []string{"state", "info", "error"}, func(pc []types.PropertyChange) bool {
|
||||
done := false
|
||||
|
||||
for _, c := range pc {
|
||||
if c.Val == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
switch c.Name {
|
||||
case "error":
|
||||
val := c.Val.(types.LocalizedMethodFault)
|
||||
lease.Error = &val
|
||||
done = true
|
||||
case "info":
|
||||
val := c.Val.(types.HttpNfcLeaseInfo)
|
||||
lease.Info = &val
|
||||
case "state":
|
||||
lease.State = c.Val.(types.HttpNfcLeaseState)
|
||||
if lease.State != types.HttpNfcLeaseStateInitializing {
|
||||
done = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return done
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if lease.State == types.HttpNfcLeaseStateReady {
|
||||
return lease.Info, nil
|
||||
}
|
||||
|
||||
if lease.Error != nil {
|
||||
return nil, errors.New(lease.Error.LocalizedMessage)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unexpected nfc lease state: %s", lease.State)
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
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 OvfManager struct {
|
||||
Common
|
||||
}
|
||||
|
||||
func NewOvfManager(c *vim25.Client) *OvfManager {
|
||||
o := OvfManager{
|
||||
Common: NewCommon(c, *c.ServiceContent.OvfManager),
|
||||
}
|
||||
|
||||
return &o
|
||||
}
|
||||
|
||||
// CreateDescriptor wraps methods.CreateDescriptor
|
||||
func (o OvfManager) CreateDescriptor(ctx context.Context, obj Reference, cdp types.OvfCreateDescriptorParams) (*types.OvfCreateDescriptorResult, error) {
|
||||
req := types.CreateDescriptor{
|
||||
This: o.Reference(),
|
||||
Obj: obj.Reference(),
|
||||
Cdp: cdp,
|
||||
}
|
||||
|
||||
res, err := methods.CreateDescriptor(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res.Returnval, nil
|
||||
}
|
||||
|
||||
// CreateImportSpec wraps methods.CreateImportSpec
|
||||
func (o OvfManager) CreateImportSpec(ctx context.Context, ovfDescriptor string, resourcePool Reference, datastore Reference, cisp types.OvfCreateImportSpecParams) (*types.OvfCreateImportSpecResult, error) {
|
||||
req := types.CreateImportSpec{
|
||||
This: o.Reference(),
|
||||
OvfDescriptor: ovfDescriptor,
|
||||
ResourcePool: resourcePool.Reference(),
|
||||
Datastore: datastore.Reference(),
|
||||
Cisp: cisp,
|
||||
}
|
||||
|
||||
res, err := methods.CreateImportSpec(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res.Returnval, nil
|
||||
}
|
||||
|
||||
// ParseDescriptor wraps methods.ParseDescriptor
|
||||
func (o OvfManager) ParseDescriptor(ctx context.Context, ovfDescriptor string, pdp types.OvfParseDescriptorParams) (*types.OvfParseDescriptorResult, error) {
|
||||
req := types.ParseDescriptor{
|
||||
This: o.Reference(),
|
||||
OvfDescriptor: ovfDescriptor,
|
||||
Pdp: pdp,
|
||||
}
|
||||
|
||||
res, err := methods.ParseDescriptor(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res.Returnval, nil
|
||||
}
|
||||
|
||||
// ValidateHost wraps methods.ValidateHost
|
||||
func (o OvfManager) ValidateHost(ctx context.Context, ovfDescriptor string, host Reference, vhp types.OvfValidateHostParams) (*types.OvfValidateHostResult, error) {
|
||||
req := types.ValidateHost{
|
||||
This: o.Reference(),
|
||||
OvfDescriptor: ovfDescriptor,
|
||||
Host: host.Reference(),
|
||||
Vhp: vhp,
|
||||
}
|
||||
|
||||
res, err := methods.ValidateHost(ctx, o.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res.Returnval, nil
|
||||
}
|
|
@ -19,6 +19,7 @@ package object
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/vmware/govmomi/nfc"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
|
@ -34,7 +35,7 @@ func NewResourcePool(c *vim25.Client, ref types.ManagedObjectReference) *Resourc
|
|||
}
|
||||
}
|
||||
|
||||
func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec, folder *Folder, host *HostSystem) (*HttpNfcLease, error) {
|
||||
func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec, folder *Folder, host *HostSystem) (*nfc.Lease, error) {
|
||||
req := types.ImportVApp{
|
||||
This: p.Reference(),
|
||||
Spec: spec,
|
||||
|
@ -55,7 +56,7 @@ func (p ResourcePool) ImportVApp(ctx context.Context, spec types.BaseImportSpec,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return NewHttpNfcLease(p.c, res.Returnval), nil
|
||||
return nfc.NewLease(p.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (p ResourcePool) Create(ctx context.Context, name string, spec types.ResourceConfigSpec) (*ResourcePool, error) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/task"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/progress"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
@ -47,7 +48,19 @@ func (t *Task) Wait(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (t *Task) WaitForResult(ctx context.Context, s progress.Sinker) (*types.TaskInfo, error) {
|
||||
func (t *Task) WaitForResult(ctx context.Context, s ...progress.Sinker) (*types.TaskInfo, error) {
|
||||
var pr progress.Sinker
|
||||
if len(s) == 1 {
|
||||
pr = s[0]
|
||||
}
|
||||
p := property.DefaultCollector(t.c)
|
||||
return task.Wait(ctx, t.Reference(), p, s)
|
||||
return task.Wait(ctx, t.Reference(), p, pr)
|
||||
}
|
||||
|
||||
func (t *Task) Cancel(ctx context.Context) error {
|
||||
_, err := methods.CancelTask(ctx, t.Client(), &types.CancelTask{
|
||||
This: t.Reference(),
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -47,8 +47,10 @@ func NewReference(c *vim25.Client, e types.ManagedObjectReference) Reference {
|
|||
return NewClusterComputeResource(c, e)
|
||||
case "HostSystem":
|
||||
return NewHostSystem(c, e)
|
||||
case "Network", "OpaqueNetwork":
|
||||
case "Network":
|
||||
return NewNetwork(c, e)
|
||||
case "OpaqueNetwork":
|
||||
return NewOpaqueNetwork(c, e)
|
||||
case "ResourcePool":
|
||||
return NewResourcePool(c, e)
|
||||
case "DistributedVirtualSwitch":
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2015-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.
|
||||
|
@ -30,6 +30,7 @@ import (
|
|||
|
||||
// Type values for use in BootOrder
|
||||
const (
|
||||
DeviceTypeNone = "-"
|
||||
DeviceTypeCdrom = "cdrom"
|
||||
DeviceTypeDisk = "disk"
|
||||
DeviceTypeEthernet = "ethernet"
|
||||
|
@ -60,7 +61,10 @@ func EthernetCardTypes() VirtualDeviceList {
|
|||
return VirtualDeviceList([]types.BaseVirtualDevice{
|
||||
&types.VirtualE1000{},
|
||||
&types.VirtualE1000e{},
|
||||
&types.VirtualVmxnet2{},
|
||||
&types.VirtualVmxnet3{},
|
||||
&types.VirtualPCNet32{},
|
||||
&types.VirtualSriovEthernetCard{},
|
||||
}).Select(func(device types.BaseVirtualDevice) bool {
|
||||
c := device.(types.BaseVirtualEthernetCard).GetVirtualEthernetCard()
|
||||
c.GetVirtualDevice().Key = -1
|
||||
|
@ -225,8 +229,10 @@ func (l VirtualDeviceList) FindSCSIController(name string) (*types.VirtualSCSICo
|
|||
func (l VirtualDeviceList) CreateSCSIController(name string) (types.BaseVirtualDevice, error) {
|
||||
ctypes := SCSIControllerTypes()
|
||||
|
||||
if name == "scsi" || name == "" {
|
||||
if name == "" || name == "scsi" {
|
||||
name = ctypes.Type(ctypes[0])
|
||||
} else if name == "virtualscsi" {
|
||||
name = "pvscsi" // ovf VirtualSCSI mapping
|
||||
}
|
||||
|
||||
found := ctypes.Select(func(device types.BaseVirtualDevice) bool {
|
||||
|
@ -754,6 +760,9 @@ func (l VirtualDeviceList) PrimaryMacAddress() string {
|
|||
|
||||
// convert a BaseVirtualDevice to a BaseVirtualMachineBootOptionsBootableDevice
|
||||
var bootableDevices = map[string]func(device types.BaseVirtualDevice) types.BaseVirtualMachineBootOptionsBootableDevice{
|
||||
DeviceTypeNone: func(types.BaseVirtualDevice) types.BaseVirtualMachineBootOptionsBootableDevice {
|
||||
return &types.VirtualMachineBootOptionsBootableDevice{}
|
||||
},
|
||||
DeviceTypeCdrom: func(types.BaseVirtualDevice) types.BaseVirtualMachineBootOptionsBootableDevice {
|
||||
return &types.VirtualMachineBootOptionsBootableCdromDevice{}
|
||||
},
|
||||
|
@ -773,17 +782,23 @@ var bootableDevices = map[string]func(device types.BaseVirtualDevice) types.Base
|
|||
}
|
||||
|
||||
// BootOrder returns a list of devices which can be used to set boot order via VirtualMachine.SetBootOptions.
|
||||
// The order can any of "ethernet", "cdrom", "floppy" or "disk" or by specific device name.
|
||||
// The order can be any of "ethernet", "cdrom", "floppy" or "disk" or by specific device name.
|
||||
// A value of "-" will clear the existing boot order on the VC/ESX side.
|
||||
func (l VirtualDeviceList) BootOrder(order []string) []types.BaseVirtualMachineBootOptionsBootableDevice {
|
||||
var devices []types.BaseVirtualMachineBootOptionsBootableDevice
|
||||
|
||||
for _, name := range order {
|
||||
if kind, ok := bootableDevices[name]; ok {
|
||||
if name == DeviceTypeNone {
|
||||
// Not covered in the API docs, nor obvious, but this clears the boot order on the VC/ESX side.
|
||||
devices = append(devices, new(types.VirtualMachineBootOptionsBootableDevice))
|
||||
continue
|
||||
}
|
||||
|
||||
for _, device := range l {
|
||||
if l.Type(device) == name {
|
||||
devices = append(devices, kind(device))
|
||||
}
|
||||
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -824,7 +839,7 @@ func (l VirtualDeviceList) TypeName(device types.BaseVirtualDevice) string {
|
|||
return dtype.Elem().Name()
|
||||
}
|
||||
|
||||
var deviceNameRegexp = regexp.MustCompile(`(?:Virtual)?(?:Machine)?(\w+?)(?:Card|Device|Controller)?$`)
|
||||
var deviceNameRegexp = regexp.MustCompile(`(?:Virtual)?(?:Machine)?(\w+?)(?:Card|EthernetCard|Device|Controller)?$`)
|
||||
|
||||
func (l VirtualDeviceList) deviceName(device types.BaseVirtualDevice) string {
|
||||
name := "device"
|
||||
|
|
|
@ -145,6 +145,47 @@ func (m VirtualDiskManager) DeleteVirtualDisk(ctx context.Context, name string,
|
|||
return NewTask(m.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
// InflateVirtualDisk inflates a virtual disk.
|
||||
func (m VirtualDiskManager) InflateVirtualDisk(ctx context.Context, name string, dc *Datacenter) (*Task, error) {
|
||||
req := types.InflateVirtualDisk_Task{
|
||||
This: m.Reference(),
|
||||
Name: name,
|
||||
}
|
||||
|
||||
if dc != nil {
|
||||
ref := dc.Reference()
|
||||
req.Datacenter = &ref
|
||||
}
|
||||
|
||||
res, err := methods.InflateVirtualDisk_Task(ctx, m.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(m.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
// ShrinkVirtualDisk shrinks a virtual disk.
|
||||
func (m VirtualDiskManager) ShrinkVirtualDisk(ctx context.Context, name string, dc *Datacenter, copy *bool) (*Task, error) {
|
||||
req := types.ShrinkVirtualDisk_Task{
|
||||
This: m.Reference(),
|
||||
Name: name,
|
||||
Copy: copy,
|
||||
}
|
||||
|
||||
if dc != nil {
|
||||
ref := dc.Reference()
|
||||
req.Datacenter = &ref
|
||||
}
|
||||
|
||||
res, err := methods.ShrinkVirtualDisk_Task(ctx, m.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(m.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
// Queries virtual disk uuid
|
||||
func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter) (string, error) {
|
||||
req := types.QueryVirtualDiskUuid{
|
||||
|
@ -168,3 +209,19 @@ func (m VirtualDiskManager) QueryVirtualDiskUuid(ctx context.Context, name strin
|
|||
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (m VirtualDiskManager) SetVirtualDiskUuid(ctx context.Context, name string, dc *Datacenter, uuid string) error {
|
||||
req := types.SetVirtualDiskUuid{
|
||||
This: m.Reference(),
|
||||
Name: name,
|
||||
Uuid: uuid,
|
||||
}
|
||||
|
||||
if dc != nil {
|
||||
ref := dc.Reference()
|
||||
req.Datacenter = &ref
|
||||
}
|
||||
|
||||
_, err := methods.SetVirtualDiskUuid(ctx, m.c, &req)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -46,9 +46,10 @@ type queryVirtualDiskInfoTaskResponse struct {
|
|||
}
|
||||
|
||||
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"`
|
||||
Req *queryVirtualDiskInfoTaskRequest `xml:"urn:internalvim25 QueryVirtualDiskInfo_Task,omitempty"`
|
||||
Res *queryVirtualDiskInfoTaskResponse `xml:"urn:vim25 QueryVirtualDiskInfo_TaskResponse,omitempty"`
|
||||
InternalRes *queryVirtualDiskInfoTaskResponse `xml:"urn:internalvim25 QueryVirtualDiskInfo_TaskResponse,omitempty"`
|
||||
Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
|
||||
}
|
||||
|
||||
func (b *queryVirtualDiskInfoTaskBody) Fault() *soap.Fault { return b.Err }
|
||||
|
@ -62,7 +63,11 @@ func queryVirtualDiskInfoTask(ctx context.Context, r soap.RoundTripper, req *que
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
if resBody.Res != nil {
|
||||
return resBody.Res, nil
|
||||
}
|
||||
|
||||
return resBody.InternalRes, nil
|
||||
}
|
||||
|
||||
type VirtualDiskInfo struct {
|
||||
|
@ -95,3 +100,67 @@ func (m VirtualDiskManager) QueryVirtualDiskInfo(ctx context.Context, name strin
|
|||
|
||||
return info.Result.(arrayOfVirtualDiskInfo).VirtualDiskInfo, nil
|
||||
}
|
||||
|
||||
type createChildDiskTaskRequest struct {
|
||||
This types.ManagedObjectReference `xml:"_this"`
|
||||
ChildName string `xml:"childName"`
|
||||
ChildDatacenter *types.ManagedObjectReference `xml:"childDatacenter,omitempty"`
|
||||
ParentName string `xml:"parentName"`
|
||||
ParentDatacenter *types.ManagedObjectReference `xml:"parentDatacenter,omitempty"`
|
||||
IsLinkedClone bool `xml:"isLinkedClone"`
|
||||
}
|
||||
|
||||
type createChildDiskTaskResponse struct {
|
||||
Returnval types.ManagedObjectReference `xml:"returnval"`
|
||||
}
|
||||
|
||||
type createChildDiskTaskBody struct {
|
||||
Req *createChildDiskTaskRequest `xml:"urn:internalvim25 CreateChildDisk_Task,omitempty"`
|
||||
Res *createChildDiskTaskResponse `xml:"urn:vim25 CreateChildDisk_TaskResponse,omitempty"`
|
||||
InternalRes *createChildDiskTaskResponse `xml:"urn:internalvim25 CreateChildDisk_TaskResponse,omitempty"`
|
||||
Err *soap.Fault `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault,omitempty"`
|
||||
}
|
||||
|
||||
func (b *createChildDiskTaskBody) Fault() *soap.Fault { return b.Err }
|
||||
|
||||
func createChildDiskTask(ctx context.Context, r soap.RoundTripper, req *createChildDiskTaskRequest) (*createChildDiskTaskResponse, error) {
|
||||
var reqBody, resBody createChildDiskTaskBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resBody.Res != nil {
|
||||
return resBody.Res, nil // vim-version <= 6.5
|
||||
}
|
||||
|
||||
return resBody.InternalRes, nil // vim-version >= 6.7
|
||||
}
|
||||
|
||||
func (m VirtualDiskManager) CreateChildDisk(ctx context.Context, parent string, pdc *Datacenter, name string, dc *Datacenter, linked bool) (*Task, error) {
|
||||
req := createChildDiskTaskRequest{
|
||||
This: m.Reference(),
|
||||
ChildName: name,
|
||||
ParentName: parent,
|
||||
IsLinkedClone: linked,
|
||||
}
|
||||
|
||||
if dc != nil {
|
||||
ref := dc.Reference()
|
||||
req.ChildDatacenter = &ref
|
||||
}
|
||||
|
||||
if pdc != nil {
|
||||
ref := pdc.Reference()
|
||||
req.ParentDatacenter = &ref
|
||||
}
|
||||
|
||||
res, err := createChildDiskTask(ctx, m.Client(), &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(m.Client(), res.Returnval), nil
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"net"
|
||||
"path"
|
||||
|
||||
"github.com/vmware/govmomi/nfc"
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
|
@ -81,6 +82,20 @@ func (v VirtualMachine) PowerOff(ctx context.Context) (*Task, error) {
|
|||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) PutUsbScanCodes(ctx context.Context, spec types.UsbScanCodeSpec) (int32, error) {
|
||||
req := types.PutUsbScanCodes{
|
||||
This: v.Reference(),
|
||||
Spec: spec,
|
||||
}
|
||||
|
||||
res, err := methods.PutUsbScanCodes(ctx, v.c, &req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) Reset(ctx context.Context) (*Task, error) {
|
||||
req := types.ResetVM_Task{
|
||||
This: v.Reference(),
|
||||
|
@ -197,6 +212,15 @@ func (v VirtualMachine) Reconfigure(ctx context.Context, config types.VirtualMac
|
|||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) RefreshStorageInfo(ctx context.Context) error {
|
||||
req := types.RefreshStorageInfo{
|
||||
This: v.Reference(),
|
||||
}
|
||||
|
||||
_, err := methods.RefreshStorageInfo(ctx, v.c, &req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (v VirtualMachine) WaitForIP(ctx context.Context) (string, error) {
|
||||
var ip string
|
||||
|
||||
|
@ -261,6 +285,10 @@ func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...str
|
|||
return true
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(device) != 0 {
|
||||
// Only wait for specific NIC(s)
|
||||
macs = make(map[string][]string)
|
||||
|
@ -464,6 +492,20 @@ func (v VirtualMachine) Answer(ctx context.Context, id, answer string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) AcquireTicket(ctx context.Context, kind string) (*types.VirtualMachineTicket, error) {
|
||||
req := types.AcquireTicket{
|
||||
This: v.Reference(),
|
||||
TicketType: kind,
|
||||
}
|
||||
|
||||
res, err := methods.AcquireTicket(ctx, v.c, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res.Returnval, nil
|
||||
}
|
||||
|
||||
// CreateSnapshot creates a new snapshot of a virtual machine.
|
||||
func (v VirtualMachine) CreateSnapshot(ctx context.Context, name string, description string, memory bool, quiesce bool) (*Task, error) {
|
||||
req := types.CreateSnapshot_Task{
|
||||
|
@ -497,7 +539,7 @@ func (v VirtualMachine) RemoveAllSnapshot(ctx context.Context, consolidate *bool
|
|||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
type snapshotMap map[string][]Reference
|
||||
type snapshotMap map[string][]types.ManagedObjectReference
|
||||
|
||||
func (m snapshotMap) add(parent string, tree []types.VirtualMachineSnapshotTree) {
|
||||
for i, st := range tree {
|
||||
|
@ -511,7 +553,7 @@ func (m snapshotMap) add(parent string, tree []types.VirtualMachineSnapshotTree)
|
|||
}
|
||||
|
||||
for _, name := range names {
|
||||
m[name] = append(m[name], &tree[i].Snapshot)
|
||||
m[name] = append(m[name], tree[i].Snapshot)
|
||||
}
|
||||
|
||||
m.add(sname, st.ChildSnapshotList)
|
||||
|
@ -522,7 +564,7 @@ func (m snapshotMap) add(parent string, tree []types.VirtualMachineSnapshotTree)
|
|||
// 1) snapshot ManagedObjectReference.Value (unique)
|
||||
// 2) snapshot name (may not be unique)
|
||||
// 3) snapshot tree path (may not be unique)
|
||||
func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (Reference, error) {
|
||||
func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (*types.ManagedObjectReference, error) {
|
||||
var o mo.VirtualMachine
|
||||
|
||||
err := v.Properties(ctx, v.Reference(), []string{"snapshot"}, &o)
|
||||
|
@ -531,7 +573,7 @@ func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (Referenc
|
|||
}
|
||||
|
||||
if o.Snapshot == nil || len(o.Snapshot.RootSnapshotList) == 0 {
|
||||
return nil, errors.New("No snapshots for this VM")
|
||||
return nil, errors.New("no snapshots for this VM")
|
||||
}
|
||||
|
||||
m := make(snapshotMap)
|
||||
|
@ -542,7 +584,7 @@ func (v VirtualMachine) FindSnapshot(ctx context.Context, name string) (Referenc
|
|||
case 0:
|
||||
return nil, fmt.Errorf("snapshot %q not found", name)
|
||||
case 1:
|
||||
return s[0], nil
|
||||
return &s[0], nil
|
||||
default:
|
||||
return nil, fmt.Errorf("%q resolves to %d snapshots", name, len(s))
|
||||
}
|
||||
|
@ -757,3 +799,43 @@ func (v VirtualMachine) UpgradeTools(ctx context.Context, options string) (*Task
|
|||
|
||||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) Export(ctx context.Context) (*nfc.Lease, error) {
|
||||
req := types.ExportVm{
|
||||
This: v.Reference(),
|
||||
}
|
||||
|
||||
res, err := methods.ExportVm(ctx, v.Client(), &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nfc.NewLease(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
func (v VirtualMachine) UpgradeVM(ctx context.Context, version string) (*Task, error) {
|
||||
req := types.UpgradeVM_Task{
|
||||
This: v.Reference(),
|
||||
Version: version,
|
||||
}
|
||||
|
||||
res, err := methods.UpgradeVM_Task(ctx, v.Client(), &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewTask(v.c, res.Returnval), nil
|
||||
}
|
||||
|
||||
// UUID is a helper to get the UUID of the VirtualMachine managed object.
|
||||
// This method returns an empty string if an error occurs when retrieving UUID from the VirtualMachine object.
|
||||
func (v VirtualMachine) UUID(ctx context.Context) string {
|
||||
var o mo.VirtualMachine
|
||||
|
||||
err := v.Properties(ctx, v.Reference(), []string{"config.uuid"}, &o)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return o.Config.Uuid
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
ifneq (,$(strip $(GOOS)))
|
||||
ifeq (,$(strip $(GOARCH)))
|
||||
GOARCH := $(shell go env | grep GOARCH | awk -F= '{print $$2}' | tr -d '"')
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(strip $(GOARCH)))
|
||||
ifeq (,$(strip $(GOOS)))
|
||||
GOOS := $(shell go env | grep GOOS | awk -F= '{print $$2}' | tr -d '"')
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (2,$(words $(GOOS) $(GOARCH)))
|
||||
PROGRAM := $(PROGRAM)_$(GOOS)_$(GOARCH)
|
||||
endif
|
||||
|
||||
ifeq (windows,$(GOOS))
|
||||
PROGRAM := $(PROGRAM).exe
|
||||
endif
|
||||
|
||||
all: $(PROGRAM)
|
||||
|
||||
TAGS += netgo
|
||||
ifeq (,$(strip $(findstring -w,$(LDFLAGS))))
|
||||
LDFLAGS += -w
|
||||
endif
|
||||
BUILD_ARGS := -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -v
|
||||
|
||||
$(PROGRAM):
|
||||
CGO_ENABLED=0 go build -a $(BUILD_ARGS) -o $@
|
||||
|
||||
install:
|
||||
CGO_ENABLED=0 go install -i -v $(BUILD_ARGS)
|
||||
|
||||
ifneq (,$(strip $(BUILD_OS)))
|
||||
ifneq (,$(strip $(BUILD_ARCH)))
|
||||
GOOS_GOARCH_TARGETS := $(foreach a,$(BUILD_ARCH),$(patsubst %,%_$a,$(BUILD_OS)))
|
||||
XBUILD := $(addprefix $(PROGRAM)_,$(GOOS_GOARCH_TARGETS))
|
||||
$(XBUILD):
|
||||
GOOS=$(word 2,$(subst _, ,$@)) GOARCH=$(word 3,$(subst _, ,$@)) $(MAKE) --output-sync=target
|
||||
build-all: $(XBUILD)
|
||||
endif
|
||||
endif
|
||||
|
||||
clean:
|
||||
@rm -f $(PROGRAM) $(XBUILD)
|
||||
|
||||
.PHONY: build-all install clean
|
|
@ -111,6 +111,12 @@ func (p *Collector) WaitForUpdates(ctx context.Context, v string) (*types.Update
|
|||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (p *Collector) CancelWaitForUpdates(ctx context.Context) error {
|
||||
req := &types.CancelWaitForUpdates{This: p.Reference()}
|
||||
_, err := methods.CancelWaitForUpdates(ctx, p.roundTripper, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Collector) RetrieveProperties(ctx context.Context, req types.RetrieveProperties) (*types.RetrievePropertiesResponse, error) {
|
||||
req.This = p.Reference()
|
||||
return methods.RetrieveProperties(ctx, p.roundTripper, &req)
|
||||
|
@ -120,26 +126,30 @@ func (p *Collector) RetrieveProperties(ctx context.Context, req types.RetrievePr
|
|||
// must be a pointer to a []interface{}, which is populated with the instances
|
||||
// of the specified managed objects, with the relevant properties filled in. If
|
||||
// the properties slice is nil, all properties are loaded.
|
||||
// Note that pointer types are optional fields that may be left as a nil value.
|
||||
// The caller should check such fields for a nil value before dereferencing.
|
||||
func (p *Collector) Retrieve(ctx context.Context, objs []types.ManagedObjectReference, ps []string, dst interface{}) error {
|
||||
var propSpec *types.PropertySpec
|
||||
if len(objs) == 0 {
|
||||
return errors.New("object references is empty")
|
||||
}
|
||||
|
||||
kinds := make(map[string]bool)
|
||||
|
||||
var propSet []types.PropertySpec
|
||||
var objectSet []types.ObjectSpec
|
||||
|
||||
for _, obj := range objs {
|
||||
// Ensure that all object reference types are the same
|
||||
if propSpec == nil {
|
||||
propSpec = &types.PropertySpec{
|
||||
if _, ok := kinds[obj.Type]; !ok {
|
||||
spec := types.PropertySpec{
|
||||
Type: obj.Type,
|
||||
}
|
||||
|
||||
if ps == nil {
|
||||
propSpec.All = types.NewBool(true)
|
||||
spec.All = types.NewBool(true)
|
||||
} else {
|
||||
propSpec.PathSet = ps
|
||||
}
|
||||
} else {
|
||||
if obj.Type != propSpec.Type {
|
||||
return errors.New("object references must have the same type")
|
||||
spec.PathSet = ps
|
||||
}
|
||||
propSet = append(propSet, spec)
|
||||
kinds[obj.Type] = true
|
||||
}
|
||||
|
||||
objectSpec := types.ObjectSpec{
|
||||
|
@ -154,7 +164,7 @@ func (p *Collector) Retrieve(ctx context.Context, objs []types.ManagedObjectRefe
|
|||
SpecSet: []types.PropertyFilterSpec{
|
||||
{
|
||||
ObjectSet: objectSet,
|
||||
PropSet: []types.PropertySpec{*propSpec},
|
||||
PropSet: propSet,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -194,7 +204,7 @@ func (p *Collector) RetrieveWithFilter(ctx context.Context, objs []types.Managed
|
|||
return p.Retrieve(ctx, objs, ps, dst)
|
||||
}
|
||||
|
||||
// RetrieveOne calls Retrieve with a single managed object reference.
|
||||
// RetrieveOne calls Retrieve with a single managed object reference via Collector.Retrieve().
|
||||
func (p *Collector) RetrieveOne(ctx context.Context, obj types.ManagedObjectReference, ps []string, dst interface{}) error {
|
||||
var objs = []types.ManagedObjectReference{obj}
|
||||
return p.Retrieve(ctx, objs, ps, dst)
|
||||
|
|
|
@ -122,7 +122,7 @@ func (f Filter) MatchPropertyList(props []types.DynamicProperty) bool {
|
|||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return len(f) == len(props) // false if a property such as VM "guest" is unset
|
||||
}
|
||||
|
||||
// MatchObjectContent returns a list of ObjectContent.Obj where the ObjectContent.PropSet matches the Filter.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2015-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.
|
||||
|
@ -19,10 +19,55 @@ package property
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
// Wait waits for any of the specified properties of the specified managed
|
||||
// WaitFilter provides helpers to construct a types.CreateFilter for use with property.Wait
|
||||
type WaitFilter struct {
|
||||
types.CreateFilter
|
||||
Options *types.WaitOptions
|
||||
}
|
||||
|
||||
// Add a new ObjectSpec and PropertySpec to the WaitFilter
|
||||
func (f *WaitFilter) Add(obj types.ManagedObjectReference, kind string, ps []string, set ...types.BaseSelectionSpec) *WaitFilter {
|
||||
spec := types.ObjectSpec{
|
||||
Obj: obj,
|
||||
SelectSet: set,
|
||||
}
|
||||
|
||||
pset := types.PropertySpec{
|
||||
Type: kind,
|
||||
PathSet: ps,
|
||||
}
|
||||
|
||||
if len(ps) == 0 {
|
||||
pset.All = types.NewBool(true)
|
||||
}
|
||||
|
||||
f.Spec.ObjectSet = append(f.Spec.ObjectSet, spec)
|
||||
|
||||
f.Spec.PropSet = append(f.Spec.PropSet, pset)
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
// Wait creates a new WaitFilter and calls the specified function for each ObjectUpdate via WaitForUpdates
|
||||
func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error {
|
||||
filter := new(WaitFilter).Add(obj, obj.Type, ps)
|
||||
|
||||
return WaitForUpdates(ctx, c, filter, func(updates []types.ObjectUpdate) bool {
|
||||
for _, update := range updates {
|
||||
if f(update.ChangeSet) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// WaitForUpdates waits for any of the specified properties of the specified managed
|
||||
// object to change. It calls the specified function for every update it
|
||||
// receives. If this function returns false, it continues waiting for
|
||||
// subsequent updates. If this function returns true, it stops waiting and
|
||||
|
@ -32,122 +77,57 @@ import (
|
|||
// creates a new property collector and calls CreateFilter. A new property
|
||||
// collector is required because filters can only be added, not removed.
|
||||
//
|
||||
// If the Context is canceled, a call to CancelWaitForUpdates() is made and its error value is returned.
|
||||
// The newly created collector is destroyed before this function returns (both
|
||||
// in case of success or error).
|
||||
//
|
||||
func Wait(ctx context.Context, c *Collector, obj types.ManagedObjectReference, ps []string, f func([]types.PropertyChange) bool) error {
|
||||
func WaitForUpdates(ctx context.Context, c *Collector, filter *WaitFilter, f func([]types.ObjectUpdate) bool) error {
|
||||
p, err := c.Create(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Attempt to destroy the collector using the background context, as the
|
||||
// specified context may have timed out or have been cancelled.
|
||||
defer p.Destroy(context.Background())
|
||||
// specified context may have timed out or have been canceled.
|
||||
defer func() {
|
||||
_ = p.Destroy(context.Background())
|
||||
}()
|
||||
|
||||
req := types.CreateFilter{
|
||||
Spec: types.PropertyFilterSpec{
|
||||
ObjectSet: []types.ObjectSpec{
|
||||
{
|
||||
Obj: obj,
|
||||
},
|
||||
},
|
||||
PropSet: []types.PropertySpec{
|
||||
{
|
||||
PathSet: ps,
|
||||
Type: obj.Type,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if len(ps) == 0 {
|
||||
req.Spec.PropSet[0].All = types.NewBool(true)
|
||||
}
|
||||
|
||||
err = p.CreateFilter(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return waitLoop(ctx, p, func(_ types.ManagedObjectReference, pc []types.PropertyChange) bool {
|
||||
return f(pc)
|
||||
})
|
||||
}
|
||||
|
||||
// WaitForView waits for any of the specified properties of the managed
|
||||
// objects in the View to change. It calls the specified function for every update it
|
||||
// receives. If this function returns false, it continues waiting for
|
||||
// subsequent updates. If this function returns true, it stops waiting and
|
||||
// returns.
|
||||
//
|
||||
// To only receive updates for the View's specified managed objects, the function
|
||||
// creates a new property collector and calls CreateFilter. A new property
|
||||
// collector is required because filters can only be added, not removed.
|
||||
//
|
||||
// The newly created collector is destroyed before this function returns (both
|
||||
// in case of success or error).
|
||||
//
|
||||
// The code assumes that all objects in the View are the same type
|
||||
func WaitForView(ctx context.Context, c *Collector, view types.ManagedObjectReference, obj types.ManagedObjectReference, ps []string, f func(types.ManagedObjectReference, []types.PropertyChange) bool) error {
|
||||
p, err := c.Create(ctx)
|
||||
err = p.CreateFilter(ctx, filter.CreateFilter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Attempt to destroy the collector using the background context, as the
|
||||
// specified context may have timed out or have been cancelled.
|
||||
defer p.Destroy(context.Background())
|
||||
|
||||
req := types.CreateFilter{
|
||||
Spec: types.PropertyFilterSpec{
|
||||
ObjectSet: []types.ObjectSpec{
|
||||
{
|
||||
Obj: view,
|
||||
SelectSet: []types.BaseSelectionSpec{
|
||||
&types.TraversalSpec{
|
||||
SelectionSpec: types.SelectionSpec{
|
||||
Name: "traverseEntities",
|
||||
},
|
||||
Path: "view",
|
||||
Type: view.Type}},
|
||||
},
|
||||
},
|
||||
PropSet: []types.PropertySpec{
|
||||
{
|
||||
Type: obj.Type,
|
||||
PathSet: ps,
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
||||
err = p.CreateFilter(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
req := types.WaitForUpdatesEx{
|
||||
This: p.Reference(),
|
||||
Options: filter.Options,
|
||||
}
|
||||
return waitLoop(ctx, p, f)
|
||||
}
|
||||
|
||||
func waitLoop(ctx context.Context, c *Collector, f func(types.ManagedObjectReference, []types.PropertyChange) bool) error {
|
||||
for version := ""; ; {
|
||||
res, err := c.WaitForUpdates(ctx, version)
|
||||
for {
|
||||
res, err := methods.WaitForUpdatesEx(ctx, p.roundTripper, &req)
|
||||
if err != nil {
|
||||
if ctx.Err() == context.Canceled {
|
||||
werr := p.CancelWaitForUpdates(context.Background())
|
||||
return werr
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Retry if the result came back empty
|
||||
if res == nil {
|
||||
set := res.Returnval
|
||||
if set == nil {
|
||||
if req.Options != nil && req.Options.MaxWaitSeconds != nil {
|
||||
return nil // WaitOptions.MaxWaitSeconds exceeded
|
||||
}
|
||||
// Retry if the result came back empty
|
||||
continue
|
||||
}
|
||||
|
||||
version = res.Version
|
||||
req.Version = set.Version
|
||||
|
||||
for _, fs := range res.FilterSet {
|
||||
for _, os := range fs.ObjectSet {
|
||||
if f(os.Obj, os.ChangeSet) {
|
||||
return nil
|
||||
}
|
||||
for _, fs := range set.FilterSet {
|
||||
if f(fs.ObjectSet) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ type keepAlive struct {
|
|||
}
|
||||
|
||||
func defaultKeepAlive(roundTripper soap.RoundTripper) error {
|
||||
_, _ = methods.GetCurrentTime(context.Background(), roundTripper)
|
||||
return nil
|
||||
_, err := methods.GetCurrentTime(context.Background(), roundTripper)
|
||||
return err
|
||||
}
|
||||
|
||||
// KeepAlive wraps the specified soap.RoundTripper and executes a meaningless
|
||||
|
@ -114,10 +114,9 @@ func (k *keepAlive) RoundTrip(ctx context.Context, req, res soap.HasFault) error
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start ticker on login, stop ticker on logout.
|
||||
switch req.(type) {
|
||||
case *methods.LoginBody, *methods.LoginExtensionByCertificateBody:
|
||||
case *methods.LoginBody, *methods.LoginExtensionByCertificateBody, *methods.LoginByTokenBody:
|
||||
k.start()
|
||||
case *methods.LogoutBody:
|
||||
k.stop()
|
||||
|
|
|
@ -18,8 +18,11 @@ package session
|
|||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/property"
|
||||
"github.com/vmware/govmomi/vim25"
|
||||
|
@ -40,6 +43,21 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
// Secret returns the contents if a file path value is given, otherwise returns value itself.
|
||||
func Secret(value string) (string, error) {
|
||||
if len(value) == 0 {
|
||||
return value, nil
|
||||
}
|
||||
contents, err := ioutil.ReadFile(value)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return value, nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimSpace(string(contents)), nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
client *vim25.Client
|
||||
userSession *types.UserSession
|
||||
|
@ -89,14 +107,51 @@ func (sm *Manager) Login(ctx context.Context, u *url.Userinfo) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sm *Manager) LoginExtensionByCertificate(ctx context.Context, key string, locale string) error {
|
||||
// LoginExtensionByCertificate uses the vCenter SDK tunnel to login using a client certificate.
|
||||
// The client certificate can be set using the soap.Client.SetCertificate method.
|
||||
// See: https://kb.vmware.com/s/article/2004305
|
||||
func (sm *Manager) LoginExtensionByCertificate(ctx context.Context, key string) error {
|
||||
c := sm.client
|
||||
u := c.URL()
|
||||
if u.Hostname() != "sdkTunnel" {
|
||||
sc := c.Tunnel()
|
||||
c = &vim25.Client{
|
||||
Client: sc,
|
||||
RoundTripper: sc,
|
||||
ServiceContent: c.ServiceContent,
|
||||
}
|
||||
// When http.Transport.Proxy is used, our thumbprint checker is bypassed, resulting in:
|
||||
// "Post https://sdkTunnel:8089/sdk: x509: certificate is valid for $vcenter_hostname, not sdkTunnel"
|
||||
// The only easy way around this is to disable verification for the call to LoginExtensionByCertificate().
|
||||
// TODO: find a way to avoid disabling InsecureSkipVerify.
|
||||
c.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify = true
|
||||
}
|
||||
|
||||
req := types.LoginExtensionByCertificate{
|
||||
This: sm.Reference(),
|
||||
ExtensionKey: key,
|
||||
Locale: locale,
|
||||
Locale: Locale,
|
||||
}
|
||||
|
||||
login, err := methods.LoginExtensionByCertificate(ctx, sm.client, &req)
|
||||
login, err := methods.LoginExtensionByCertificate(ctx, c, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Copy the session cookie
|
||||
sm.client.Jar.SetCookies(u, c.Jar.Cookies(c.URL()))
|
||||
|
||||
sm.userSession = &login.Returnval
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sm *Manager) LoginByToken(ctx context.Context) error {
|
||||
req := types.LoginByToken{
|
||||
This: sm.Reference(),
|
||||
Locale: Locale,
|
||||
}
|
||||
|
||||
login, err := methods.LoginByToken(ctx, sm.client, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -199,3 +254,31 @@ func (sm *Manager) AcquireLocalTicket(ctx context.Context, userName string) (*ty
|
|||
|
||||
return &res.Returnval, nil
|
||||
}
|
||||
|
||||
func (sm *Manager) AcquireCloneTicket(ctx context.Context) (string, error) {
|
||||
req := types.AcquireCloneTicket{
|
||||
This: sm.Reference(),
|
||||
}
|
||||
|
||||
res, err := methods.AcquireCloneTicket(ctx, sm.client, &req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return res.Returnval, nil
|
||||
}
|
||||
|
||||
func (sm *Manager) CloneSession(ctx context.Context, ticket string) error {
|
||||
req := types.CloneSession{
|
||||
This: sm.Reference(),
|
||||
CloneTicket: ticket,
|
||||
}
|
||||
|
||||
res, err := methods.CloneSession(ctx, sm.client, &req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sm.userSession = &res.Returnval
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ func (t *taskCallback) fn(pc []types.PropertyChange) bool {
|
|||
t.info = &ti
|
||||
}
|
||||
|
||||
// t.info could be nil if pc can't satify the rules above
|
||||
// t.info could be nil if pc can't satisfy the rules above
|
||||
if t.info == nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -19,12 +19,30 @@ package vim25
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/methods"
|
||||
"github.com/vmware/govmomi/vim25/soap"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
const (
|
||||
Namespace = "vim25"
|
||||
Version = "6.7"
|
||||
Path = "/sdk"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceInstance = types.ManagedObjectReference{
|
||||
Type: "ServiceInstance",
|
||||
Value: "ServiceInstance",
|
||||
}
|
||||
)
|
||||
|
||||
// Client is a tiny wrapper around the vim25/soap Client that stores session
|
||||
// specific state (i.e. state that only needs to be retrieved once after the
|
||||
// client has been created). This means the client can be reused after
|
||||
|
@ -40,27 +58,63 @@ type Client struct {
|
|||
RoundTripper soap.RoundTripper
|
||||
}
|
||||
|
||||
// NewClient creates and returns a new client wirh the ServiceContent field
|
||||
// NewClient creates and returns a new client with the ServiceContent field
|
||||
// filled in.
|
||||
func NewClient(ctx context.Context, rt soap.RoundTripper) (*Client, error) {
|
||||
serviceContent, err := methods.GetServiceContent(ctx, rt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c := Client{
|
||||
ServiceContent: serviceContent,
|
||||
RoundTripper: rt,
|
||||
RoundTripper: rt,
|
||||
}
|
||||
|
||||
// Set client if it happens to be a soap.Client
|
||||
if sc, ok := rt.(*soap.Client); ok {
|
||||
c.Client = sc
|
||||
|
||||
if c.Namespace == "" {
|
||||
c.Namespace = "urn:" + Namespace
|
||||
} else if !strings.Contains(c.Namespace, ":") {
|
||||
c.Namespace = "urn:" + c.Namespace // ensure valid URI format
|
||||
}
|
||||
if c.Version == "" {
|
||||
c.Version = Version
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
c.ServiceContent, err = methods.GetServiceContent(ctx, rt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
// UseServiceVersion sets soap.Client.Version to the current version of the service endpoint via /sdk/vimServiceVersions.xml
|
||||
func (c *Client) UseServiceVersion() error {
|
||||
u := c.URL()
|
||||
u.Path = path.Join(Path, "vimServiceVersions.xml")
|
||||
|
||||
res, err := c.Get(u.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("http.Get(%s): %s", u.Path, err)
|
||||
}
|
||||
|
||||
v := struct {
|
||||
Version *string `xml:"namespace>version"`
|
||||
}{&c.Version}
|
||||
|
||||
err = xml.NewDecoder(res.Body).Decode(&v)
|
||||
_ = res.Body.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("xml.Decode(%s): %s", u.Path, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RoundTrip dispatches to the RoundTripper field.
|
||||
func (c *Client) RoundTrip(ctx context.Context, req, res soap.HasFault) error {
|
||||
return c.RoundTripper.RoundTrip(ctx, req, res)
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
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 methods
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/vmware/govmomi/vim25/soap"
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
type RetrieveDynamicTypeManagerBody struct {
|
||||
Req *types.RetrieveDynamicTypeManager `xml:"urn:vim25 RetrieveDynamicTypeManager"`
|
||||
Res *types.RetrieveDynamicTypeManagerResponse `xml:"urn:vim25 RetrieveDynamicTypeManagerResponse"`
|
||||
Fault_ *soap.Fault
|
||||
}
|
||||
|
||||
func (b *RetrieveDynamicTypeManagerBody) Fault() *soap.Fault { return b.Fault_ }
|
||||
|
||||
func RetrieveDynamicTypeManager(ctx context.Context, r soap.RoundTripper, req *types.RetrieveDynamicTypeManager) (*types.RetrieveDynamicTypeManagerResponse, error) {
|
||||
var reqBody, resBody RetrieveDynamicTypeManagerBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
}
|
||||
|
||||
type RetrieveManagedMethodExecuterBody struct {
|
||||
Req *types.RetrieveManagedMethodExecuter `xml:"urn:vim25 RetrieveManagedMethodExecuter"`
|
||||
Res *types.RetrieveManagedMethodExecuterResponse `xml:"urn:vim25 RetrieveManagedMethodExecuterResponse"`
|
||||
Fault_ *soap.Fault
|
||||
}
|
||||
|
||||
func (b *RetrieveManagedMethodExecuterBody) Fault() *soap.Fault { return b.Fault_ }
|
||||
|
||||
func RetrieveManagedMethodExecuter(ctx context.Context, r soap.RoundTripper, req *types.RetrieveManagedMethodExecuter) (*types.RetrieveManagedMethodExecuterResponse, error) {
|
||||
var reqBody, resBody RetrieveManagedMethodExecuterBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
}
|
||||
|
||||
type DynamicTypeMgrQueryMoInstancesBody struct {
|
||||
Req *types.DynamicTypeMgrQueryMoInstances `xml:"urn:vim25 DynamicTypeMgrQueryMoInstances"`
|
||||
Res *types.DynamicTypeMgrQueryMoInstancesResponse `xml:"urn:vim25 DynamicTypeMgrQueryMoInstancesResponse"`
|
||||
Fault_ *soap.Fault
|
||||
}
|
||||
|
||||
func (b *DynamicTypeMgrQueryMoInstancesBody) Fault() *soap.Fault { return b.Fault_ }
|
||||
|
||||
func DynamicTypeMgrQueryMoInstances(ctx context.Context, r soap.RoundTripper, req *types.DynamicTypeMgrQueryMoInstances) (*types.DynamicTypeMgrQueryMoInstancesResponse, error) {
|
||||
var reqBody, resBody DynamicTypeMgrQueryMoInstancesBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
}
|
||||
|
||||
type DynamicTypeMgrQueryTypeInfoBody struct {
|
||||
Req *types.DynamicTypeMgrQueryTypeInfo `xml:"urn:vim25 DynamicTypeMgrQueryTypeInfo"`
|
||||
Res *types.DynamicTypeMgrQueryTypeInfoResponse `xml:"urn:vim25 DynamicTypeMgrQueryTypeInfoResponse"`
|
||||
Fault_ *soap.Fault
|
||||
}
|
||||
|
||||
func (b *DynamicTypeMgrQueryTypeInfoBody) Fault() *soap.Fault { return b.Fault_ }
|
||||
|
||||
func DynamicTypeMgrQueryTypeInfo(ctx context.Context, r soap.RoundTripper, req *types.DynamicTypeMgrQueryTypeInfo) (*types.DynamicTypeMgrQueryTypeInfoResponse, error) {
|
||||
var reqBody, resBody DynamicTypeMgrQueryTypeInfoBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
}
|
||||
|
||||
type ExecuteSoapBody struct {
|
||||
Req *types.ExecuteSoap `xml:"urn:vim25 ExecuteSoap"`
|
||||
Res *types.ExecuteSoapResponse `xml:"urn:vim25 ExecuteSoapResponse"`
|
||||
Fault_ *soap.Fault
|
||||
}
|
||||
|
||||
func (b *ExecuteSoapBody) Fault() *soap.Fault { return b.Fault_ }
|
||||
|
||||
func ExecuteSoap(ctx context.Context, r soap.RoundTripper, req *types.ExecuteSoap) (*types.ExecuteSoapResponse, error) {
|
||||
var reqBody, resBody ExecuteSoapBody
|
||||
|
||||
reqBody.Req = req
|
||||
|
||||
if err := r.RoundTrip(ctx, &reqBody, &resBody); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resBody.Res, nil
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -24,14 +24,15 @@ import (
|
|||
"github.com/vmware/govmomi/vim25/types"
|
||||
)
|
||||
|
||||
var ServiceInstance = types.ManagedObjectReference{
|
||||
// copy of vim25.ServiceInstance to avoid import cycle
|
||||
var serviceInstance = types.ManagedObjectReference{
|
||||
Type: "ServiceInstance",
|
||||
Value: "ServiceInstance",
|
||||
}
|
||||
|
||||
func GetServiceContent(ctx context.Context, r soap.RoundTripper) (types.ServiceContent, error) {
|
||||
req := types.RetrieveServiceContent{
|
||||
This: ServiceInstance,
|
||||
This: serviceInstance,
|
||||
}
|
||||
|
||||
res, err := RetrieveServiceContent(ctx, r, &req)
|
||||
|
@ -44,7 +45,7 @@ func GetServiceContent(ctx context.Context, r soap.RoundTripper) (types.ServiceC
|
|||
|
||||
func GetCurrentTime(ctx context.Context, r soap.RoundTripper) (*time.Time, error) {
|
||||
req := types.CurrentTime{
|
||||
This: ServiceInstance,
|
||||
This: serviceInstance,
|
||||
}
|
||||
|
||||
res, err := CurrentTime(ctx, r, &req)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2014-2018 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.
|
||||
|
@ -164,6 +164,22 @@ func init() {
|
|||
t["CryptoManager"] = reflect.TypeOf((*CryptoManager)(nil)).Elem()
|
||||
}
|
||||
|
||||
type CryptoManagerHost struct {
|
||||
CryptoManager
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["CryptoManagerHost"] = reflect.TypeOf((*CryptoManagerHost)(nil)).Elem()
|
||||
}
|
||||
|
||||
type CryptoManagerHostKMS struct {
|
||||
CryptoManagerHost
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["CryptoManagerHostKMS"] = reflect.TypeOf((*CryptoManagerHostKMS)(nil)).Elem()
|
||||
}
|
||||
|
||||
type CryptoManagerKmip struct {
|
||||
CryptoManager
|
||||
|
||||
|
@ -759,9 +775,10 @@ func init() {
|
|||
type HostGraphicsManager struct {
|
||||
ExtensibleManagedObject
|
||||
|
||||
GraphicsInfo []types.HostGraphicsInfo `mo:"graphicsInfo"`
|
||||
GraphicsConfig *types.HostGraphicsConfig `mo:"graphicsConfig"`
|
||||
SharedPassthruGpuTypes []string `mo:"sharedPassthruGpuTypes"`
|
||||
GraphicsInfo []types.HostGraphicsInfo `mo:"graphicsInfo"`
|
||||
GraphicsConfig *types.HostGraphicsConfig `mo:"graphicsConfig"`
|
||||
SharedPassthruGpuTypes []string `mo:"sharedPassthruGpuTypes"`
|
||||
SharedGpuCapabilities []types.HostSharedGpuCapabilities `mo:"sharedGpuCapabilities"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -853,6 +870,20 @@ func init() {
|
|||
t["HostNetworkSystem"] = reflect.TypeOf((*HostNetworkSystem)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostNvdimmSystem struct {
|
||||
Self types.ManagedObjectReference
|
||||
|
||||
NvdimmSystemInfo types.NvdimmSystemInfo `mo:"nvdimmSystemInfo"`
|
||||
}
|
||||
|
||||
func (m HostNvdimmSystem) Reference() types.ManagedObjectReference {
|
||||
return m.Self
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["HostNvdimmSystem"] = reflect.TypeOf((*HostNvdimmSystem)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostPatchManager struct {
|
||||
Self types.ManagedObjectReference
|
||||
}
|
||||
|
@ -894,7 +925,10 @@ func init() {
|
|||
type HostProfile struct {
|
||||
Profile
|
||||
|
||||
ReferenceHost *types.ManagedObjectReference `mo:"referenceHost"`
|
||||
ValidationState *string `mo:"validationState"`
|
||||
ValidationStateUpdateTime *time.Time `mo:"validationStateUpdateTime"`
|
||||
ValidationFailureInfo *types.HostProfileValidationFailureInfo `mo:"validationFailureInfo"`
|
||||
ReferenceHost *types.ManagedObjectReference `mo:"referenceHost"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -962,18 +996,25 @@ func init() {
|
|||
type HostSystem struct {
|
||||
ManagedEntity
|
||||
|
||||
Runtime types.HostRuntimeInfo `mo:"runtime"`
|
||||
Summary types.HostListSummary `mo:"summary"`
|
||||
Hardware *types.HostHardwareInfo `mo:"hardware"`
|
||||
Capability *types.HostCapability `mo:"capability"`
|
||||
LicensableResource types.HostLicensableResourceInfo `mo:"licensableResource"`
|
||||
ConfigManager types.HostConfigManager `mo:"configManager"`
|
||||
Config *types.HostConfigInfo `mo:"config"`
|
||||
Vm []types.ManagedObjectReference `mo:"vm"`
|
||||
Datastore []types.ManagedObjectReference `mo:"datastore"`
|
||||
Network []types.ManagedObjectReference `mo:"network"`
|
||||
DatastoreBrowser types.ManagedObjectReference `mo:"datastoreBrowser"`
|
||||
SystemResources *types.HostSystemResourceInfo `mo:"systemResources"`
|
||||
Runtime types.HostRuntimeInfo `mo:"runtime"`
|
||||
Summary types.HostListSummary `mo:"summary"`
|
||||
Hardware *types.HostHardwareInfo `mo:"hardware"`
|
||||
Capability *types.HostCapability `mo:"capability"`
|
||||
LicensableResource types.HostLicensableResourceInfo `mo:"licensableResource"`
|
||||
RemediationState *types.HostSystemRemediationState `mo:"remediationState"`
|
||||
PrecheckRemediationResult *types.ApplyHostProfileConfigurationSpec `mo:"precheckRemediationResult"`
|
||||
RemediationResult *types.ApplyHostProfileConfigurationResult `mo:"remediationResult"`
|
||||
ComplianceCheckState *types.HostSystemComplianceCheckState `mo:"complianceCheckState"`
|
||||
ComplianceCheckResult *types.ComplianceResult `mo:"complianceCheckResult"`
|
||||
ConfigManager types.HostConfigManager `mo:"configManager"`
|
||||
Config *types.HostConfigInfo `mo:"config"`
|
||||
Vm []types.ManagedObjectReference `mo:"vm"`
|
||||
Datastore []types.ManagedObjectReference `mo:"datastore"`
|
||||
Network []types.ManagedObjectReference `mo:"network"`
|
||||
DatastoreBrowser types.ManagedObjectReference `mo:"datastoreBrowser"`
|
||||
SystemResources *types.HostSystemResourceInfo `mo:"systemResources"`
|
||||
AnswerFileValidationState *types.AnswerFileStatusResult `mo:"answerFileValidationState"`
|
||||
AnswerFileValidationResult *types.AnswerFileStatusResult `mo:"answerFileValidationResult"`
|
||||
}
|
||||
|
||||
func (m *HostSystem) Entity() *ManagedEntity {
|
||||
|
@ -1056,10 +1097,13 @@ func init() {
|
|||
type HttpNfcLease struct {
|
||||
Self types.ManagedObjectReference
|
||||
|
||||
InitializeProgress int32 `mo:"initializeProgress"`
|
||||
Info *types.HttpNfcLeaseInfo `mo:"info"`
|
||||
State types.HttpNfcLeaseState `mo:"state"`
|
||||
Error *types.LocalizedMethodFault `mo:"error"`
|
||||
InitializeProgress int32 `mo:"initializeProgress"`
|
||||
TransferProgress int32 `mo:"transferProgress"`
|
||||
Mode string `mo:"mode"`
|
||||
Capabilities types.HttpNfcLeaseCapabilities `mo:"capabilities"`
|
||||
Info *types.HttpNfcLeaseInfo `mo:"info"`
|
||||
State types.HttpNfcLeaseState `mo:"state"`
|
||||
Error *types.LocalizedMethodFault `mo:"error"`
|
||||
}
|
||||
|
||||
func (m HttpNfcLease) Reference() types.ManagedObjectReference {
|
||||
|
|
|
@ -65,6 +65,22 @@ func ObjectContentToType(o types.ObjectContent) (interface{}, error) {
|
|||
return v.Elem().Interface(), nil
|
||||
}
|
||||
|
||||
// ApplyPropertyChange converts the response of a call to WaitForUpdates
|
||||
// and applies it to the given managed object.
|
||||
func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
|
||||
t := typeInfoForType(obj.Reference().Type)
|
||||
v := reflect.ValueOf(obj)
|
||||
|
||||
for _, p := range changes {
|
||||
rv, ok := t.props[p.Name]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
assignValue(v, rv, reflect.ValueOf(p.Val))
|
||||
}
|
||||
}
|
||||
|
||||
// LoadRetrievePropertiesResponse converts the response of a call to
|
||||
// RetrieveProperties to one or more managed objects.
|
||||
func LoadRetrievePropertiesResponse(res *types.RetrievePropertiesResponse, dst interface{}) error {
|
||||
|
|
|
@ -155,7 +155,9 @@ func (t *typeInfo) build(typ reflect.Type, fn string, fi []int) {
|
|||
}
|
||||
}
|
||||
|
||||
// assignValue assignes a value 'pv' to the struct pointed to by 'val', given a
|
||||
var nilValue reflect.Value
|
||||
|
||||
// assignValue assigns a value 'pv' to the struct pointed to by 'val', given a
|
||||
// slice of field indices. It recurses into the struct until it finds the field
|
||||
// specified by the indices. It creates new values for pointer types where
|
||||
// needed.
|
||||
|
@ -172,6 +174,11 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
|||
rv := val.Field(fi[0])
|
||||
fi = fi[1:]
|
||||
if len(fi) == 0 {
|
||||
if pv == nilValue {
|
||||
pv = reflect.Zero(rv.Type())
|
||||
rv.Set(pv)
|
||||
return
|
||||
}
|
||||
rt := rv.Type()
|
||||
pt := pv.Type()
|
||||
|
||||
|
@ -182,6 +189,24 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
|||
rt = rv.Type()
|
||||
}
|
||||
|
||||
// If the target type is a slice, but the source is not, deference any ArrayOfXYZ type
|
||||
if rt.Kind() == reflect.Slice && pt.Kind() != reflect.Slice {
|
||||
if pt.Kind() == reflect.Ptr {
|
||||
pv = pv.Elem()
|
||||
pt = pt.Elem()
|
||||
}
|
||||
|
||||
m := arrayOfRegexp.FindStringSubmatch(pt.Name())
|
||||
if len(m) > 0 {
|
||||
pv = pv.FieldByName(m[1]) // ArrayOfXYZ type has single field named XYZ
|
||||
pt = pv.Type()
|
||||
|
||||
if !pv.IsValid() {
|
||||
panic(fmt.Sprintf("expected %s type to have field %s", m[0], m[1]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If type is an interface, check if pv implements it.
|
||||
if rt.Kind() == reflect.Interface && !pt.Implements(rt) {
|
||||
// Check if pointer to pv implements it.
|
||||
|
@ -193,6 +218,9 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
|||
} else {
|
||||
panic(fmt.Sprintf("type %s doesn't implement %s", pt.Name(), rt.Name()))
|
||||
}
|
||||
} else if rt.Kind() == reflect.Struct && pt.Kind() == reflect.Ptr {
|
||||
pv = pv.Elem()
|
||||
pt = pv.Type()
|
||||
}
|
||||
|
||||
if pt.AssignableTo(rt) {
|
||||
|
@ -200,7 +228,7 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
|||
} else if rt.ConvertibleTo(pt) {
|
||||
rv.Set(pv.Convert(rt))
|
||||
} else {
|
||||
panic(fmt.Sprintf("cannot assign %s (%s) to %s (%s)", rt.Name(), rt.Kind(), pt.Name(), pt.Kind()))
|
||||
panic(fmt.Sprintf("cannot assign %q (%s) to %q (%s)", rt.Name(), rt.Kind(), pt.Name(), pt.Kind()))
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -211,23 +239,6 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
|
|||
|
||||
var arrayOfRegexp = regexp.MustCompile("ArrayOf(.*)$")
|
||||
|
||||
func anyTypeToValue(t interface{}) reflect.Value {
|
||||
rt := reflect.TypeOf(t)
|
||||
rv := reflect.ValueOf(t)
|
||||
|
||||
// Dereference if ArrayOfXYZ type
|
||||
m := arrayOfRegexp.FindStringSubmatch(rt.Name())
|
||||
if len(m) > 0 {
|
||||
// ArrayOfXYZ type has single field named XYZ
|
||||
rv = rv.FieldByName(m[1])
|
||||
if !rv.IsValid() {
|
||||
panic(fmt.Sprintf("expected %s type to have field %s", m[0], m[1]))
|
||||
}
|
||||
}
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
// LoadObjectFromContent loads properties from the 'PropSet' field in the
|
||||
// specified ObjectContent value into the value it represents, which is
|
||||
// returned as a reflect.Value.
|
||||
|
@ -240,7 +251,7 @@ func (t *typeInfo) LoadFromObjectContent(o types.ObjectContent) (reflect.Value,
|
|||
if !ok {
|
||||
continue
|
||||
}
|
||||
assignValue(v, rv, anyTypeToValue(p.Val))
|
||||
assignValue(v, rv, reflect.ValueOf(p.Val))
|
||||
}
|
||||
|
||||
return v, nil
|
||||
|
|
|
@ -18,6 +18,7 @@ package progress
|
|||
|
||||
import (
|
||||
"container/list"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync/atomic"
|
||||
|
@ -25,11 +26,11 @@ import (
|
|||
)
|
||||
|
||||
type readerReport struct {
|
||||
t time.Time
|
||||
pos int64 // Keep first to ensure 64-bit alignment
|
||||
size int64 // Keep first to ensure 64-bit alignment
|
||||
bps *uint64 // Keep first to ensure 64-bit alignment
|
||||
|
||||
pos int64
|
||||
size int64
|
||||
bps *uint64
|
||||
t time.Time
|
||||
|
||||
err error
|
||||
}
|
||||
|
@ -75,16 +76,16 @@ type reader struct {
|
|||
|
||||
pos int64
|
||||
size int64
|
||||
bps uint64
|
||||
|
||||
bps uint64
|
||||
|
||||
ch chan<- Report
|
||||
ch chan<- Report
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func NewReader(s Sinker, r io.Reader, size int64) *reader {
|
||||
func NewReader(ctx context.Context, s Sinker, r io.Reader, size int64) *reader {
|
||||
pr := reader{
|
||||
r: r,
|
||||
|
||||
r: r,
|
||||
ctx: ctx,
|
||||
size: size,
|
||||
}
|
||||
|
||||
|
@ -99,11 +100,12 @@ func NewReader(s Sinker, r io.Reader, size int64) *reader {
|
|||
// underlying channel.
|
||||
func (r *reader) Read(b []byte) (int, error) {
|
||||
n, err := r.r.Read(b)
|
||||
if err != nil {
|
||||
r.pos += int64(n)
|
||||
|
||||
if err != nil && err != io.EOF {
|
||||
return n, err
|
||||
}
|
||||
|
||||
r.pos += int64(n)
|
||||
q := readerReport{
|
||||
t: time.Now(),
|
||||
pos: r.pos,
|
||||
|
@ -111,7 +113,10 @@ func (r *reader) Read(b []byte) (int, error) {
|
|||
bps: &r.bps,
|
||||
}
|
||||
|
||||
r.ch <- q
|
||||
select {
|
||||
case r.ch <- q:
|
||||
case <-r.ctx.Done():
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
@ -127,8 +132,11 @@ func (r *reader) Done(err error) {
|
|||
err: err,
|
||||
}
|
||||
|
||||
r.ch <- q
|
||||
close(r.ch)
|
||||
select {
|
||||
case r.ch <- q:
|
||||
close(r.ch)
|
||||
case <-r.ctx.Done():
|
||||
}
|
||||
}
|
||||
|
||||
// newBpsLoop returns a sink that monitors and stores throughput.
|
||||
|
@ -150,7 +158,7 @@ func bpsLoop(ch <-chan Report, dst *uint64) {
|
|||
|
||||
// Setup timer for front of list to become stale.
|
||||
if e := l.Front(); e != nil {
|
||||
dt := time.Second - time.Now().Sub(e.Value.(readerReport).t)
|
||||
dt := time.Second - time.Since(e.Value.(readerReport).t)
|
||||
tch = time.After(dt)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2014-2018 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.
|
||||
|
@ -28,12 +28,14 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -53,15 +55,9 @@ type RoundTripper interface {
|
|||
}
|
||||
|
||||
const (
|
||||
DefaultVimNamespace = "urn:vim25"
|
||||
DefaultVimVersion = "6.5"
|
||||
DefaultMinVimVersion = "5.5"
|
||||
SessionCookieName = "vmware_soap_session"
|
||||
)
|
||||
|
||||
type header struct {
|
||||
Cookie string `xml:"vcSessionCookie,omitempty"`
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
http.Client
|
||||
|
||||
|
@ -69,20 +65,31 @@ type Client struct {
|
|||
k bool // Named after curl's -k flag
|
||||
d *debugContainer
|
||||
t *http.Transport
|
||||
p *url.URL
|
||||
|
||||
hostsMu sync.Mutex
|
||||
hosts map[string]string
|
||||
|
||||
Namespace string // Vim namespace
|
||||
Version string // Vim version
|
||||
Types types.Func
|
||||
UserAgent string
|
||||
|
||||
header *header
|
||||
cookie string
|
||||
}
|
||||
|
||||
var schemeMatch = regexp.MustCompile(`^\w+://`)
|
||||
|
||||
type errInvalidCACertificate struct {
|
||||
File string
|
||||
}
|
||||
|
||||
func (e errInvalidCACertificate) Error() string {
|
||||
return fmt.Sprintf(
|
||||
"invalid certificate '%s', cannot be used as a trusted CA certificate",
|
||||
e.File,
|
||||
)
|
||||
}
|
||||
|
||||
// ParseURL is wrapper around url.Parse, where Scheme defaults to "https" and Path defaults to "/sdk"
|
||||
func ParseURL(s string) (*url.URL, error) {
|
||||
var err error
|
||||
|
@ -117,6 +124,8 @@ func NewClient(u *url.URL, insecure bool) *Client {
|
|||
u: u,
|
||||
k: insecure,
|
||||
d: newDebug(),
|
||||
|
||||
Types: types.TypeFunc(),
|
||||
}
|
||||
|
||||
// Initialize http.RoundTripper on client, so we can customize it below
|
||||
|
@ -147,35 +156,62 @@ func NewClient(u *url.URL, insecure bool) *Client {
|
|||
c.u = c.URL()
|
||||
c.u.User = nil
|
||||
|
||||
c.Namespace = DefaultVimNamespace
|
||||
c.Version = DefaultVimVersion
|
||||
|
||||
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
|
||||
vc := c.URL()
|
||||
u, err := url.Parse(path)
|
||||
if err != nil {
|
||||
log.Panicf("url.Parse(%q): %s", path, err)
|
||||
}
|
||||
if u.Host == "" {
|
||||
u.Scheme = vc.Scheme
|
||||
u.Host = vc.Host
|
||||
}
|
||||
|
||||
client := NewClient(u, c.k)
|
||||
client.Namespace = "urn:" + namespace
|
||||
client.Transport.(*http.Transport).TLSClientConfig = c.Transport.(*http.Transport).TLSClientConfig
|
||||
if cert := c.Certificate(); cert != nil {
|
||||
client.SetCertificate(*cert)
|
||||
}
|
||||
|
||||
client.Namespace = namespace
|
||||
// Copy the trusted thumbprints
|
||||
c.hostsMu.Lock()
|
||||
for k, v := range c.hosts {
|
||||
client.hosts[k] = v
|
||||
}
|
||||
c.hostsMu.Unlock()
|
||||
|
||||
// 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,
|
||||
}
|
||||
|
||||
if cookie.Name == SessionCookieName {
|
||||
client.cookie = cookie.Value
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Copy any query params (e.g. GOVMOMI_TUNNEL_PROXY_PORT used in testing)
|
||||
client.u.RawQuery = vc.RawQuery
|
||||
|
||||
client.UserAgent = c.UserAgent
|
||||
|
||||
vimTypes := c.Types
|
||||
client.Types = func(name string) (reflect.Type, bool) {
|
||||
kind, ok := vimTypes(name)
|
||||
if ok {
|
||||
return kind, ok
|
||||
}
|
||||
// vim25/xml typeToString() does not have an option to include namespace prefix.
|
||||
// Workaround this by re-trying the lookup with the namespace prefix.
|
||||
return vimTypes(namespace + ":" + name)
|
||||
}
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
|
@ -188,12 +224,16 @@ func (c *Client) SetRootCAs(file string) error {
|
|||
pool := x509.NewCertPool()
|
||||
|
||||
for _, name := range filepath.SplitList(file) {
|
||||
pem, err := ioutil.ReadFile(name)
|
||||
pem, err := ioutil.ReadFile(filepath.Clean(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pool.AppendCertsFromPEM(pem)
|
||||
if ok := pool.AppendCertsFromPEM(pem); !ok {
|
||||
return errInvalidCACertificate{
|
||||
File: name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.t.TLSClientConfig.RootCAs = pool
|
||||
|
@ -254,7 +294,7 @@ func (c *Client) LoadThumbprints(file string) error {
|
|||
}
|
||||
|
||||
func (c *Client) loadThumbprints(name string) error {
|
||||
f, err := os.Open(name)
|
||||
f, err := os.Open(filepath.Clean(name))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
|
@ -323,7 +363,7 @@ func (c *Client) dialTLS(network string, addr string) (net.Conn, error) {
|
|||
if thumbprint != peer {
|
||||
_ = conn.Close()
|
||||
|
||||
return nil, fmt.Errorf("Host %q thumbprint does not match %q", addr, thumbprint)
|
||||
return nil, fmt.Errorf("host %q thumbprint does not match %q", addr, thumbprint)
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
|
@ -347,19 +387,33 @@ func splitHostPort(host string) (string, string) {
|
|||
|
||||
const sdkTunnel = "sdkTunnel:8089"
|
||||
|
||||
func (c *Client) Certificate() *tls.Certificate {
|
||||
certs := c.t.TLSClientConfig.Certificates
|
||||
if len(certs) == 0 {
|
||||
return nil
|
||||
}
|
||||
return &certs[0]
|
||||
}
|
||||
|
||||
func (c *Client) SetCertificate(cert tls.Certificate) {
|
||||
t := c.Client.Transport.(*http.Transport)
|
||||
|
||||
// Extension certificate
|
||||
// Extension or HoK certificate
|
||||
t.TLSClientConfig.Certificates = []tls.Certificate{cert}
|
||||
}
|
||||
|
||||
// Tunnel returns a Client configured to proxy requests through vCenter's http port 80,
|
||||
// to the SDK tunnel virtual host. Use of the SDK tunnel is required by LoginExtensionByCertificate()
|
||||
// and optional for other methods.
|
||||
func (c *Client) Tunnel() *Client {
|
||||
tunnel := c.NewServiceClient(c.u.Path, c.Namespace)
|
||||
t := tunnel.Client.Transport.(*http.Transport)
|
||||
// Proxy to vCenter host on port 80
|
||||
host, _ := splitHostPort(c.u.Host)
|
||||
|
||||
host := tunnel.u.Hostname()
|
||||
// Should be no reason to change the default port other than testing
|
||||
key := "GOVMOMI_TUNNEL_PROXY_PORT"
|
||||
|
||||
port := c.URL().Query().Get(key)
|
||||
port := tunnel.URL().Query().Get(key)
|
||||
if port == "" {
|
||||
port = os.Getenv(key)
|
||||
}
|
||||
|
@ -368,20 +422,14 @@ func (c *Client) SetCertificate(cert tls.Certificate) {
|
|||
host += ":" + port
|
||||
}
|
||||
|
||||
c.p = &url.URL{
|
||||
t.Proxy = http.ProxyURL(&url.URL{
|
||||
Scheme: "http",
|
||||
Host: host,
|
||||
}
|
||||
t.Proxy = func(r *http.Request) (*url.URL, error) {
|
||||
// Only sdk requests should be proxied
|
||||
if r.URL.Path == "/sdk" {
|
||||
return c.p, nil
|
||||
}
|
||||
return http.ProxyFromEnvironment(r)
|
||||
}
|
||||
})
|
||||
|
||||
// Rewrite url Host to use the sdk tunnel, required for a certificate request.
|
||||
c.u.Host = sdkTunnel
|
||||
tunnel.u.Host = sdkTunnel
|
||||
return tunnel
|
||||
}
|
||||
|
||||
func (c *Client) URL() *url.URL {
|
||||
|
@ -393,6 +441,7 @@ type marshaledClient struct {
|
|||
Cookies []*http.Cookie
|
||||
URL *url.URL
|
||||
Insecure bool
|
||||
Version string
|
||||
}
|
||||
|
||||
func (c *Client) MarshalJSON() ([]byte, error) {
|
||||
|
@ -400,6 +449,7 @@ func (c *Client) MarshalJSON() ([]byte, error) {
|
|||
Cookies: c.Jar.Cookies(c.u),
|
||||
URL: c.u,
|
||||
Insecure: c.k,
|
||||
Version: c.Version,
|
||||
}
|
||||
|
||||
return json.Marshal(m)
|
||||
|
@ -414,36 +464,106 @@ func (c *Client) UnmarshalJSON(b []byte) error {
|
|||
}
|
||||
|
||||
*c = *NewClient(m.URL, m.Insecure)
|
||||
c.Version = m.Version
|
||||
c.Jar.SetCookies(m.URL, m.Cookies)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) do(ctx context.Context, req *http.Request) (*http.Response, error) {
|
||||
if nil == ctx || nil == ctx.Done() { // ctx.Done() is for ctx
|
||||
return c.Client.Do(req)
|
||||
type kindContext struct{}
|
||||
|
||||
func (c *Client) Do(ctx context.Context, req *http.Request, f func(*http.Response) error) error {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
return c.Client.Do(req.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error {
|
||||
var err 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() {
|
||||
defer d.done()
|
||||
}
|
||||
|
||||
b, err := xml.Marshal(reqEnv)
|
||||
if c.UserAgent != "" {
|
||||
req.Header.Set(`User-Agent`, c.UserAgent)
|
||||
}
|
||||
|
||||
ext := ""
|
||||
if d.enabled() {
|
||||
ext = d.debugRequest(req)
|
||||
}
|
||||
|
||||
tstart := time.Now()
|
||||
res, err := c.Client.Do(req.WithContext(ctx))
|
||||
tstop := time.Now()
|
||||
|
||||
if d.enabled() {
|
||||
var name string
|
||||
if kind, ok := ctx.Value(kindContext{}).(HasFault); ok {
|
||||
name = fmt.Sprintf("%T", kind)
|
||||
} else {
|
||||
name = fmt.Sprintf("%s %s", req.Method, req.URL)
|
||||
}
|
||||
d.logf("%6dms (%s)", tstop.Sub(tstart)/time.Millisecond, name)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
||||
if d.enabled() {
|
||||
d.debugResponse(res, ext)
|
||||
}
|
||||
|
||||
return f(res)
|
||||
}
|
||||
|
||||
// Signer can be implemented by soap.Header.Security to sign requests.
|
||||
// If the soap.Header.Security field is set to an implementation of Signer via WithHeader(),
|
||||
// then Client.RoundTrip will call Sign() to marshal the SOAP request.
|
||||
type Signer interface {
|
||||
Sign(Envelope) ([]byte, error)
|
||||
}
|
||||
|
||||
type headerContext struct{}
|
||||
|
||||
// WithHeader can be used to modify the outgoing request soap.Header fields.
|
||||
func (c *Client) WithHeader(ctx context.Context, header Header) context.Context {
|
||||
return context.WithValue(ctx, headerContext{}, header)
|
||||
}
|
||||
|
||||
func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error {
|
||||
var err error
|
||||
var b []byte
|
||||
|
||||
reqEnv := Envelope{Body: reqBody}
|
||||
resEnv := Envelope{Body: resBody}
|
||||
|
||||
h, ok := ctx.Value(headerContext{}).(Header)
|
||||
if !ok {
|
||||
h = Header{}
|
||||
}
|
||||
|
||||
// We added support for OperationID before soap.Header was exported.
|
||||
if id, ok := ctx.Value(types.ID{}).(string); ok {
|
||||
h.ID = id
|
||||
}
|
||||
|
||||
h.Cookie = c.cookie
|
||||
if h.Cookie != "" || h.ID != "" || h.Security != nil {
|
||||
reqEnv.Header = &h // XML marshal header only if a field is set
|
||||
}
|
||||
|
||||
if signer, ok := h.Security.(Signer); ok {
|
||||
b, err = signer.Sign(reqEnv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
b, err = xml.Marshal(reqEnv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
rawReqBody := io.MultiReader(strings.NewReader(xml.Header), bytes.NewReader(b))
|
||||
|
@ -453,56 +573,36 @@ func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error
|
|||
}
|
||||
|
||||
req.Header.Set(`Content-Type`, `text/xml; charset="utf-8"`)
|
||||
soapAction := fmt.Sprintf("%s/%s", c.Namespace, c.Version)
|
||||
req.Header.Set(`SOAPAction`, soapAction)
|
||||
if c.UserAgent != "" {
|
||||
req.Header.Set(`User-Agent`, c.UserAgent)
|
||||
|
||||
action := h.Action
|
||||
if action == "" {
|
||||
action = fmt.Sprintf("%s/%s", c.Namespace, c.Version)
|
||||
}
|
||||
req.Header.Set(`SOAPAction`, action)
|
||||
|
||||
if d.enabled() {
|
||||
d.debugRequest(req)
|
||||
}
|
||||
return c.Do(context.WithValue(ctx, kindContext{}, resBody), req, func(res *http.Response) error {
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
// OK
|
||||
case http.StatusInternalServerError:
|
||||
// Error, but typically includes a body explaining the error
|
||||
default:
|
||||
return errors.New(res.Status)
|
||||
}
|
||||
|
||||
tstart := time.Now()
|
||||
res, err := c.do(ctx, req)
|
||||
tstop := time.Now()
|
||||
dec := xml.NewDecoder(res.Body)
|
||||
dec.TypeFunc = c.Types
|
||||
err = dec.Decode(&resEnv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if d.enabled() {
|
||||
d.logf("%6dms (%T)", tstop.Sub(tstart)/time.Millisecond, resBody)
|
||||
}
|
||||
if f := resBody.Fault(); f != nil {
|
||||
return WrapSoapFault(f)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if d.enabled() {
|
||||
d.debugResponse(res)
|
||||
}
|
||||
|
||||
// Close response regardless of what happens next
|
||||
defer res.Body.Close()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
// OK
|
||||
case http.StatusInternalServerError:
|
||||
// Error, but typically includes a body explaining the error
|
||||
default:
|
||||
return errors.New(res.Status)
|
||||
}
|
||||
|
||||
dec := xml.NewDecoder(res.Body)
|
||||
dec.TypeFunc = types.TypeFunc()
|
||||
err = dec.Decode(&resEnv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if f := resBody.Fault(); f != nil {
|
||||
return WrapSoapFault(f)
|
||||
}
|
||||
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) CloseIdleConnections() {
|
||||
|
@ -542,11 +642,11 @@ var DefaultUpload = Upload{
|
|||
}
|
||||
|
||||
// Upload PUTs the local file to the given URL
|
||||
func (c *Client) Upload(f io.Reader, u *url.URL, param *Upload) error {
|
||||
func (c *Client) Upload(ctx context.Context, f io.Reader, u *url.URL, param *Upload) error {
|
||||
var err error
|
||||
|
||||
if param.Progress != nil {
|
||||
pr := progress.NewReader(param.Progress, f, param.ContentLength)
|
||||
pr := progress.NewReader(ctx, param.Progress, f, param.ContentLength)
|
||||
f = pr
|
||||
|
||||
// Mark progress reader as done when returning from this function.
|
||||
|
@ -560,6 +660,8 @@ func (c *Client) Upload(f io.Reader, u *url.URL, param *Upload) error {
|
|||
return err
|
||||
}
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
req.ContentLength = param.ContentLength
|
||||
req.Header.Set("Content-Type", param.Type)
|
||||
|
||||
|
@ -576,6 +678,8 @@ func (c *Client) Upload(f io.Reader, u *url.URL, param *Upload) error {
|
|||
return err
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
case http.StatusCreated:
|
||||
|
@ -587,7 +691,7 @@ func (c *Client) Upload(f io.Reader, u *url.URL, param *Upload) error {
|
|||
}
|
||||
|
||||
// UploadFile PUTs the local file to the given URL
|
||||
func (c *Client) UploadFile(file string, u *url.URL, param *Upload) error {
|
||||
func (c *Client) UploadFile(ctx context.Context, file string, u *url.URL, param *Upload) error {
|
||||
if param == nil {
|
||||
p := DefaultUpload // Copy since we set ContentLength
|
||||
param = &p
|
||||
|
@ -598,7 +702,7 @@ func (c *Client) UploadFile(file string, u *url.URL, param *Upload) error {
|
|||
return err
|
||||
}
|
||||
|
||||
f, err := os.Open(file)
|
||||
f, err := os.Open(filepath.Clean(file))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -606,7 +710,7 @@ func (c *Client) UploadFile(file string, u *url.URL, param *Upload) error {
|
|||
|
||||
param.ContentLength = s.Size()
|
||||
|
||||
return c.Upload(f, u, param)
|
||||
return c.Upload(ctx, f, u, param)
|
||||
}
|
||||
|
||||
type Download struct {
|
||||
|
@ -614,6 +718,7 @@ type Download struct {
|
|||
Headers map[string]string
|
||||
Ticket *http.Cookie
|
||||
Progress progress.Sinker
|
||||
Writer io.Writer
|
||||
}
|
||||
|
||||
var DefaultDownload = Download{
|
||||
|
@ -621,12 +726,14 @@ var DefaultDownload = Download{
|
|||
}
|
||||
|
||||
// DownloadRequest wraps http.Client.Do, returning the http.Response without checking its StatusCode
|
||||
func (c *Client) DownloadRequest(u *url.URL, param *Download) (*http.Response, error) {
|
||||
func (c *Client) DownloadRequest(ctx context.Context, u *url.URL, param *Download) (*http.Response, error) {
|
||||
req, err := http.NewRequest(param.Method, u.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
for k, v := range param.Headers {
|
||||
req.Header.Add(k, v)
|
||||
}
|
||||
|
@ -638,39 +745,9 @@ func (c *Client) DownloadRequest(u *url.URL, param *Download) (*http.Response, e
|
|||
return c.Client.Do(req)
|
||||
}
|
||||
|
||||
// directoryReader wraps an io.ReadCloser to support streaming download
|
||||
// of a guest directory, stops reading once it sees the stream trailer.
|
||||
// This is only useful when guest tools is the Go toolbox.
|
||||
// The trailer is required since TransferFromGuest requires a Content-Length,
|
||||
// which toolbox doesn't know ahead of time as the gzip'd tarball never touches the disk.
|
||||
// We opted to wrap this here for now rather than guest.FileManager so
|
||||
// DownloadFile can be also be used as-is to handle this use case.
|
||||
type directoryReader struct {
|
||||
io.ReadCloser
|
||||
}
|
||||
|
||||
var (
|
||||
gzipHeader = []byte{0x1f, 0x8b, 0x08} // rfc1952 {ID1, ID2, CM}
|
||||
gzipHeaderLen = len(gzipHeader)
|
||||
)
|
||||
|
||||
func (r *directoryReader) Read(buf []byte) (int, error) {
|
||||
nr, err := r.ReadCloser.Read(buf)
|
||||
|
||||
// Stop reading if the last N bytes are the gzipTrailer
|
||||
if nr >= gzipHeaderLen {
|
||||
if bytes.Equal(buf[nr-gzipHeaderLen:nr], gzipHeader) {
|
||||
nr -= gzipHeaderLen
|
||||
err = io.EOF
|
||||
}
|
||||
}
|
||||
|
||||
return nr, err
|
||||
}
|
||||
|
||||
// Download GETs the remote file from the given URL
|
||||
func (c *Client) Download(u *url.URL, param *Download) (io.ReadCloser, int64, error) {
|
||||
res, err := c.DownloadRequest(u, param)
|
||||
func (c *Client) Download(ctx context.Context, u *url.URL, param *Download) (io.ReadCloser, int64, error) {
|
||||
res, err := c.DownloadRequest(ctx, u, param)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
@ -687,37 +764,22 @@ func (c *Client) Download(u *url.URL, param *Download) (io.ReadCloser, int64, er
|
|||
|
||||
r := res.Body
|
||||
|
||||
if strings.HasSuffix(u.Path, "/") {
|
||||
r = &directoryReader{ReadCloser: r}
|
||||
}
|
||||
|
||||
return r, res.ContentLength, nil
|
||||
}
|
||||
|
||||
// DownloadFile GETs the given URL to a local file
|
||||
func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
||||
func (c *Client) WriteFile(ctx context.Context, file string, src io.Reader, size int64, s progress.Sinker, w io.Writer) error {
|
||||
var err error
|
||||
if param == nil {
|
||||
param = &DefaultDownload
|
||||
}
|
||||
|
||||
rc, contentLength, err := c.Download(u, param)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
var r io.Reader = rc
|
||||
r := src
|
||||
|
||||
fh, err := os.Create(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
if param.Progress != nil {
|
||||
pr := progress.NewReader(param.Progress, r, contentLength)
|
||||
r = pr
|
||||
if s != nil {
|
||||
pr := progress.NewReader(ctx, s, src, size)
|
||||
src = pr
|
||||
|
||||
// Mark progress reader as done when returning from this function.
|
||||
defer func() {
|
||||
|
@ -725,17 +787,34 @@ func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error {
|
|||
}()
|
||||
}
|
||||
|
||||
_, err = io.Copy(fh, r)
|
||||
if err != nil {
|
||||
return err
|
||||
if w == nil {
|
||||
w = fh
|
||||
} else {
|
||||
w = io.MultiWriter(w, fh)
|
||||
}
|
||||
|
||||
// Assign error before returning so that it gets picked up by the deferred
|
||||
// function marking the progress reader as done.
|
||||
err = fh.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
_, err = io.Copy(w, r)
|
||||
|
||||
cerr := fh.Close()
|
||||
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// DownloadFile GETs the given URL to a local file
|
||||
func (c *Client) DownloadFile(ctx context.Context, file string, u *url.URL, param *Download) error {
|
||||
var err error
|
||||
if param == nil {
|
||||
param = &DefaultDownload
|
||||
}
|
||||
|
||||
rc, contentLength, err := c.Download(ctx, u, param)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.WriteFile(ctx, file, rc, contentLength, param.Progress, param.Writer)
|
||||
}
|
||||
|
|
|
@ -69,42 +69,50 @@ func (d *debugRoundTrip) newFile(suffix string) io.WriteCloser {
|
|||
return debug.NewFile(fmt.Sprintf("%d-%04d.%s", d.cn, d.rn, suffix))
|
||||
}
|
||||
|
||||
func (d *debugRoundTrip) debugRequest(req *http.Request) {
|
||||
func (d *debugRoundTrip) ext(h http.Header) string {
|
||||
const json = "application/json"
|
||||
ext := "xml"
|
||||
if h.Get("Accept") == json || h.Get("Content-Type") == json {
|
||||
ext = "json"
|
||||
}
|
||||
return ext
|
||||
}
|
||||
|
||||
func (d *debugRoundTrip) debugRequest(req *http.Request) string {
|
||||
if d == nil {
|
||||
return
|
||||
return ""
|
||||
}
|
||||
|
||||
var wc io.WriteCloser
|
||||
|
||||
// Capture headers
|
||||
wc = d.newFile("req.headers")
|
||||
var wc io.WriteCloser = d.newFile("req.headers")
|
||||
b, _ := httputil.DumpRequest(req, false)
|
||||
wc.Write(b)
|
||||
wc.Close()
|
||||
|
||||
ext := d.ext(req.Header)
|
||||
// Capture body
|
||||
wc = d.newFile("req.xml")
|
||||
wc = d.newFile("req." + ext)
|
||||
req.Body = newTeeReader(req.Body, wc)
|
||||
|
||||
// Delay closing until marked done
|
||||
d.cs = append(d.cs, wc)
|
||||
|
||||
return ext
|
||||
}
|
||||
|
||||
func (d *debugRoundTrip) debugResponse(res *http.Response) {
|
||||
func (d *debugRoundTrip) debugResponse(res *http.Response, ext string) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var wc io.WriteCloser
|
||||
|
||||
// Capture headers
|
||||
wc = d.newFile("res.headers")
|
||||
var wc io.WriteCloser = d.newFile("res.headers")
|
||||
b, _ := httputil.DumpResponse(res, false)
|
||||
wc.Write(b)
|
||||
wc.Close()
|
||||
|
||||
// Capture body
|
||||
wc = d.newFile("res.xml")
|
||||
wc = d.newFile("res." + ext)
|
||||
res.Body = newTeeReader(res.Body, wc)
|
||||
|
||||
// Delay closing until marked done
|
||||
|
|
|
@ -39,7 +39,11 @@ func (s soapFaultError) Error() string {
|
|||
msg := s.fault.String
|
||||
|
||||
if msg == "" {
|
||||
msg = reflect.TypeOf(s.fault.Detail.Fault).Name()
|
||||
if s.fault.Detail.Fault == nil {
|
||||
msg = "unknown fault"
|
||||
} else {
|
||||
msg = reflect.TypeOf(s.fault.Detail.Fault).Name()
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s: %s", s.fault.Code, msg)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2014-2018 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.
|
||||
|
@ -21,9 +21,17 @@ import (
|
|||
"github.com/vmware/govmomi/vim25/xml"
|
||||
)
|
||||
|
||||
// Header includes optional soap Header fields.
|
||||
type Header struct {
|
||||
Action string `xml:"-"` // Action is the 'SOAPAction' HTTP header value. Defaults to "Client.Namespace/Client.Version".
|
||||
Cookie string `xml:"vcSessionCookie,omitempty"` // Cookie is a vCenter session cookie that can be used with other SDK endpoints (e.g. pbm).
|
||||
ID string `xml:"operationID,omitempty"` // ID is the operationID used by ESX/vCenter logging for correlation.
|
||||
Security interface{} `xml:",omitempty"` // Security is used for SAML token authentication and request signing.
|
||||
}
|
||||
|
||||
type Envelope struct {
|
||||
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
|
||||
Header interface{} `xml:",omitempty"`
|
||||
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
|
||||
Header *Header `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header,omitempty"`
|
||||
Body interface{}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2014-2018 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.
|
||||
|
@ -82,6 +82,59 @@ func init() {
|
|||
t["AgentInstallFailedReason"] = reflect.TypeOf((*AgentInstallFailedReason)(nil)).Elem()
|
||||
}
|
||||
|
||||
type AlarmFilterSpecAlarmTypeByEntity string
|
||||
|
||||
const (
|
||||
AlarmFilterSpecAlarmTypeByEntityEntityTypeAll = AlarmFilterSpecAlarmTypeByEntity("entityTypeAll")
|
||||
AlarmFilterSpecAlarmTypeByEntityEntityTypeHost = AlarmFilterSpecAlarmTypeByEntity("entityTypeHost")
|
||||
AlarmFilterSpecAlarmTypeByEntityEntityTypeVm = AlarmFilterSpecAlarmTypeByEntity("entityTypeVm")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["AlarmFilterSpecAlarmTypeByEntity"] = reflect.TypeOf((*AlarmFilterSpecAlarmTypeByEntity)(nil)).Elem()
|
||||
}
|
||||
|
||||
type AlarmFilterSpecAlarmTypeByTrigger string
|
||||
|
||||
const (
|
||||
AlarmFilterSpecAlarmTypeByTriggerTriggerTypeAll = AlarmFilterSpecAlarmTypeByTrigger("triggerTypeAll")
|
||||
AlarmFilterSpecAlarmTypeByTriggerTriggerTypeEvent = AlarmFilterSpecAlarmTypeByTrigger("triggerTypeEvent")
|
||||
AlarmFilterSpecAlarmTypeByTriggerTriggerTypeMetric = AlarmFilterSpecAlarmTypeByTrigger("triggerTypeMetric")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["AlarmFilterSpecAlarmTypeByTrigger"] = reflect.TypeOf((*AlarmFilterSpecAlarmTypeByTrigger)(nil)).Elem()
|
||||
}
|
||||
|
||||
type AnswerFileValidationInfoStatus string
|
||||
|
||||
const (
|
||||
AnswerFileValidationInfoStatusSuccess = AnswerFileValidationInfoStatus("success")
|
||||
AnswerFileValidationInfoStatusFailed = AnswerFileValidationInfoStatus("failed")
|
||||
AnswerFileValidationInfoStatusFailed_defaults = AnswerFileValidationInfoStatus("failed_defaults")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["AnswerFileValidationInfoStatus"] = reflect.TypeOf((*AnswerFileValidationInfoStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ApplyHostProfileConfigurationResultStatus string
|
||||
|
||||
const (
|
||||
ApplyHostProfileConfigurationResultStatusSuccess = ApplyHostProfileConfigurationResultStatus("success")
|
||||
ApplyHostProfileConfigurationResultStatusFailed = ApplyHostProfileConfigurationResultStatus("failed")
|
||||
ApplyHostProfileConfigurationResultStatusReboot_failed = ApplyHostProfileConfigurationResultStatus("reboot_failed")
|
||||
ApplyHostProfileConfigurationResultStatusStateless_reboot_failed = ApplyHostProfileConfigurationResultStatus("stateless_reboot_failed")
|
||||
ApplyHostProfileConfigurationResultStatusCheck_compliance_failed = ApplyHostProfileConfigurationResultStatus("check_compliance_failed")
|
||||
ApplyHostProfileConfigurationResultStatusState_not_satisfied = ApplyHostProfileConfigurationResultStatus("state_not_satisfied")
|
||||
ApplyHostProfileConfigurationResultStatusExit_maintenancemode_failed = ApplyHostProfileConfigurationResultStatus("exit_maintenancemode_failed")
|
||||
ApplyHostProfileConfigurationResultStatusCanceled = ApplyHostProfileConfigurationResultStatus("canceled")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["ApplyHostProfileConfigurationResultStatus"] = reflect.TypeOf((*ApplyHostProfileConfigurationResultStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ArrayUpdateOperation string
|
||||
|
||||
const (
|
||||
|
@ -206,6 +259,18 @@ func init() {
|
|||
t["CheckTestType"] = reflect.TypeOf((*CheckTestType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ClusterComputeResourceHCIWorkflowState string
|
||||
|
||||
const (
|
||||
ClusterComputeResourceHCIWorkflowStateIn_progress = ClusterComputeResourceHCIWorkflowState("in_progress")
|
||||
ClusterComputeResourceHCIWorkflowStateDone = ClusterComputeResourceHCIWorkflowState("done")
|
||||
ClusterComputeResourceHCIWorkflowStateInvalid = ClusterComputeResourceHCIWorkflowState("invalid")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["ClusterComputeResourceHCIWorkflowState"] = reflect.TypeOf((*ClusterComputeResourceHCIWorkflowState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ClusterDasAamNodeStateDasState string
|
||||
|
||||
const (
|
||||
|
@ -410,6 +475,7 @@ const (
|
|||
ComplianceResultStatusCompliant = ComplianceResultStatus("compliant")
|
||||
ComplianceResultStatusNonCompliant = ComplianceResultStatus("nonCompliant")
|
||||
ComplianceResultStatusUnknown = ComplianceResultStatus("unknown")
|
||||
ComplianceResultStatusRunning = ComplianceResultStatus("running")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -440,6 +506,20 @@ func init() {
|
|||
t["ConfigSpecOperation"] = reflect.TypeOf((*ConfigSpecOperation)(nil)).Elem()
|
||||
}
|
||||
|
||||
type CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason string
|
||||
|
||||
const (
|
||||
CryptoManagerKmipCryptoKeyStatusKeyUnavailableReasonKeyStateMissingInCache = CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason("KeyStateMissingInCache")
|
||||
CryptoManagerKmipCryptoKeyStatusKeyUnavailableReasonKeyStateClusterInvalid = CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason("KeyStateClusterInvalid")
|
||||
CryptoManagerKmipCryptoKeyStatusKeyUnavailableReasonKeyStateClusterUnreachable = CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason("KeyStateClusterUnreachable")
|
||||
CryptoManagerKmipCryptoKeyStatusKeyUnavailableReasonKeyStateMissingInKMS = CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason("KeyStateMissingInKMS")
|
||||
CryptoManagerKmipCryptoKeyStatusKeyUnavailableReasonKeyStateNotActiveOrEnabled = CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason("KeyStateNotActiveOrEnabled")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason"] = reflect.TypeOf((*CryptoManagerKmipCryptoKeyStatusKeyUnavailableReason)(nil)).Elem()
|
||||
}
|
||||
|
||||
type CustomizationLicenseDataMode string
|
||||
|
||||
const (
|
||||
|
@ -499,6 +579,17 @@ func init() {
|
|||
t["DVPortStatusVmDirectPathGen2InactiveReasonOther"] = reflect.TypeOf((*DVPortStatusVmDirectPathGen2InactiveReasonOther)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DVSMacLimitPolicyType string
|
||||
|
||||
const (
|
||||
DVSMacLimitPolicyTypeAllow = DVSMacLimitPolicyType("allow")
|
||||
DVSMacLimitPolicyTypeDrop = DVSMacLimitPolicyType("drop")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["DVSMacLimitPolicyType"] = reflect.TypeOf((*DVSMacLimitPolicyType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DasConfigFaultDasConfigFaultReason string
|
||||
|
||||
const (
|
||||
|
@ -932,6 +1023,17 @@ func init() {
|
|||
t["FileSystemMountInfoVStorageSupportStatus"] = reflect.TypeOf((*FileSystemMountInfoVStorageSupportStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type FolderDesiredHostState string
|
||||
|
||||
const (
|
||||
FolderDesiredHostStateMaintenance = FolderDesiredHostState("maintenance")
|
||||
FolderDesiredHostStateNon_maintenance = FolderDesiredHostState("non_maintenance")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["FolderDesiredHostState"] = reflect.TypeOf((*FolderDesiredHostState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type FtIssuesOnHostHostSelectionType string
|
||||
|
||||
const (
|
||||
|
@ -1079,6 +1181,18 @@ func init() {
|
|||
t["HostCapabilityFtUnsupportedReason"] = reflect.TypeOf((*HostCapabilityFtUnsupportedReason)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostCapabilityUnmapMethodSupported string
|
||||
|
||||
const (
|
||||
HostCapabilityUnmapMethodSupportedPriority = HostCapabilityUnmapMethodSupported("priority")
|
||||
HostCapabilityUnmapMethodSupportedFixed = HostCapabilityUnmapMethodSupported("fixed")
|
||||
HostCapabilityUnmapMethodSupportedDynamic = HostCapabilityUnmapMethodSupported("dynamic")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostCapabilityUnmapMethodSupported"] = reflect.TypeOf((*HostCapabilityUnmapMethodSupported)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostCapabilityVmDirectPathGen2UnsupportedReason string
|
||||
|
||||
const (
|
||||
|
@ -1136,6 +1250,7 @@ const (
|
|||
HostCpuPackageVendorUnknown = HostCpuPackageVendor("unknown")
|
||||
HostCpuPackageVendorIntel = HostCpuPackageVendor("intel")
|
||||
HostCpuPackageVendorAmd = HostCpuPackageVendor("amd")
|
||||
HostCpuPackageVendorHygon = HostCpuPackageVendor("hygon")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -1186,8 +1301,12 @@ func init() {
|
|||
type HostDigestInfoDigestMethodType string
|
||||
|
||||
const (
|
||||
HostDigestInfoDigestMethodTypeSHA1 = HostDigestInfoDigestMethodType("SHA1")
|
||||
HostDigestInfoDigestMethodTypeMD5 = HostDigestInfoDigestMethodType("MD5")
|
||||
HostDigestInfoDigestMethodTypeSHA1 = HostDigestInfoDigestMethodType("SHA1")
|
||||
HostDigestInfoDigestMethodTypeMD5 = HostDigestInfoDigestMethodType("MD5")
|
||||
HostDigestInfoDigestMethodTypeSHA256 = HostDigestInfoDigestMethodType("SHA256")
|
||||
HostDigestInfoDigestMethodTypeSHA384 = HostDigestInfoDigestMethodType("SHA384")
|
||||
HostDigestInfoDigestMethodTypeSHA512 = HostDigestInfoDigestMethodType("SHA512")
|
||||
HostDigestInfoDigestMethodTypeSM3_256 = HostDigestInfoDigestMethodType("SM3_256")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -1261,6 +1380,7 @@ const (
|
|||
HostFileSystemVolumeFileSystemTypeVsan = HostFileSystemVolumeFileSystemType("vsan")
|
||||
HostFileSystemVolumeFileSystemTypeVFFS = HostFileSystemVolumeFileSystemType("VFFS")
|
||||
HostFileSystemVolumeFileSystemTypeVVOL = HostFileSystemVolumeFileSystemType("VVOL")
|
||||
HostFileSystemVolumeFileSystemTypePMEM = HostFileSystemVolumeFileSystemType("PMEM")
|
||||
HostFileSystemVolumeFileSystemTypeOTHER = HostFileSystemVolumeFileSystemType("OTHER")
|
||||
)
|
||||
|
||||
|
@ -1720,6 +1840,28 @@ func init() {
|
|||
t["HostProfileManagerAnswerFileStatus"] = reflect.TypeOf((*HostProfileManagerAnswerFileStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProfileManagerCompositionResultResultElementStatus string
|
||||
|
||||
const (
|
||||
HostProfileManagerCompositionResultResultElementStatusSuccess = HostProfileManagerCompositionResultResultElementStatus("success")
|
||||
HostProfileManagerCompositionResultResultElementStatusError = HostProfileManagerCompositionResultResultElementStatus("error")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostProfileManagerCompositionResultResultElementStatus"] = reflect.TypeOf((*HostProfileManagerCompositionResultResultElementStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProfileManagerCompositionValidationResultResultElementStatus string
|
||||
|
||||
const (
|
||||
HostProfileManagerCompositionValidationResultResultElementStatusSuccess = HostProfileManagerCompositionValidationResultResultElementStatus("success")
|
||||
HostProfileManagerCompositionValidationResultResultElementStatusError = HostProfileManagerCompositionValidationResultResultElementStatus("error")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostProfileManagerCompositionValidationResultResultElementStatus"] = reflect.TypeOf((*HostProfileManagerCompositionValidationResultResultElementStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProfileManagerTaskListRequirement string
|
||||
|
||||
const (
|
||||
|
@ -1731,6 +1873,31 @@ func init() {
|
|||
t["HostProfileManagerTaskListRequirement"] = reflect.TypeOf((*HostProfileManagerTaskListRequirement)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProfileValidationFailureInfoUpdateType string
|
||||
|
||||
const (
|
||||
HostProfileValidationFailureInfoUpdateTypeHostBased = HostProfileValidationFailureInfoUpdateType("HostBased")
|
||||
HostProfileValidationFailureInfoUpdateTypeImport = HostProfileValidationFailureInfoUpdateType("Import")
|
||||
HostProfileValidationFailureInfoUpdateTypeEdit = HostProfileValidationFailureInfoUpdateType("Edit")
|
||||
HostProfileValidationFailureInfoUpdateTypeCompose = HostProfileValidationFailureInfoUpdateType("Compose")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostProfileValidationFailureInfoUpdateType"] = reflect.TypeOf((*HostProfileValidationFailureInfoUpdateType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProfileValidationState string
|
||||
|
||||
const (
|
||||
HostProfileValidationStateReady = HostProfileValidationState("Ready")
|
||||
HostProfileValidationStateRunning = HostProfileValidationState("Running")
|
||||
HostProfileValidationStateFailed = HostProfileValidationState("Failed")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostProfileValidationState"] = reflect.TypeOf((*HostProfileValidationState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostProtocolEndpointPEType string
|
||||
|
||||
const (
|
||||
|
@ -1834,9 +2001,11 @@ func init() {
|
|||
type HostSystemIdentificationInfoIdentifier string
|
||||
|
||||
const (
|
||||
HostSystemIdentificationInfoIdentifierAssetTag = HostSystemIdentificationInfoIdentifier("AssetTag")
|
||||
HostSystemIdentificationInfoIdentifierServiceTag = HostSystemIdentificationInfoIdentifier("ServiceTag")
|
||||
HostSystemIdentificationInfoIdentifierOemSpecificString = HostSystemIdentificationInfoIdentifier("OemSpecificString")
|
||||
HostSystemIdentificationInfoIdentifierAssetTag = HostSystemIdentificationInfoIdentifier("AssetTag")
|
||||
HostSystemIdentificationInfoIdentifierServiceTag = HostSystemIdentificationInfoIdentifier("ServiceTag")
|
||||
HostSystemIdentificationInfoIdentifierOemSpecificString = HostSystemIdentificationInfoIdentifier("OemSpecificString")
|
||||
HostSystemIdentificationInfoIdentifierEnclosureSerialNumberTag = HostSystemIdentificationInfoIdentifier("EnclosureSerialNumberTag")
|
||||
HostSystemIdentificationInfoIdentifierSerialNumberTag = HostSystemIdentificationInfoIdentifier("SerialNumberTag")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -1856,6 +2025,32 @@ func init() {
|
|||
t["HostSystemPowerState"] = reflect.TypeOf((*HostSystemPowerState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostSystemRemediationStateState string
|
||||
|
||||
const (
|
||||
HostSystemRemediationStateStateRemediationReady = HostSystemRemediationStateState("remediationReady")
|
||||
HostSystemRemediationStateStatePrecheckRemediationRunning = HostSystemRemediationStateState("precheckRemediationRunning")
|
||||
HostSystemRemediationStateStatePrecheckRemediationComplete = HostSystemRemediationStateState("precheckRemediationComplete")
|
||||
HostSystemRemediationStateStatePrecheckRemediationFailed = HostSystemRemediationStateState("precheckRemediationFailed")
|
||||
HostSystemRemediationStateStateRemediationRunning = HostSystemRemediationStateState("remediationRunning")
|
||||
HostSystemRemediationStateStateRemediationFailed = HostSystemRemediationStateState("remediationFailed")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostSystemRemediationStateState"] = reflect.TypeOf((*HostSystemRemediationStateState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostTpmAttestationInfoAcceptanceStatus string
|
||||
|
||||
const (
|
||||
HostTpmAttestationInfoAcceptanceStatusNotAccepted = HostTpmAttestationInfoAcceptanceStatus("notAccepted")
|
||||
HostTpmAttestationInfoAcceptanceStatusAccepted = HostTpmAttestationInfoAcceptanceStatus("accepted")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostTpmAttestationInfoAcceptanceStatus"] = reflect.TypeOf((*HostTpmAttestationInfoAcceptanceStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostUnresolvedVmfsExtentUnresolvedReason string
|
||||
|
||||
const (
|
||||
|
@ -1907,6 +2102,17 @@ func init() {
|
|||
t["HostVmciAccessManagerMode"] = reflect.TypeOf((*HostVmciAccessManagerMode)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostVmfsVolumeUnmapBandwidthPolicy string
|
||||
|
||||
const (
|
||||
HostVmfsVolumeUnmapBandwidthPolicyFixed = HostVmfsVolumeUnmapBandwidthPolicy("fixed")
|
||||
HostVmfsVolumeUnmapBandwidthPolicyDynamic = HostVmfsVolumeUnmapBandwidthPolicy("dynamic")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HostVmfsVolumeUnmapBandwidthPolicy"] = reflect.TypeOf((*HostVmfsVolumeUnmapBandwidthPolicy)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HostVmfsVolumeUnmapPriority string
|
||||
|
||||
const (
|
||||
|
@ -1918,6 +2124,28 @@ func init() {
|
|||
t["HostVmfsVolumeUnmapPriority"] = reflect.TypeOf((*HostVmfsVolumeUnmapPriority)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HttpNfcLeaseManifestEntryChecksumType string
|
||||
|
||||
const (
|
||||
HttpNfcLeaseManifestEntryChecksumTypeSha1 = HttpNfcLeaseManifestEntryChecksumType("sha1")
|
||||
HttpNfcLeaseManifestEntryChecksumTypeSha256 = HttpNfcLeaseManifestEntryChecksumType("sha256")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HttpNfcLeaseManifestEntryChecksumType"] = reflect.TypeOf((*HttpNfcLeaseManifestEntryChecksumType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HttpNfcLeaseMode string
|
||||
|
||||
const (
|
||||
HttpNfcLeaseModePushOrGet = HttpNfcLeaseMode("pushOrGet")
|
||||
HttpNfcLeaseModePull = HttpNfcLeaseMode("pull")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["HttpNfcLeaseMode"] = reflect.TypeOf((*HttpNfcLeaseMode)(nil)).Elem()
|
||||
}
|
||||
|
||||
type HttpNfcLeaseState string
|
||||
|
||||
const (
|
||||
|
@ -2288,6 +2516,110 @@ func init() {
|
|||
t["NumVirtualCpusIncompatibleReason"] = reflect.TypeOf((*NumVirtualCpusIncompatibleReason)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmInterleaveSetState string
|
||||
|
||||
const (
|
||||
NvdimmInterleaveSetStateInvalid = NvdimmInterleaveSetState("invalid")
|
||||
NvdimmInterleaveSetStateActive = NvdimmInterleaveSetState("active")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmInterleaveSetState"] = reflect.TypeOf((*NvdimmInterleaveSetState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNamespaceDetailsHealthStatus string
|
||||
|
||||
const (
|
||||
NvdimmNamespaceDetailsHealthStatusNormal = NvdimmNamespaceDetailsHealthStatus("normal")
|
||||
NvdimmNamespaceDetailsHealthStatusMissing = NvdimmNamespaceDetailsHealthStatus("missing")
|
||||
NvdimmNamespaceDetailsHealthStatusLabelMissing = NvdimmNamespaceDetailsHealthStatus("labelMissing")
|
||||
NvdimmNamespaceDetailsHealthStatusInterleaveBroken = NvdimmNamespaceDetailsHealthStatus("interleaveBroken")
|
||||
NvdimmNamespaceDetailsHealthStatusLabelInconsistent = NvdimmNamespaceDetailsHealthStatus("labelInconsistent")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNamespaceDetailsHealthStatus"] = reflect.TypeOf((*NvdimmNamespaceDetailsHealthStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNamespaceDetailsState string
|
||||
|
||||
const (
|
||||
NvdimmNamespaceDetailsStateInvalid = NvdimmNamespaceDetailsState("invalid")
|
||||
NvdimmNamespaceDetailsStateNotInUse = NvdimmNamespaceDetailsState("notInUse")
|
||||
NvdimmNamespaceDetailsStateInUse = NvdimmNamespaceDetailsState("inUse")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNamespaceDetailsState"] = reflect.TypeOf((*NvdimmNamespaceDetailsState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNamespaceHealthStatus string
|
||||
|
||||
const (
|
||||
NvdimmNamespaceHealthStatusNormal = NvdimmNamespaceHealthStatus("normal")
|
||||
NvdimmNamespaceHealthStatusMissing = NvdimmNamespaceHealthStatus("missing")
|
||||
NvdimmNamespaceHealthStatusLabelMissing = NvdimmNamespaceHealthStatus("labelMissing")
|
||||
NvdimmNamespaceHealthStatusInterleaveBroken = NvdimmNamespaceHealthStatus("interleaveBroken")
|
||||
NvdimmNamespaceHealthStatusLabelInconsistent = NvdimmNamespaceHealthStatus("labelInconsistent")
|
||||
NvdimmNamespaceHealthStatusBttCorrupt = NvdimmNamespaceHealthStatus("bttCorrupt")
|
||||
NvdimmNamespaceHealthStatusBadBlockSize = NvdimmNamespaceHealthStatus("badBlockSize")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNamespaceHealthStatus"] = reflect.TypeOf((*NvdimmNamespaceHealthStatus)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNamespaceState string
|
||||
|
||||
const (
|
||||
NvdimmNamespaceStateInvalid = NvdimmNamespaceState("invalid")
|
||||
NvdimmNamespaceStateNotInUse = NvdimmNamespaceState("notInUse")
|
||||
NvdimmNamespaceStateInUse = NvdimmNamespaceState("inUse")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNamespaceState"] = reflect.TypeOf((*NvdimmNamespaceState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNamespaceType string
|
||||
|
||||
const (
|
||||
NvdimmNamespaceTypeBlockNamespace = NvdimmNamespaceType("blockNamespace")
|
||||
NvdimmNamespaceTypePersistentNamespace = NvdimmNamespaceType("persistentNamespace")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNamespaceType"] = reflect.TypeOf((*NvdimmNamespaceType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmNvdimmHealthInfoState string
|
||||
|
||||
const (
|
||||
NvdimmNvdimmHealthInfoStateNormal = NvdimmNvdimmHealthInfoState("normal")
|
||||
NvdimmNvdimmHealthInfoStateError = NvdimmNvdimmHealthInfoState("error")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmNvdimmHealthInfoState"] = reflect.TypeOf((*NvdimmNvdimmHealthInfoState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type NvdimmRangeType string
|
||||
|
||||
const (
|
||||
NvdimmRangeTypeVolatileRange = NvdimmRangeType("volatileRange")
|
||||
NvdimmRangeTypePersistentRange = NvdimmRangeType("persistentRange")
|
||||
NvdimmRangeTypeControlRange = NvdimmRangeType("controlRange")
|
||||
NvdimmRangeTypeBlockRange = NvdimmRangeType("blockRange")
|
||||
NvdimmRangeTypeVolatileVirtualDiskRange = NvdimmRangeType("volatileVirtualDiskRange")
|
||||
NvdimmRangeTypeVolatileVirtualCDRange = NvdimmRangeType("volatileVirtualCDRange")
|
||||
NvdimmRangeTypePersistentVirtualDiskRange = NvdimmRangeType("persistentVirtualDiskRange")
|
||||
NvdimmRangeTypePersistentVirtualCDRange = NvdimmRangeType("persistentVirtualCDRange")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["NvdimmRangeType"] = reflect.TypeOf((*NvdimmRangeType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ObjectUpdateKind string
|
||||
|
||||
const (
|
||||
|
@ -2491,6 +2823,20 @@ func init() {
|
|||
t["ProfileNumericComparator"] = reflect.TypeOf((*ProfileNumericComparator)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ProfileParameterMetadataRelationType string
|
||||
|
||||
const (
|
||||
ProfileParameterMetadataRelationTypeDynamic_relation = ProfileParameterMetadataRelationType("dynamic_relation")
|
||||
ProfileParameterMetadataRelationTypeExtensible_relation = ProfileParameterMetadataRelationType("extensible_relation")
|
||||
ProfileParameterMetadataRelationTypeLocalizable_relation = ProfileParameterMetadataRelationType("localizable_relation")
|
||||
ProfileParameterMetadataRelationTypeStatic_relation = ProfileParameterMetadataRelationType("static_relation")
|
||||
ProfileParameterMetadataRelationTypeValidation_relation = ProfileParameterMetadataRelationType("validation_relation")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["ProfileParameterMetadataRelationType"] = reflect.TypeOf((*ProfileParameterMetadataRelationType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type PropertyChangeOp string
|
||||
|
||||
const (
|
||||
|
@ -2611,6 +2957,8 @@ const (
|
|||
ReplicationVmConfigFaultReasonForFaultReplicationNotEnabled = ReplicationVmConfigFaultReasonForFault("replicationNotEnabled")
|
||||
ReplicationVmConfigFaultReasonForFaultReplicationConfigurationFailed = ReplicationVmConfigFaultReasonForFault("replicationConfigurationFailed")
|
||||
ReplicationVmConfigFaultReasonForFaultEncryptedVm = ReplicationVmConfigFaultReasonForFault("encryptedVm")
|
||||
ReplicationVmConfigFaultReasonForFaultInvalidThumbprint = ReplicationVmConfigFaultReasonForFault("invalidThumbprint")
|
||||
ReplicationVmConfigFaultReasonForFaultIncompatibleDevice = ReplicationVmConfigFaultReasonForFault("incompatibleDevice")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -2628,6 +2976,7 @@ const (
|
|||
ReplicationVmFaultReasonForFaultInvalidState = ReplicationVmFaultReasonForFault("invalidState")
|
||||
ReplicationVmFaultReasonForFaultInvalidInstanceId = ReplicationVmFaultReasonForFault("invalidInstanceId")
|
||||
ReplicationVmFaultReasonForFaultCloseDiskError = ReplicationVmFaultReasonForFault("closeDiskError")
|
||||
ReplicationVmFaultReasonForFaultGroupExist = ReplicationVmFaultReasonForFault("groupExist")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -2688,10 +3037,11 @@ func init() {
|
|||
type ScsiDiskType string
|
||||
|
||||
const (
|
||||
ScsiDiskTypeNative512 = ScsiDiskType("native512")
|
||||
ScsiDiskTypeEmulated512 = ScsiDiskType("emulated512")
|
||||
ScsiDiskTypeNative4k = ScsiDiskType("native4k")
|
||||
ScsiDiskTypeUnknown = ScsiDiskType("unknown")
|
||||
ScsiDiskTypeNative512 = ScsiDiskType("native512")
|
||||
ScsiDiskTypeEmulated512 = ScsiDiskType("emulated512")
|
||||
ScsiDiskTypeNative4k = ScsiDiskType("native4k")
|
||||
ScsiDiskTypeSoftwareEmulated4k = ScsiDiskType("SoftwareEmulated4k")
|
||||
ScsiDiskTypeUnknown = ScsiDiskType("unknown")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -3266,6 +3616,18 @@ func init() {
|
|||
t["VirtualDeviceConfigSpecOperation"] = reflect.TypeOf((*VirtualDeviceConfigSpecOperation)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualDeviceConnectInfoMigrateConnectOp string
|
||||
|
||||
const (
|
||||
VirtualDeviceConnectInfoMigrateConnectOpConnect = VirtualDeviceConnectInfoMigrateConnectOp("connect")
|
||||
VirtualDeviceConnectInfoMigrateConnectOpDisconnect = VirtualDeviceConnectInfoMigrateConnectOp("disconnect")
|
||||
VirtualDeviceConnectInfoMigrateConnectOpUnset = VirtualDeviceConnectInfoMigrateConnectOp("unset")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["VirtualDeviceConnectInfoMigrateConnectOp"] = reflect.TypeOf((*VirtualDeviceConnectInfoMigrateConnectOp)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualDeviceConnectInfoStatus string
|
||||
|
||||
const (
|
||||
|
@ -3365,6 +3727,18 @@ func init() {
|
|||
t["VirtualDiskMode"] = reflect.TypeOf((*VirtualDiskMode)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualDiskRuleSpecRuleType string
|
||||
|
||||
const (
|
||||
VirtualDiskRuleSpecRuleTypeAffinity = VirtualDiskRuleSpecRuleType("affinity")
|
||||
VirtualDiskRuleSpecRuleTypeAntiAffinity = VirtualDiskRuleSpecRuleType("antiAffinity")
|
||||
VirtualDiskRuleSpecRuleTypeDisabled = VirtualDiskRuleSpecRuleType("disabled")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["VirtualDiskRuleSpecRuleType"] = reflect.TypeOf((*VirtualDiskRuleSpecRuleType)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualDiskSharing string
|
||||
|
||||
const (
|
||||
|
@ -3530,6 +3904,17 @@ func init() {
|
|||
t["VirtualMachineConnectionState"] = reflect.TypeOf((*VirtualMachineConnectionState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualMachineCryptoState string
|
||||
|
||||
const (
|
||||
VirtualMachineCryptoStateUnlocked = VirtualMachineCryptoState("unlocked")
|
||||
VirtualMachineCryptoStateLocked = VirtualMachineCryptoState("locked")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["VirtualMachineCryptoState"] = reflect.TypeOf((*VirtualMachineCryptoState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeStateVmDirectPathGen2InactiveReasonOther string
|
||||
|
||||
const (
|
||||
|
@ -3725,6 +4110,10 @@ const (
|
|||
VirtualMachineGuestOsIdentifierWindowsHyperVGuest = VirtualMachineGuestOsIdentifier("windowsHyperVGuest")
|
||||
VirtualMachineGuestOsIdentifierFreebsdGuest = VirtualMachineGuestOsIdentifier("freebsdGuest")
|
||||
VirtualMachineGuestOsIdentifierFreebsd64Guest = VirtualMachineGuestOsIdentifier("freebsd64Guest")
|
||||
VirtualMachineGuestOsIdentifierFreebsd11Guest = VirtualMachineGuestOsIdentifier("freebsd11Guest")
|
||||
VirtualMachineGuestOsIdentifierFreebsd11_64Guest = VirtualMachineGuestOsIdentifier("freebsd11_64Guest")
|
||||
VirtualMachineGuestOsIdentifierFreebsd12Guest = VirtualMachineGuestOsIdentifier("freebsd12Guest")
|
||||
VirtualMachineGuestOsIdentifierFreebsd12_64Guest = VirtualMachineGuestOsIdentifier("freebsd12_64Guest")
|
||||
VirtualMachineGuestOsIdentifierRedhatGuest = VirtualMachineGuestOsIdentifier("redhatGuest")
|
||||
VirtualMachineGuestOsIdentifierRhel2Guest = VirtualMachineGuestOsIdentifier("rhel2Guest")
|
||||
VirtualMachineGuestOsIdentifierRhel3Guest = VirtualMachineGuestOsIdentifier("rhel3Guest")
|
||||
|
@ -3737,18 +4126,21 @@ const (
|
|||
VirtualMachineGuestOsIdentifierRhel6_64Guest = VirtualMachineGuestOsIdentifier("rhel6_64Guest")
|
||||
VirtualMachineGuestOsIdentifierRhel7Guest = VirtualMachineGuestOsIdentifier("rhel7Guest")
|
||||
VirtualMachineGuestOsIdentifierRhel7_64Guest = VirtualMachineGuestOsIdentifier("rhel7_64Guest")
|
||||
VirtualMachineGuestOsIdentifierRhel8_64Guest = VirtualMachineGuestOsIdentifier("rhel8_64Guest")
|
||||
VirtualMachineGuestOsIdentifierCentosGuest = VirtualMachineGuestOsIdentifier("centosGuest")
|
||||
VirtualMachineGuestOsIdentifierCentos64Guest = VirtualMachineGuestOsIdentifier("centos64Guest")
|
||||
VirtualMachineGuestOsIdentifierCentos6Guest = VirtualMachineGuestOsIdentifier("centos6Guest")
|
||||
VirtualMachineGuestOsIdentifierCentos6_64Guest = VirtualMachineGuestOsIdentifier("centos6_64Guest")
|
||||
VirtualMachineGuestOsIdentifierCentos7Guest = VirtualMachineGuestOsIdentifier("centos7Guest")
|
||||
VirtualMachineGuestOsIdentifierCentos7_64Guest = VirtualMachineGuestOsIdentifier("centos7_64Guest")
|
||||
VirtualMachineGuestOsIdentifierCentos8_64Guest = VirtualMachineGuestOsIdentifier("centos8_64Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinuxGuest = VirtualMachineGuestOsIdentifier("oracleLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux64Guest = VirtualMachineGuestOsIdentifier("oracleLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux6Guest = VirtualMachineGuestOsIdentifier("oracleLinux6Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux6_64Guest = VirtualMachineGuestOsIdentifier("oracleLinux6_64Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux7Guest = VirtualMachineGuestOsIdentifier("oracleLinux7Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux7_64Guest = VirtualMachineGuestOsIdentifier("oracleLinux7_64Guest")
|
||||
VirtualMachineGuestOsIdentifierOracleLinux8_64Guest = VirtualMachineGuestOsIdentifier("oracleLinux8_64Guest")
|
||||
VirtualMachineGuestOsIdentifierSuseGuest = VirtualMachineGuestOsIdentifier("suseGuest")
|
||||
VirtualMachineGuestOsIdentifierSuse64Guest = VirtualMachineGuestOsIdentifier("suse64Guest")
|
||||
VirtualMachineGuestOsIdentifierSlesGuest = VirtualMachineGuestOsIdentifier("slesGuest")
|
||||
|
@ -3759,6 +4151,7 @@ const (
|
|||
VirtualMachineGuestOsIdentifierSles11_64Guest = VirtualMachineGuestOsIdentifier("sles11_64Guest")
|
||||
VirtualMachineGuestOsIdentifierSles12Guest = VirtualMachineGuestOsIdentifier("sles12Guest")
|
||||
VirtualMachineGuestOsIdentifierSles12_64Guest = VirtualMachineGuestOsIdentifier("sles12_64Guest")
|
||||
VirtualMachineGuestOsIdentifierSles15_64Guest = VirtualMachineGuestOsIdentifier("sles15_64Guest")
|
||||
VirtualMachineGuestOsIdentifierNld9Guest = VirtualMachineGuestOsIdentifier("nld9Guest")
|
||||
VirtualMachineGuestOsIdentifierOesGuest = VirtualMachineGuestOsIdentifier("oesGuest")
|
||||
VirtualMachineGuestOsIdentifierSjdsGuest = VirtualMachineGuestOsIdentifier("sjdsGuest")
|
||||
|
@ -3789,6 +4182,7 @@ const (
|
|||
VirtualMachineGuestOsIdentifierAsianux4_64Guest = VirtualMachineGuestOsIdentifier("asianux4_64Guest")
|
||||
VirtualMachineGuestOsIdentifierAsianux5_64Guest = VirtualMachineGuestOsIdentifier("asianux5_64Guest")
|
||||
VirtualMachineGuestOsIdentifierAsianux7_64Guest = VirtualMachineGuestOsIdentifier("asianux7_64Guest")
|
||||
VirtualMachineGuestOsIdentifierAsianux8_64Guest = VirtualMachineGuestOsIdentifier("asianux8_64Guest")
|
||||
VirtualMachineGuestOsIdentifierOpensuseGuest = VirtualMachineGuestOsIdentifier("opensuseGuest")
|
||||
VirtualMachineGuestOsIdentifierOpensuse64Guest = VirtualMachineGuestOsIdentifier("opensuse64Guest")
|
||||
VirtualMachineGuestOsIdentifierFedoraGuest = VirtualMachineGuestOsIdentifier("fedoraGuest")
|
||||
|
@ -3799,10 +4193,12 @@ const (
|
|||
VirtualMachineGuestOsIdentifierOther26xLinuxGuest = VirtualMachineGuestOsIdentifier("other26xLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierOtherLinuxGuest = VirtualMachineGuestOsIdentifier("otherLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierOther3xLinuxGuest = VirtualMachineGuestOsIdentifier("other3xLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierOther4xLinuxGuest = VirtualMachineGuestOsIdentifier("other4xLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierGenericLinuxGuest = VirtualMachineGuestOsIdentifier("genericLinuxGuest")
|
||||
VirtualMachineGuestOsIdentifierOther24xLinux64Guest = VirtualMachineGuestOsIdentifier("other24xLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierOther26xLinux64Guest = VirtualMachineGuestOsIdentifier("other26xLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierOther3xLinux64Guest = VirtualMachineGuestOsIdentifier("other3xLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierOther4xLinux64Guest = VirtualMachineGuestOsIdentifier("other4xLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierOtherLinux64Guest = VirtualMachineGuestOsIdentifier("otherLinux64Guest")
|
||||
VirtualMachineGuestOsIdentifierSolaris6Guest = VirtualMachineGuestOsIdentifier("solaris6Guest")
|
||||
VirtualMachineGuestOsIdentifierSolaris7Guest = VirtualMachineGuestOsIdentifier("solaris7Guest")
|
||||
|
@ -3831,10 +4227,13 @@ const (
|
|||
VirtualMachineGuestOsIdentifierDarwin14_64Guest = VirtualMachineGuestOsIdentifier("darwin14_64Guest")
|
||||
VirtualMachineGuestOsIdentifierDarwin15_64Guest = VirtualMachineGuestOsIdentifier("darwin15_64Guest")
|
||||
VirtualMachineGuestOsIdentifierDarwin16_64Guest = VirtualMachineGuestOsIdentifier("darwin16_64Guest")
|
||||
VirtualMachineGuestOsIdentifierDarwin17_64Guest = VirtualMachineGuestOsIdentifier("darwin17_64Guest")
|
||||
VirtualMachineGuestOsIdentifierDarwin18_64Guest = VirtualMachineGuestOsIdentifier("darwin18_64Guest")
|
||||
VirtualMachineGuestOsIdentifierVmkernelGuest = VirtualMachineGuestOsIdentifier("vmkernelGuest")
|
||||
VirtualMachineGuestOsIdentifierVmkernel5Guest = VirtualMachineGuestOsIdentifier("vmkernel5Guest")
|
||||
VirtualMachineGuestOsIdentifierVmkernel6Guest = VirtualMachineGuestOsIdentifier("vmkernel6Guest")
|
||||
VirtualMachineGuestOsIdentifierVmkernel65Guest = VirtualMachineGuestOsIdentifier("vmkernel65Guest")
|
||||
VirtualMachineGuestOsIdentifierAmazonlinux2_64Guest = VirtualMachineGuestOsIdentifier("amazonlinux2_64Guest")
|
||||
VirtualMachineGuestOsIdentifierOtherGuest = VirtualMachineGuestOsIdentifier("otherGuest")
|
||||
VirtualMachineGuestOsIdentifierOtherGuest64 = VirtualMachineGuestOsIdentifier("otherGuest64")
|
||||
)
|
||||
|
@ -4051,10 +4450,11 @@ func init() {
|
|||
type VirtualMachineTicketType string
|
||||
|
||||
const (
|
||||
VirtualMachineTicketTypeMks = VirtualMachineTicketType("mks")
|
||||
VirtualMachineTicketTypeDevice = VirtualMachineTicketType("device")
|
||||
VirtualMachineTicketTypeGuestControl = VirtualMachineTicketType("guestControl")
|
||||
VirtualMachineTicketTypeWebmks = VirtualMachineTicketType("webmks")
|
||||
VirtualMachineTicketTypeMks = VirtualMachineTicketType("mks")
|
||||
VirtualMachineTicketTypeDevice = VirtualMachineTicketType("device")
|
||||
VirtualMachineTicketTypeGuestControl = VirtualMachineTicketType("guestControl")
|
||||
VirtualMachineTicketTypeWebmks = VirtualMachineTicketType("webmks")
|
||||
VirtualMachineTicketTypeGuestIntegrity = VirtualMachineTicketType("guestIntegrity")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -4262,6 +4662,17 @@ func init() {
|
|||
t["VirtualSerialPortEndPoint"] = reflect.TypeOf((*VirtualSerialPortEndPoint)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VirtualVmxnet3VrdmaOptionDeviceProtocols string
|
||||
|
||||
const (
|
||||
VirtualVmxnet3VrdmaOptionDeviceProtocolsRocev1 = VirtualVmxnet3VrdmaOptionDeviceProtocols("rocev1")
|
||||
VirtualVmxnet3VrdmaOptionDeviceProtocolsRocev2 = VirtualVmxnet3VrdmaOptionDeviceProtocols("rocev2")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["VirtualVmxnet3VrdmaOptionDeviceProtocols"] = reflect.TypeOf((*VirtualVmxnet3VrdmaOptionDeviceProtocols)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VmDasBeingResetEventReasonCode string
|
||||
|
||||
const (
|
||||
|
@ -4319,6 +4730,8 @@ const (
|
|||
VmFaultToleranceConfigIssueReasonForIssueCpuHwmmuUnsupported = VmFaultToleranceConfigIssueReasonForIssue("cpuHwmmuUnsupported")
|
||||
VmFaultToleranceConfigIssueReasonForIssueCpuHvDisabled = VmFaultToleranceConfigIssueReasonForIssue("cpuHvDisabled")
|
||||
VmFaultToleranceConfigIssueReasonForIssueHasEFIFirmware = VmFaultToleranceConfigIssueReasonForIssue("hasEFIFirmware")
|
||||
VmFaultToleranceConfigIssueReasonForIssueTooManyVCPUs = VmFaultToleranceConfigIssueReasonForIssue("tooManyVCPUs")
|
||||
VmFaultToleranceConfigIssueReasonForIssueTooMuchMemory = VmFaultToleranceConfigIssueReasonForIssue("tooMuchMemory")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -4464,3 +4877,15 @@ const (
|
|||
func init() {
|
||||
t["WillLoseHAProtectionResolution"] = reflect.TypeOf((*WillLoseHAProtectionResolution)(nil)).Elem()
|
||||
}
|
||||
|
||||
type VslmVStorageObjectControlFlag string
|
||||
|
||||
const (
|
||||
VslmVStorageObjectControlFlagKeepAfterDeleteVm = VslmVStorageObjectControlFlag("keepAfterDeleteVm")
|
||||
VslmVStorageObjectControlFlagDisableRelocation = VslmVStorageObjectControlFlag("disableRelocation")
|
||||
VslmVStorageObjectControlFlagEnableChangedBlockTracking = VslmVStorageObjectControlFlag("enableChangedBlockTracking")
|
||||
)
|
||||
|
||||
func init() {
|
||||
t["vslmVStorageObjectControlFlag"] = reflect.TypeOf((*VslmVStorageObjectControlFlag)(nil)).Elem()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2015-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.
|
||||
|
@ -16,12 +16,28 @@ limitations under the License.
|
|||
|
||||
package types
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewBool(v bool) *bool {
|
||||
return &v
|
||||
}
|
||||
|
||||
func NewInt32(v int32) *int32 {
|
||||
return &v
|
||||
}
|
||||
|
||||
func NewInt64(v int64) *int64 {
|
||||
return &v
|
||||
}
|
||||
|
||||
func NewTime(v time.Time) *time.Time {
|
||||
return &v
|
||||
}
|
||||
|
||||
func NewReference(r ManagedObjectReference) *ManagedObjectReference {
|
||||
return &r
|
||||
}
|
||||
|
@ -50,3 +66,30 @@ func (r *ManagedObjectReference) FromString(o string) bool {
|
|||
func (c *PerfCounterInfo) Name() string {
|
||||
return c.GroupInfo.GetElementDescription().Key + "." + c.NameInfo.GetElementDescription().Key + "." + string(c.RollupType)
|
||||
}
|
||||
|
||||
func defaultResourceAllocationInfo() ResourceAllocationInfo {
|
||||
return ResourceAllocationInfo{
|
||||
Reservation: NewInt64(0),
|
||||
ExpandableReservation: NewBool(true),
|
||||
Limit: NewInt64(-1),
|
||||
Shares: &SharesInfo{
|
||||
Level: SharesLevelNormal,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultResourceConfigSpec returns a ResourceConfigSpec populated with the same default field values as vCenter.
|
||||
// Note that the wsdl marks these fields as optional, but they are required to be set when creating a resource pool.
|
||||
// They are only optional when updating a resource pool.
|
||||
func DefaultResourceConfigSpec() ResourceConfigSpec {
|
||||
return ResourceConfigSpec{
|
||||
CpuAllocation: defaultResourceAllocationInfo(),
|
||||
MemoryAllocation: defaultResourceAllocationInfo(),
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Known 6.5 issue where this event type is sent even though it is internal.
|
||||
// This workaround allows us to unmarshal and avoid NPEs.
|
||||
t["HostSubSpecificationUpdateEvent"] = reflect.TypeOf((*HostEvent)(nil)).Elem()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2014-2018 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.
|
||||
|
@ -214,6 +214,18 @@ func init() {
|
|||
t["BaseClusterAction"] = reflect.TypeOf((*ClusterAction)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *ClusterComputeResourceValidationResultBase) GetClusterComputeResourceValidationResultBase() *ClusterComputeResourceValidationResultBase {
|
||||
return b
|
||||
}
|
||||
|
||||
type BaseClusterComputeResourceValidationResultBase interface {
|
||||
GetClusterComputeResourceValidationResultBase() *ClusterComputeResourceValidationResultBase
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["BaseClusterComputeResourceValidationResultBase"] = reflect.TypeOf((*ClusterComputeResourceValidationResultBase)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *ClusterDasAdmissionControlInfo) GetClusterDasAdmissionControlInfo() *ClusterDasAdmissionControlInfo {
|
||||
return b
|
||||
}
|
||||
|
@ -786,6 +798,7 @@ func (b *DvsFilterConfig) GetDvsFilterConfig() *DvsFilterConfig { return b }
|
|||
|
||||
type BaseDvsFilterConfig interface {
|
||||
GetDvsFilterConfig() *DvsFilterConfig
|
||||
GetDvsTrafficFilterConfig() *DvsTrafficFilterConfig
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -828,12 +841,21 @@ func (b *DvsNetworkRuleQualifier) GetDvsNetworkRuleQualifier() *DvsNetworkRuleQu
|
|||
|
||||
type BaseDvsNetworkRuleQualifier interface {
|
||||
GetDvsNetworkRuleQualifier() *DvsNetworkRuleQualifier
|
||||
GetDvsIpNetworkRuleQualifier() *DvsIpNetworkRuleQualifier
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["BaseDvsNetworkRuleQualifier"] = reflect.TypeOf((*DvsNetworkRuleQualifier)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *DvsIpNetworkRuleQualifier) GetDvsIpNetworkRuleQualifier() *DvsIpNetworkRuleQualifier {
|
||||
return b
|
||||
}
|
||||
|
||||
type BaseDvsIpNetworkRuleQualifier interface {
|
||||
GetDvsIpNetworkRuleQualifier() *DvsIpNetworkRuleQualifier
|
||||
}
|
||||
|
||||
func (b *DvsTrafficFilterConfig) GetDvsTrafficFilterConfig() *DvsTrafficFilterConfig { return b }
|
||||
|
||||
type BaseDvsTrafficFilterConfig interface {
|
||||
|
@ -2360,16 +2382,6 @@ func init() {
|
|||
t["BaseReplicationVmFault"] = reflect.TypeOf((*ReplicationVmFault)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *ResourceAllocationInfo) GetResourceAllocationInfo() *ResourceAllocationInfo { return b }
|
||||
|
||||
type BaseResourceAllocationInfo interface {
|
||||
GetResourceAllocationInfo() *ResourceAllocationInfo
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["BaseResourceAllocationInfo"] = reflect.TypeOf((*ResourceAllocationInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *ResourceInUse) GetResourceInUse() *ResourceInUse { return b }
|
||||
|
||||
type BaseResourceInUse interface {
|
||||
|
|
|
@ -1,266 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014 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"
|
||||
|
||||
type DynamicTypeMgrQueryMoInstances struct {
|
||||
This ManagedObjectReference `xml:"_this"`
|
||||
FilterSpec BaseDynamicTypeMgrFilterSpec `xml:"filterSpec,omitempty,typeattr"`
|
||||
}
|
||||
|
||||
type DynamicTypeMgrQueryMoInstancesResponse struct {
|
||||
Returnval []DynamicTypeMgrMoInstance `xml:"urn:vim25 returnval"`
|
||||
}
|
||||
|
||||
type DynamicTypeEnumTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
WsdlName string `xml:"wsdlName"`
|
||||
Version string `xml:"version"`
|
||||
Value []string `xml:"value,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeEnumTypeInfo"] = reflect.TypeOf((*DynamicTypeEnumTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrAllTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
ManagedTypeInfo []DynamicTypeMgrManagedTypeInfo `xml:"managedTypeInfo,omitempty"`
|
||||
EnumTypeInfo []DynamicTypeEnumTypeInfo `xml:"enumTypeInfo,omitempty"`
|
||||
DataTypeInfo []DynamicTypeMgrDataTypeInfo `xml:"dataTypeInfo,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrAllTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrAllTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrAnnotation struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
Parameter []string `xml:"parameter,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrAnnotation"] = reflect.TypeOf((*DynamicTypeMgrAnnotation)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrDataTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
WsdlName string `xml:"wsdlName"`
|
||||
Version string `xml:"version"`
|
||||
Base []string `xml:"base,omitempty"`
|
||||
Property []DynamicTypeMgrPropertyTypeInfo `xml:"property,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrDataTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrDataTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (b *DynamicTypeMgrFilterSpec) GetDynamicTypeMgrFilterSpec() *DynamicTypeMgrFilterSpec { return b }
|
||||
|
||||
type BaseDynamicTypeMgrFilterSpec interface {
|
||||
GetDynamicTypeMgrFilterSpec() *DynamicTypeMgrFilterSpec
|
||||
}
|
||||
|
||||
type DynamicTypeMgrFilterSpec struct {
|
||||
DynamicData
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrFilterSpec"] = reflect.TypeOf((*DynamicTypeMgrFilterSpec)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrManagedTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
WsdlName string `xml:"wsdlName"`
|
||||
Version string `xml:"version"`
|
||||
Base []string `xml:"base,omitempty"`
|
||||
Property []DynamicTypeMgrPropertyTypeInfo `xml:"property,omitempty"`
|
||||
Method []DynamicTypeMgrMethodTypeInfo `xml:"method,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrManagedTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrManagedTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrMethodTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
WsdlName string `xml:"wsdlName"`
|
||||
Version string `xml:"version"`
|
||||
ParamTypeInfo []DynamicTypeMgrParamTypeInfo `xml:"paramTypeInfo,omitempty"`
|
||||
ReturnTypeInfo *DynamicTypeMgrParamTypeInfo `xml:"returnTypeInfo,omitempty"`
|
||||
Fault []string `xml:"fault,omitempty"`
|
||||
PrivId string `xml:"privId,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrMethodTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrMethodTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrMoFilterSpec struct {
|
||||
DynamicTypeMgrFilterSpec
|
||||
|
||||
Id string `xml:"id,omitempty"`
|
||||
TypeSubstr string `xml:"typeSubstr,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrMoFilterSpec"] = reflect.TypeOf((*DynamicTypeMgrMoFilterSpec)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrMoInstance struct {
|
||||
DynamicData
|
||||
|
||||
Id string `xml:"id"`
|
||||
MoType string `xml:"moType"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrMoInstance"] = reflect.TypeOf((*DynamicTypeMgrMoInstance)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrParamTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
Version string `xml:"version"`
|
||||
Type string `xml:"type"`
|
||||
PrivId string `xml:"privId,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrParamTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrParamTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrPropertyTypeInfo struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
Version string `xml:"version"`
|
||||
Type string `xml:"type"`
|
||||
PrivId string `xml:"privId,omitempty"`
|
||||
MsgIdFormat string `xml:"msgIdFormat,omitempty"`
|
||||
Annotation []DynamicTypeMgrAnnotation `xml:"annotation,omitempty"`
|
||||
}
|
||||
|
||||
type DynamicTypeMgrQueryTypeInfo struct {
|
||||
This ManagedObjectReference `xml:"_this"`
|
||||
FilterSpec BaseDynamicTypeMgrFilterSpec `xml:"filterSpec,omitempty,typeattr"`
|
||||
}
|
||||
|
||||
type DynamicTypeMgrQueryTypeInfoResponse struct {
|
||||
Returnval DynamicTypeMgrAllTypeInfo `xml:"urn:vim25 returnval"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrPropertyTypeInfo"] = reflect.TypeOf((*DynamicTypeMgrPropertyTypeInfo)(nil)).Elem()
|
||||
}
|
||||
|
||||
type DynamicTypeMgrTypeFilterSpec struct {
|
||||
DynamicTypeMgrFilterSpec
|
||||
|
||||
TypeSubstr string `xml:"typeSubstr,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["DynamicTypeMgrTypeFilterSpec"] = reflect.TypeOf((*DynamicTypeMgrTypeFilterSpec)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ReflectManagedMethodExecuterSoapArgument struct {
|
||||
DynamicData
|
||||
|
||||
Name string `xml:"name"`
|
||||
Val string `xml:"val"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["ReflectManagedMethodExecuterSoapArgument"] = reflect.TypeOf((*ReflectManagedMethodExecuterSoapArgument)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ReflectManagedMethodExecuterSoapFault struct {
|
||||
DynamicData
|
||||
|
||||
FaultMsg string `xml:"faultMsg"`
|
||||
FaultDetail string `xml:"faultDetail,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["ReflectManagedMethodExecuterSoapFault"] = reflect.TypeOf((*ReflectManagedMethodExecuterSoapFault)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ReflectManagedMethodExecuterSoapResult struct {
|
||||
DynamicData
|
||||
|
||||
Response string `xml:"response,omitempty"`
|
||||
Fault *ReflectManagedMethodExecuterSoapFault `xml:"fault,omitempty"`
|
||||
}
|
||||
|
||||
type RetrieveDynamicTypeManager struct {
|
||||
This ManagedObjectReference `xml:"_this"`
|
||||
}
|
||||
|
||||
type RetrieveDynamicTypeManagerResponse struct {
|
||||
Returnval *InternalDynamicTypeManager `xml:"urn:vim25 returnval"`
|
||||
}
|
||||
|
||||
type RetrieveManagedMethodExecuter struct {
|
||||
This ManagedObjectReference `xml:"_this"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
t["RetrieveManagedMethodExecuter"] = reflect.TypeOf((*RetrieveManagedMethodExecuter)(nil)).Elem()
|
||||
}
|
||||
|
||||
type RetrieveManagedMethodExecuterResponse struct {
|
||||
Returnval *ReflectManagedMethodExecuter `xml:"urn:vim25 returnval"`
|
||||
}
|
||||
|
||||
type InternalDynamicTypeManager struct {
|
||||
ManagedObjectReference
|
||||
}
|
||||
|
||||
type ReflectManagedMethodExecuter struct {
|
||||
ManagedObjectReference
|
||||
}
|
||||
|
||||
type ExecuteSoap struct {
|
||||
This ManagedObjectReference `xml:"_this"`
|
||||
Moid string `xml:"moid"`
|
||||
Version string `xml:"version"`
|
||||
Method string `xml:"method"`
|
||||
Argument []ReflectManagedMethodExecuterSoapArgument `xml:"argument,omitempty"`
|
||||
}
|
||||
|
||||
type ExecuteSoapResponse struct {
|
||||
Returnval *ReflectManagedMethodExecuterSoapResult `xml:"urn:vim25 returnval"`
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
# This source code refers to The Go Authors for copyright purposes.
|
||||
# The master list of authors is in the main Go distribution,
|
||||
# visible at http://tip.golang.org/AUTHORS.
|
|
@ -0,0 +1,3 @@
|
|||
# This source code was written by the Go contributors.
|
||||
# The master list of contributors is in the main Go distribution,
|
||||
# visible at http://tip.golang.org/CONTRIBUTORS.
|
|
@ -0,0 +1,27 @@
|
|||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue