Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vsphere-provider: Added folder handling for folder-qualified vm names #3939

Merged
merged 1 commit into from
Dec 9, 2015
Merged

vsphere-provider: Added folder handling for folder-qualified vm names #3939

merged 1 commit into from
Dec 9, 2015

Conversation

matt-deboer
Copy link
Contributor

With this update, the builtin vsphere provider will now support a new top-level resource type called vsphere_folder which can be leveraged in the form of a "folder" attribute on a vsphere_virtual_machine resource--causing the vm to be created within the specified folder path.

Example:

# Ensure a folder is present
resource "vsphere_folder" "test" {
  datacenter = "mydc"
  path       = "terraform-test-folder"
}

# Places the VM into the folder as it creates it
resource "vsphere_virtual_machine" "test" {
  datacenter = "mydc"
  name       = "myvm"
  folder     = "${vsphere_folder.test.path}"
}

An additional attribute "existing_path" is computed on the vsphere_folder resource to track any folder segments that were pre-existing upon initial folder creation--to ensure that such pre-existing folder segments are not removed when the terraform resource is destroyed.

This is fix/enhancement supports #3921.

@chrislovecnm
Copy link
Contributor

@matt-deboer looks good. Would you be able to provide an acceptance test with a new test case? Acceptance test are here: https://github.com/hashicorp/terraform/blob/master/builtin/providers/vsphere/resource_vsphere_virtual_machine_test.go

@chrislovecnm
Copy link
Contributor

@matt-deboer are you able to add acceptance testing?? Would be much better to test this code on various vsphere systems before the terraform folks approve this pull.

@matt-deboer
Copy link
Contributor Author

yeah, I've added. just preparing to ammend the PR; should be sometime today

On Thu, Nov 19, 2015 at 1:12 PM, Chris Love notifications@github.com
wrote:

@matt-deboer https://github.com/matt-deboer are you able to add
acceptance testing?? Would be much better to test this code on various
vsphere systems before the terraform folks approve this pull.


Reply to this email directly or view it on GitHub
#3939 (comment).

@matt-deboer
Copy link
Contributor Author

acceptance test is uploaded--please take a look

@chrislovecnm
Copy link
Contributor

"base_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
ForceNew: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly call out ForceNew: false here as it's the default.

@phinze
Copy link
Contributor

phinze commented Nov 20, 2015

Hi @matt-deboer - thanks so much for this! 👍

I dropped a few comments inline for you. I also have a higher level question: I am wondering if folder might make more sense as a first class resource? It looks like it has CRUD functions which would be able to map to Terraform's declarative config.

So sketching out what that might look like in Terraform:

# Ensures the folder exists
resource "vsphere_folder" "test" {
  datacenter = "mydc"
  path       = "terraform-test-folder"
}

# Places the VM into the folder as it creates it
resource "vsphere_virtual_machine" "test" {
  datacenter = "mydc"
  name       = "myvm"
  folder     = "${vsphere_folder.test.path}"
}

Not sure if this makes sense from a user perspective. I saw the CreateFolder you have to do in the tests and in similar scenarios elsewhere that has been a clue to a need for a new top level resource.

Let me know what you think!

@matt-deboer
Copy link
Contributor Author

@phinze: Thanks for the notes. Yes, I think like the new top-level resource option; it's cleaner.
Will update the PR...

@chrislovecnm
Copy link
Contributor

@tkak any comments on these changes?

@matt-deboer
Copy link
Contributor Author

@chrislovecnm @phinze : I'm hitting some interesting issues with the acceptance tests; I'm getting "A specified parameter was not correct" regarding "spec.identity.hostName" before the vm is finished being created (based on the log output); what is the trigger that tells TF to consider a resource "created"? It seems whatever that is, it may be firing too soon...

@chrislovecnm
Copy link
Contributor

can I get some debug logs?

@matt-deboer
Copy link
Contributor Author

sure: here you go:

notice that around the line containing with "new vm: {VirtualMachine", TF determines the problem with spec.identity.hostName, but this is only a partially-created machine...

  CREATE: vsphere_virtual_machine.bar
    cluster:                         "" => "MY_CLUSTER" (forces new resource)
    datacenter:                      "" => "MY_DATACENTER" (forces new resource)
    disk.#:                          "" => "1" (forces new resource)
    disk.0.datastore:                "" => "MY_DATASTORE" (forces new resource)
    disk.0.template:                 "" => "Templates/RHEL-6.6-Template" (forces new resource)
    domain:                          "" => "vsphere.local" (forces new resource)
    memory:                          "" => "4096" (forces new resource)
    name:                            "" => "tf_test_vm_dhcp" (forces new resource)
    network_interface.#:             "" => "1" (forces new resource)
    network_interface.0.ip_address:  "" => "<computed>" (forces new resource)
    network_interface.0.label:       "" => "MY_NETWORK_LABEL" (forces new resource)
    network_interface.0.subnet_mask: "" => "<computed>" (forces new resource)
    resource_pool:                   "" => "/MY_DATACENTER/host/MY_CLUSTER/Resources/MY_RESPOOL" (forces new resource)
    time_zone:                       "" => "Etc/UTC" (forces new resource)
    vcpu:                            "" => "2" (forces new resource)

  STATE:

  <no state>
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.ConfigTransformer:

  vsphere_virtual_machine.bar
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.OrphanTransformer:

  vsphere_virtual_machine.bar
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.AddOutputOrphanTransformer:

  vsphere_virtual_machine.bar
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.MissingProviderTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.ProviderTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.DisableProviderTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.MissingProvisionerTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.ProvisionerTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.VertexTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.FlattenTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.ProxyTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.RootTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.TargetsTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.PruneProviderTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.PruneProvisionerTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.DestroyTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
    vsphere_virtual_machine.bar (destroy tainted)
    vsphere_virtual_machine.bar (destroy)
  vsphere_virtual_machine.bar (destroy tainted)
    provider.vsphere
  vsphere_virtual_machine.bar (destroy)
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.CreateBeforeDestroyTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
    vsphere_virtual_machine.bar (destroy tainted)
    vsphere_virtual_machine.bar (destroy)
  vsphere_virtual_machine.bar (destroy tainted)
    provider.vsphere
  vsphere_virtual_machine.bar (destroy)
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.PruneDestroyTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.PruneNoopTransformer:

  provider.vsphere
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.CloseProviderTransformer:

  provider.vsphere
  provider.vsphere (close)
    provider.vsphere
    vsphere_virtual_machine.bar
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.CloseProvisionerTransformer:

  provider.vsphere
  provider.vsphere (close)
    provider.vsphere
    vsphere_virtual_machine.bar
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.RootTransformer:

  provider.vsphere
  provider.vsphere (close)
    provider.vsphere
    vsphere_virtual_machine.bar
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [TRACE] Graph after step *terraform.TransitiveReductionTransformer:

  provider.vsphere
  provider.vsphere (close)
    vsphere_virtual_machine.bar
  vsphere_virtual_machine.bar
    provider.vsphere
  2015/11/23 13:56:42 [DEBUG] Starting graph walk: walkApply
  2015/11/23 13:56:42 [DEBUG] vertex root.provider.vsphere: walking
  2015/11/23 13:56:42 [DEBUG] vertex root.provider.vsphere: evaluating
  2015/11/23 13:56:42 [INFO] Entering eval tree: provider.vsphere
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalInitProvider
  2015/11/23 13:56:42 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:42 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalOpFilter
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalGetProvider
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalInterpolate
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalBuildProviderConfig
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalSetProviderConfig
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalOpFilter
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:42 [DEBUG] root: eval: *terraform.EvalConfigProvider
  2015/11/23 13:56:44 [INFO] VMWare vSphere Client configured for URL: https://username:password@myesxhost/sdk
  2015/11/23 13:56:44 [INFO] Exiting eval tree: provider.vsphere
  2015/11/23 13:56:44 [DEBUG] vertex vsphere_virtual_machine.bar, got dep: provider.vsphere
  2015/11/23 13:56:44 [DEBUG] vertex root.vsphere_virtual_machine.bar: walking
  2015/11/23 13:56:44 [DEBUG] vertex root.vsphere_virtual_machine.bar: evaluating
  2015/11/23 13:56:44 [INFO] Entering eval tree: vsphere_virtual_machine.bar
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalInterpolate
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalCountFixZeroOneBoundary
  2015/11/23 13:56:44 [INFO] Exiting eval tree: vsphere_virtual_machine.bar
  2015/11/23 13:56:44 [DEBUG] vertex root.vsphere_virtual_machine.bar: expanding/walking dynamic subgraph
  2015/11/23 13:56:44 [TRACE] Graph after step *terraform.ResourceCountTransformer:

  vsphere_virtual_machine.bar
  2015/11/23 13:56:44 [TRACE] Graph after step *terraform.RootTransformer:

  vsphere_virtual_machine.bar
  2015/11/23 13:56:44 [DEBUG] vertex root.vsphere_virtual_machine.bar: walking
  2015/11/23 13:56:44 [DEBUG] vertex root.vsphere_virtual_machine.bar: evaluating
  2015/11/23 13:56:44 [INFO] Entering eval tree: vsphere_virtual_machine.bar
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalInstanceInfo
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalOpFilter
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalSequence
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalReadDiff
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalIf
  2015/11/23 13:56:44 [DEBUG] root: eval: terraform.EvalNoop
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalIf
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalInterpolate
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalGetProvider
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalReadState
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalDiff
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalReadDiff
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalCompareDiff
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalGetProvider
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalReadState
  2015/11/23 13:56:44 [DEBUG] root: eval: *terraform.EvalApply
  2015/11/23 13:56:44 [DEBUG] apply: vsphere_virtual_machine.bar: executing Apply
  2015/11/23 13:56:44 [DEBUG] network_interface init: [{ MY_NETWORK_LABEL   }]
  2015/11/23 13:56:44 [DEBUG] disk init: [{0 0}]
  2015/11/23 13:56:44 [DEBUG] template: &object.VirtualMachine{Common:object.Common{c:(*vim25.Client)(0xc208342000), r:types.ManagedObjectReference{Type:"VirtualMachine", Value:"vm-1073"}}, InventoryPath:"/MY_DATACENTER/vm/Templates/RHEL-6.6-Template"}
  2015/11/23 13:56:44 [DEBUG] resource pool: &object.ResourcePool{Common:object.Common{c:(*vim25.Client)(0xc208342000), r:types.ManagedObjectReference{Type:"ResourcePool", Value:"resgroup-910"}}, InventoryPath:"/MY_DATACENTER/host/MY_CLUSTER/Resources/MY_RESPOOL"}
  2015/11/23 13:56:44 [DEBUG] folder: ""
  2015/11/23 13:56:44 [DEBUG] datastore: &object.Datastore{Common:object.Common{c:(*vim25.Client)(0xc208342000), r:types.ManagedObjectReference{Type:"Datastore", Value:"datastore-85"}}, InventoryPath:"/MY_DATACENTER/datastore/MY_DATASTORE"}
  2015/11/23 13:56:44 [DEBUG] relocate spec: {{} <nil> <nil> 0xc208662ea0  0xc208662e80 <nil> [{{} 2000 {Datastore datastore-85}  0xc208282270 []}]  [] []}
  2015/11/23 13:56:44 [DEBUG] network configs: {{} 0x16cdde8  [] <nil> []    }
  2015/11/23 13:56:44 [DEBUG] virtual machine config spec: {{}      [] []  0 0 <nil> <nil>      <nil> <nil> <nil> <nil> <nil> 2 1 4096 <nil> <nil> <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> <nil> <nil> [] []  <nil> <nil> <nil> <nil> <nil> <nil> <nil>  0 <nil> <nil> <nil> <nil> <nil> <nil> [] <nil>}
  2015/11/23 13:56:44 [DEBUG] custom spec: {{} <nil> 0xc2086b9080 {{} [vsphere.local] [8.8.8.8 8.8.4.4]} [{{}  {{} 0x16cdde8  [] <nil> []    }}] []}
  2015/11/23 13:56:44 [DEBUG] clone spec: {{} {{} <nil> <nil> 0xc208662ea0  0xc208662e80 <nil> [{{} 2000 {Datastore datastore-85}  0xc208282270 []}]  [] []} false 0xc208331b80 <nil> false <nil> <nil>}
  2015/11/23 13:56:47 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:56:52 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:56:57 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:02 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:07 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:12 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:17 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:22 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:27 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:32 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:37 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:42 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:47 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:52 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:57:57 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:02 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:07 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:12 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:17 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:22 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:27 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:32 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:37 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:42 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:47 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:52 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:58:57 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:02 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:07 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:12 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:17 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:22 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:27 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:32 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:37 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:42 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:47 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:52 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 13:59:57 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:02 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:07 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:12 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:17 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:22 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:27 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:32 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:37 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:42 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:47 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:52 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:00:57 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:01:02 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:01:07 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:01:12 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:01:17 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.bar
  2015/11/23 14:01:20 [DEBUG] new vm: {VirtualMachine vm-1934} @ /MY_DATACENTER/vm/tf_test_vm_dhcp
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalWriteState
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalIf
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalWriteDiff
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalIf
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalWriteState
  2015/11/23 14:01:21 [DEBUG] root: eval: *terraform.EvalApplyPost
  2015/11/23 14:01:21 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

  * vsphere_virtual_machine.bar: A specified parameter was not correct. 
  spec.identity.hostName
  2015/11/23 14:01:21 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

  * vsphere_virtual_machine.bar: A specified parameter was not correct. 
  spec.identity.hostName
  2015/11/23 14:01:21 [ERROR] root: eval: *terraform.EvalOpFilter, err: 1 error(s) occurred:

  * vsphere_virtual_machine.bar: A specified parameter was not correct. 
  spec.identity.hostName
  2015/11/23 14:01:21 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

  * vsphere_virtual_machine.bar: A specified parameter was not correct. 
  spec.identity.hostName
  2015/11/23 14:01:21 [INFO] Exiting eval tree: vsphere_virtual_machine.bar

@matt-deboer
Copy link
Contributor Author

user error : ) I had named some test vms with "_" in the name (invalid for hostname).
now, back to the actual issue...

@chrislovecnm
Copy link
Contributor

@matt-deboer 😀 we have all done that before. Appreciate your work on this!!!!

@matt-deboer
Copy link
Contributor Author

I think this is in a stable state now for review;

  • applied the suggestions from @phinze, including creation of a separate "vsphere_folder" top level resource
  • updated the docs

Please take a look when you can.

@chrislovecnm
Copy link
Contributor

@matt-deboer 👍 thanks

Type: schema.TypeString,
Optional: true,
Computed: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is existing_path meant to be user settable? If not you should omit Optional so it's treated as read-only.

@matt-deboer
Copy link
Contributor Author

@phinze thanks for the tip; removed the 'optional', and rebased with upstream

context.TODO(), fmt.Sprintf("%v/vm/%v", d.Get("datacenter").(string),
d.Get("path").(string)))

if err != nil || folder == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to scope this error check down to a "NotFound" error and return the error in other cases?

If we treat any error here as though the resource was deleted, running a terraform plan with e.g. internet disconnected could result in state losing track of all its folders instead of the error message you'd expect in that case.

@phinze
Copy link
Contributor

phinze commented Dec 4, 2015

Okay nearly there! One more comment for you and after we address that I think this thing is ready to go! 🚀

Added acceptance test for creation in folders

Added 'baseName' as computed schema attribute for convenience

Added 'base_name' computed attribute for convenience

Added new vsphere folder resource

Fixed folder behavior

Assure test folders are properly removed

Avoid creating recreating search index in loop

Fix typeo in vsphere.createFolder

Updated website documentation

Renamed test folders to be unique across tests

Fixes based on acc test findings; code cleanup

Added combined folder and vm acc test

Restored newline; fixed skipped acc tests

Marked 'existing_path' as computed only

Removed debug logging from tests

Changed folder read to return error
@matt-deboer
Copy link
Contributor Author

@phinze Okay; updated now. It turns out that a normal failed lookup simply returns nil object and nil error, so I think we're safe to return any non-nil error.

@phinze
Copy link
Contributor

phinze commented Dec 9, 2015

Nice!

Great work on this, @matt-deboer 👍

phinze added a commit that referenced this pull request Dec 9, 2015
vsphere-provider: Added folder handling for folder-qualified vm names
@phinze phinze merged commit e065bec into hashicorp:master Dec 9, 2015
@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants