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

Enhancement: Added resource for license management #110

Merged
merged 29 commits into from
Aug 17, 2017

Conversation

girishramnani
Copy link

Please review the implementation of license resource.

The following capabilities are provided by this resource -

  1. Adding license ( with optional labels )
  2. Removing license
  3. Updating labels attached to a license

Terraform version - v0.9.11
Vsphere version used for acceptance tests - Version 5.5.0 Build 4063694

@girishramnani girishramnani changed the title Enhancement: Added resource for license Enhancement: Added resource for license management Jul 25, 2017
@grubernaut grubernaut added enhancement Type: Enhancement new-resource Feature: New Resource labels Jul 25, 2017
@vancluever vancluever self-assigned this Aug 1, 2017
@vancluever
Copy link
Contributor

vancluever commented Aug 1, 2017

Hi @girishramnani! Thank you very much for submitting this PR - it's going to be very useful!

I have been testing this against a standalone ESXi server and there seems to be some issues. I think this stems from the fact that the host API differs somewhat from the vCenter API. There are a couple of formatting issues as well that I hope could be looked at, just to make the tests look a bit better.

I will start a review (expect it in a few hours) and put the relevant information in, but just FYI a good reference to check what needs to happen to support both standalone host and vCenter when working with licenses can be found in the govc license.add call.

If you have any questions or need any help feel free to ask! Looking forward to getting this one merged!

@vancluever
Copy link
Contributor

Hey @girishramnani - just wanted to let you know the review is still pending - sorry for the delay! In the meantime can you check out what I mentioned regarding handling the API that this points against (host vs vCenter) and make the needed changes?

PS: This is the line that needs fixing in Create: https://github.com/terraform-providers/terraform-provider-vsphere/pull/110/files/fb2068625fe0a3c63647156cb53e68e3d28ca7cd#diff-6da7e5115133f8bf52016c3cc74c771cR98

@girishramnani
Copy link
Author

Done, so now based on the api type different method to add license will be used.

Copy link
Contributor

@vancluever vancluever left a comment

Choose a reason for hiding this comment

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

Hey @girishramnani! Thanks for the update. I have the rest of the review ready now. Can you look at the points and update/comment accordingly?

I was also wondering if the config generation functions in the tests could be modified as well? I think it might help with readability a lot if the configs were laid out a bit more explicitly and less functionally - maybe something like this:

func testAccVSphereLicenseConfig() {
  return fmt.Sprintf(`
resource "vsphere_license" "foo" {
  license_key = "%s"
}
`, os.Getenv("VSPHERE_LICENSE"))
}

func testAccVSphereLicenseConfig() {
  return fmt.Sprintf(
`resource "vsphere_license" "foo" {
  license_key = "%s"

  label {
    key   = "VpxClientLicenseLabel"
    value = "Hello World"
  }

  label {
    key   = "TestTitle"
    value = "FooBar"
  }
}
`, os.Getenv("VSPHERE_LICENSE"))
}

(Note that the labels will probably change once the label attribute is updated)

Also, I noticed there was a lot of leading spaces in some of the functions in resource_vsphere_license.go, ie: on the first line - example here and here. Maybe it would be a good idea to just go over the code for some possible style artifacts and clean them up?

return err
}
}
info, err := manager.Add(context.TODO(), key, finalLabels)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @girishramnani, this is where both APIs need to be handled. They may need to be handled in other places as well (depending on how the host API handles labeling). Again, govc's license.add call is a good place to look.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS: When updating this you may need to switch the context package you are using to the standard library's version, (ie: import "context" versus import "golang.org/x/net/context") as that is what govmomi uses.

t.Fatal("Error ", err)
}

if value, ok := labelMap["Hello"]; !ok || value != "World" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a small nitpick here - you test data (labelStub) contains keys that are not being iterated on in your test - maybe it's possible to trim that and move that fixture to the function too if it's not being consumed by anything else?

Copy link
Author

Choose a reason for hiding this comment

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

I think it would be better to add a check for the keys that are not being tested here.

Copy link
Contributor

Choose a reason for hiding this comment

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

So you are saying test the entire set? I think that makes sense too - just as long as the fixture as a whole ultimately has use. 🙂

manager := license.NewManager(client.Client)

// the key was never present. Should set the ID to false.
if _, ok := d.GetOk("license_key"); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering in what scenario might license_key not be present, especially if it is a Required and ForceNew field? Given these this could probably be omitted, handing this logic off to TF core.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, makes sense. Removing this part.

"key": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was ForceNew intended here? It doesn't seem that updating a label would require the entire key to be re-added?

Copy link
Author

@girishramnani girishramnani Aug 2, 2017

Choose a reason for hiding this comment

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

Wouldn't ForceNew here mean that if keyof this label changes then that should create a new label instead of updating it?

d.Set("total", info.Total)
d.Set("used", info.Used)
d.Set("name", info.Name)

Copy link
Contributor

Choose a reason for hiding this comment

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

I notice that labels are not updated here - would it be a good idea to do so so that any drift caught on the labels can be reconciled?

Copy link
Author

Choose a reason for hiding this comment

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

If i update the labels here, then the state provided by terraform files and terraform state stored will drift apart, for example if server has labels x:y and local state shows it as x:yy then the server state has to be changed not the other way around. That's why only computed properties are set as they are the one which the user is not responsible for.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually the intended behaviour of Terraform - it should detect this kind of drift (ie: if a user manually adds a label) and bring it back to the correctly configured state. It encourages management to be done out of configuration, treating it as the source of truth.

When someone wants to ignore drift, the correct thing to do in a Terraform configuration is to add ignore_changes for the attributes they want to ignore:

resource "vsphere_license" "license" {
  ...

  lifecycle {
    ignore_changes = ["label"]
  }
}

Copy link
Author

Choose a reason for hiding this comment

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

But then in the next apply terraform will detect a difference in the local
state and the state specified by the terraform files which will trigger an
update. Due to this labels added by the user manually would be removed. Am
I correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @girishramnani, that is correct, but as mentioned above, this is intended Terrafrom behaviour - resources should always be set up so that they reconcile state with config, even if resources were intentionally modified by a user outside of Terraform. ignore_changes is explicitly used to disregard such changes when that's intentional.

The following arguments are supported:

* `license_key` - (Required) The key of the license which is needed to be added to vpshere
* `label` - (Optional) The key value pair of labels that has to be attached to the license key. One key can have multiple labels.
Copy link
Contributor

@vancluever vancluever Aug 2, 2017

Choose a reason for hiding this comment

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

I think this could probably do with more detail. Something like:

  • label - (Optional) A set of labels to apply to the license key. May be specified multiple times to supply multiple label keys.

The values for label are:

  • key - (Required) The key for the label.
  • values - (Required) A list of string values to assign to the label key.

The latter note on values also takes into consideration my notes on the labels attribute in the schema itself - so check there for more details.

Copy link
Author

Choose a reason for hiding this comment

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

values is not a list of string, value is a string. Does the api support multiple values for a single key?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think my confusion was in this part:

One key can have multiple labels

I did double check as well, and a label can't have multiple values - sorry about that! So I think what you are saying here is that a in particular license can have multiple labels, right? I think in that case, it might be a good idea to just drop this sentence altogether, considering the double meaning of key (license key and label key) may cause confusion.

Copy link
Author

Choose a reason for hiding this comment

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

instead of key, I can write license_key can have multiple labels


## Attributes Reference

The following attributes are exported:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this section be cleaned up a bit too? Something like:

  • edition_key - The product edition of the license key.
  • total - Total number of units (example: vCPUs) contained in the license.
  • used - The number of units (example: vCPUs) assigned to this license.
  • name - The display name for the license.

"github.com/vmware/govmomi/license"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
"golang.org/x/net/context"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be changed to the standard library context? So just context, versus golang.org/x/net/context.

ForceNew: true,
},
"value": &schema.Schema{
Type: schema.TypeString,
Copy link
Contributor

Choose a reason for hiding this comment

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

Noticed that you mention that labels can be have multiple values - can this be switched to a TypeSet so that all values can be specified in a single resource?

Copy link
Author

Choose a reason for hiding this comment

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

I don't think one label can have multiple values. Where have I mentioned that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused about this - sorry again! I put some notes in the documentation comment relevant to this.

ForceNew: true,
},
"label": &schema.Schema{
Type: schema.TypeList,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a TypeSet so that conflicting entries can't be added.

Also, you will need a hashing function as well when converting it to a set - the stock HashResource function should help too.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS: In light of the misunderstanding over label data - this could possibly be moved to a TypeMap to make things easier as well, seeing as no complex resource stuff needs to happen on this being that it's just a set of key/value pairs.

Copy link
Author

Choose a reason for hiding this comment

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

Could you please clarify which approach is going to be used here, TypeMap or TypeSet

@girishramnani
Copy link
Author

@vancluever thank you for such a quick and thorough review. I have done the changes according to the comments could you please review them.

* `license_key` - (Required) The key of the license which is needed to be added to vpshere
* `label` - (Optional) The key value pair of labels that has to be attached to the license key. One key can have multiple labels.
* `license_key` - (Required) The license key to add.
* `labels` - (Optional) The key value pair of labels that has to be attached to the license key.
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking good here! Thank you for the fix!

Just a couple of remaining nitpicks on the labels line:

  • Can we indicate that it's a map now?
  • Can we say key/value instead of key value?
  • It says has to be attached, but it's optional.

Something like:

labels - (Optional) A map of key/value pairs to be attached as labels (tags) to the license key.

}`
}

func testAccVSphereLicenseWithLabelConfig(labels map[string]string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

We are getting close here - remember though that we don't necessarily need to render the labels here dynamically - it's better to just use a static string, and roll the function into a much more simpler form:

func testAccVSphereLicenseWithLabelConfig() string {
  return fmt.Sprintf(`
resource "vsphere_license" "foo" {
  license_key = "%s"

  labels {
    VpxClientLicenseLabel = "Hello World"
    TestTitle = "FooBar"
  }  
}
`, os.Getenv("VSPHERE_LICENSE"))
}

return val
}

func testAccVSphereLicenseBasicConfig() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

As per the label generator here, remember we should style this function the same way:

func testAccVSphereLicenseWithLabelConfig() string {
  return fmt.Sprintf(`
resource "vsphere_license" "foo" {
  license_key = "%s"
}
`, os.Getenv("VSPHERE_LICENSE"))
}

@vancluever
Copy link
Contributor

Hey @girishramnani thanks for the updates! Added some comments inline for the docs and tests stuff that still needs to be adjusted.

The following items are still outstanding:

  • Ensure labels are being saved to state on Read calls
  • Fix spurious whitespace at the start of functions - there are still several places that have them - it would be useful to go over the whole set of changes and address this. One was also added in 8f6e127. I think maybe there's a misunderstanding that these lines should be removed, not added.
  • Just had a couple of nitpicks about language on the labels attribute and then that's good to go.
  • We are making progress on the tests but I still would like to see the config generation functions cleaned up a bit.

After this work, this also needs to be fully tested against an ESXi host. From what I read in the LicenseManager object, tags are ignored by AddLicense on ESXi, which might be causing the errors I was seeing in these tests on ESXi (the test returned tag not found after a successful call to add the license).

Thank you for your patience and continued work on this!

@girishramnani
Copy link
Author

@vancluever thanks once again for the review, I have changed the code according to the comments, could you please review it.

@vancluever
Copy link
Contributor

Hey @girishramnani - making more progress!

Here are the current test results:

vCenter

=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (3.32s)
=== RUN   TestAccVSphereLicenseInvalid
--- PASS: TestAccVSphereLicenseInvalid (0.99s)
=== RUN   TestAccVSphereLicenseWithLabels
--- FAIL: TestAccVSphereLicenseWithLabels (0.00s)
	testing.go:428: Step 0 error: Error loading configuration: Error parsing /tmp/tf-test756435681/main.tf: At 6:21: Unknown token: 6:21 IDENT FooBar

Standalone ESXi

This first round of tests was with a license that I don't think is valid for ESXi at all (vSAN). I think better error trapping needs to happen to ensure that invalid license types for a node (not just invalid keys) are caught.

=== RUN   TestAccVSphereLicenseBasic
--- FAIL: TestAccVSphereLicenseBasic (1.35s)
	testing.go:428: Step 0 error: Error applying: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: The key was not found
	testing.go:492: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.
		
		Error: Error refreshing: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: vsphere_license.foo: The key was not found
		
		State: <nil>
=== RUN   TestAccVSphereLicenseInvalid
--- FAIL: TestAccVSphereLicenseInvalid (1.31s)
	testing.go:422: Step 0, expected error:
		
		Error applying: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: The key was not found
		
		To match:
		
		License file not found
		
		
	testing.go:492: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.
		
		Error: Error refreshing: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: vsphere_license.foo: The key was not found
		
		State: <nil>
=== RUN   TestAccVSphereLicenseWithLabels
--- FAIL: TestAccVSphereLicenseWithLabels (0.00s)
	testing.go:428: Step 0 error: Error loading configuration: Error parsing /tmp/tf-test872458016/main.tf: At 6:21: Unknown token: 6:21 IDENT FooBar

This second test was with an Enterprise Plus key. This one succeeds minus the issues with labels and the broken config that is causing issues with all of the tests (see below).

=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (3.28s)
=== RUN   TestAccVSphereLicenseInvalid
--- FAIL: TestAccVSphereLicenseInvalid (1.32s)
	testing.go:422: Step 0, expected error:
		
		Error applying: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: The key was not found
		
		To match:
		
		License file not found
		
		
	testing.go:492: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.
		
		Error: Error refreshing: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: vsphere_license.foo: The key was not found
		
		State: <nil>
=== RUN   TestAccVSphereLicenseWithLabels
--- FAIL: TestAccVSphereLicenseWithLabels (0.00s)
	testing.go:428: Step 0 error: Error loading configuration: Error parsing /tmp/tf-test762915504/main.tf: At 6:21: Unknown token: 6:21 IDENT FooBar

So looks like the config needs to be fixed on the label test, and also the outstanding label tests need to be corrected against the ESXi hosts (might be an idea to kick back an error if a user is trying to define labels on an ESXi server versus vCenter, to prevent confusion).

Also, the formatting needs to be changed on your config generation functions still (again, change them to a simple form where the raw string is not indented and you are using os.Getenv directly in the fmt.Sprintf call).

Thank you for the continued attention on this one!

}

func testAccVSphereLicenseDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*govmomi.Client)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @girishramnani, while not necessarily a panic that affects users, this panics when there is an error setting up the client (ie: if one forgets to skip SSL verification). Can you add something to trap nil in this situation and return an error?

Copy link
Author

Choose a reason for hiding this comment

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

@vancluever So should I change it in all the places? Like other tests and methods.

@girishramnani
Copy link
Author

girishramnani commented Aug 8, 2017

Hello @vancluever, I have solved the invalid config. A small doubt, could you please help me understand why TestAccVSphereLicenseInvalid test is failing in cases of VSAN key and enterprise key? This test doesn't even depend on the license key.

Also could you please provide me the govc response debug xml files when you used the VSAN key so that I can add that in the error check (i.e. DecodeError method).

@vancluever
Copy link
Contributor

Hey @girishramnani, I think the issues with both the invalid license tests and the issues with adding the VSAN key might be due to the differences between the vCenter and host APIs. I tried a completely invalid key and got the same kind of error. Just using govc license.add -dump ABCDE-11111-11111-11111-11111:

vCenter

The error that the code currently looks for is displayed here correctly.

(license.licenseOutput) (len=1 cap=1) {
    (types.LicenseManagerLicenseInfo) {
        DynamicData: (types.DynamicData) {
        },
        LicenseKey: (string) "",
        EditionKey: (string) "",
        Name: (string) "",
        Total: (int32) 0,
        Used: (int32) 0,
        CostUnit: (string) "",
        Properties: ([]types.KeyAnyValue) (len=4 cap=4) {
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=8) "lc_error",
                Value: (int32) 5
            },
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=19) "localizedDiagnostic",
                Value: (types.LocalizableMessage) {
                    DynamicData: (types.DynamicData) {
                    },
                    Key: (string) (len=38) "com.vmware.vim.vc.license.error.decode",
                    Arg: ([]types.KeyAnyValue) (len=1 cap=4) {
                        (types.KeyAnyValue) {
                            DynamicData: (types.DynamicData) {
                            },
                            Key: (string) (len=10) "diagnostic",
                            Value: (string) (len=19) "licenseFileNotFound"
                        }
                    },
                    Message: (string) (len=22) "License file not found"
                }
            },
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=10) "diagnostic",
                Value: (string) (len=37) "License is not valid for this product"
            },
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=9) "Localized",
                Value: (types.ArrayOfKeyAnyValue) {
                    KeyAnyValue: ([]types.KeyAnyValue) <nil>
                }
            }
        },
        Labels: ([]types.KeyValue) <nil>
    }
}

ESXi

Here, the error isn't, so the code is assuming that the add is successful. This is the same dump profile I get when trying to add the VSAN key.

(license.licenseOutput) (len=1 cap=1) {
    (types.LicenseManagerLicenseInfo) {
        DynamicData: (types.DynamicData) {
        },
        LicenseKey: (string) (len=29) "ABCDE-11111-11111-11111-11111",
        EditionKey: (string) "",
        Name: (string) "",
        Total: (int32) 0,
        Used: (int32) 0,
        CostUnit: (string) "",
        Properties: ([]types.KeyAnyValue) (len=46 cap=64) {
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=10) "diagnostic",
                Value: (string) (len=37) "License is not valid for this product"
            },
            (types.KeyAnyValue) {
                DynamicData: (types.DynamicData) {
                },
                Key: (string) (len=11) "ProductName",
                Value: (string) (len=17) "VMware ESX Server"
            },
        ...
    }
}

It looks like both errors have the common "License is not valid for this product" un-localized diagnostic KeyAnyValue - maybe we should filter off of that instead? If we do that, I think there's a good chance all of these tests will pass.

PS: Looks like the raw strings for the config generation functions still need to be fixed. Remember that it needs to be un-indented. Example: this config should be generated more like:

func testAccVSphereLicenseWithLabelConfig() string {
  return fmt.Sprintf(`
resource "vsphere_license" "foo" {
  license_key = "%s"
  labels {
    VpxClientLicenseLabel = "Hello World"
    TestTitle = "FooBar"
  }		 	
}
`, os.Getenv("VSPHERE_LICENSE"))
}

PPS: Also, can you rebase this PR off of master and re-vendor the license packages of gvmomi off of v0.15.0? Both of these things have changed since this PR was submitted.

@girishramnani
Copy link
Author

Hello @vancluever , I have added error and Error checks for ESXi server, removed indentation and checked for invalid license instead of decode.error. Could you please review it.

The following attributes are exported:

* `edition_key` - The product edition of the license key.
* `total` - Total number of units (example: vCPUs) contained in the license.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I missed this before @girishramnani but this needs to be changed to CPUs as well - I don't think I've seen a license have vCPUs at all.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, changing.

@girishramnani
Copy link
Author

Hello @vancluever , changed the docs are per the request.

@vancluever
Copy link
Contributor

Hey @girishramnani, getting close now. Tests all pass on ESXi, but now on vCenter we get:

=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (2.10s)
=== RUN   TestAccVSphereLicenseInvalid
--- PASS: TestAccVSphereLicenseInvalid (0.54s)
=== RUN   TestAccVSphereLicenseWithLabels
--- FAIL: TestAccVSphereLicenseWithLabels (0.61s)
	testing.go:422: Step 0, expected error:

		Error applying: 1 error(s) occurred:

		* vsphere_license.foo: 1 error(s) occurred:

		* vsphere_license.foo: No description for lc_error code

		To match:

		Labels are not allowed in ESXi


FAIL
exit status 1

I think this is the source of the issue - can we split the tests up into vSphere and ESXi-specific tests? Maybe let's add the VSPHERE_TEST_ESXI environment variable to indicate if we are testing against ESXi or not and skip a tests based on the results.

The last item would be the test code - the raw strings are still indented - sorry if this is not 100% clear but I need it laid out in a fashion similar to this. If there's maybe something keeping you from doing this (ie: IDE issues), we can just merge this and make the change after the fact. Let me know!

@girishramnani
Copy link
Author

girishramnani commented Aug 11, 2017

Hello @vancluever , Sorry about the space issue. I have split the test in VCenter and ESXi specific part and also removed the extra space. Thank you for your patience on this PR.

@vancluever
Copy link
Contributor

Hey @girishramnani - getting closer!

Test results:

vCenter

=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (3.37s)
=== RUN   TestAccVSphereLicenseInvalid
--- PASS: TestAccVSphereLicenseInvalid (0.89s)
=== RUN   TestAccVSphereLicenseWithLabelsOnVCenter
--- FAIL: TestAccVSphereLicenseWithLabelsOnVCenter (0.91s)
	testing.go:428: Step 0 error: Error applying: 1 error(s) occurred:
		
		* vsphere_license.foo: 1 error(s) occurred:
		
		* vsphere_license.foo: No description for lc_error code
=== RUN   TestAccVSphereLicenseWithLabelsOnESXiServer
--- SKIP: TestAccVSphereLicenseWithLabelsOnESXiServer (0.00s)
	resource_vsphere_license_test.go:109: VSPHERE_TEST_ESXI must be set to true for this acceptance test

ESXi

=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (3.31s)
=== RUN   TestAccVSphereLicenseInvalid
--- PASS: TestAccVSphereLicenseInvalid (0.79s)
=== RUN   TestAccVSphereLicenseWithLabelsOnVCenter
--- SKIP: TestAccVSphereLicenseWithLabelsOnVCenter (0.00s)
	resource_vsphere_license_test.go:103: VSPHERE_TEST_ESXI must not be set for this acceptance test
=== RUN   TestAccVSphereLicenseWithLabelsOnESXiServer
--- PASS: TestAccVSphereLicenseWithLabelsOnESXiServer (0.71s)

Can you review what might be going on with TestAccVSphereLicenseWithLabelsOnVCenter and fix accordingly?

Also - still need to fix one config generator (it could actually be moved to a constant). I will comment it.

Thanks!


func testAccVSphereLicenseInvalidConfig() string {
// quite sure this key cannot be valid
return `resource "vsphere_license" "foo" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @girishramnani, looks like this one is still indented - might be worthwhile to just move this to a constant too as nothing in it is being generated.

@girishramnani
Copy link
Author

Hello @vancluever, I cannot reproduce the lc_error on VCenter could you please share the verbose logs.

@girishramnani
Copy link
Author

Hello @vancluever, this is the output of my tests


TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run License -timeout 120m
?       bitbucket.org/girishramnani/terraform_vsphere    [no test files]
=== RUN   TestAccVSphereLicenseBasic
--- PASS: TestAccVSphereLicenseBasic (1.47s)
=== RUN   TestAccVSphereLicenseInvalid
--- PASS: TestAccVSphereLicenseInvalid (0.16s)
=== RUN   TestAccVSphereLicenseWithLabelsOnVCenter
--- PASS: TestAccVSphereLicenseWithLabelsOnVCenter (0.78s)
=== RUN   TestAccVSphereLicenseWithLabelsOnESXiServer
--- SKIP: TestAccVSphereLicenseWithLabelsOnESXiServer (0.00s)
        resource_vsphere_license_test.go:115: VSPHERE_TEST_ESXI must be set to true for this acceptance test
PASS
ok      bitbucket.org/girishramnani/terraform_vsphere/vsphere    2.455s

Vsphere version used for acceptance tests - Version 5.5.0 Build 4063694. I am not able to reproduce the error, could you please provide me the govc debug logs.

@vancluever
Copy link
Contributor

Hey @girishramnani - interesting! I am testing against vSphere 6.5 U1, so there definitely is a version discrepancy there that we may need to investigate. I will make a note to get the info you need tomorrow morning!

@vancluever
Copy link
Contributor

Hey @girishramnani, here's an XML of one the request's output:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <AddLicenseResponse xmlns="urn:vim25">
      <returnval>
        <licenseKey/>
        <editionKey/>
        <name/>
        <total>0</total>
        <costUnit/>
        <properties>
          <key>lc_error</key>
          <value xsi:type="xsd:int">-1</value>
        </properties>
        <properties>
          <key>localizedDiagnostic</key>
          <value xsi:type="LocalizableMessage">
            <key>com.vmware.vim.vc.license.error.decode</key>
            <arg>
              <key>diagnostic</key>
              <value xsi:type="xsd:string">unknownError</value>
            </arg>
            <message>Unknown license decode error</message>
          </value>
        </properties>
        <properties>
          <key>diagnostic</key>
          <value xsi:type="xsd:string">No description for lc_error code</value>
        </properties>
        <properties>
          <key>Localized</key>
          <value xsi:type="ArrayOfKeyAnyValue"/>
        </properties>
      </returnval>
    </AddLicenseResponse>
  </soapenv:Body>
</soapenv:Envelope>

This is happening on creation. I kind of wonder if we need to work around this by doing an initial create without the labels and then update it afterwards. Source. Will check and then update the issue.

@vancluever
Copy link
Contributor

Hey @girishramnani, looks like this was indeed the issue.

Here is a very non-optimal sketch of my updated workflow:

		info, err = manager.Add(context.TODO(), key, nil)
		if err != nil {
			return err
		}
		if err = DecodeError(info); err != nil {
			return err
		}
		d.SetId(info.LicenseKey)
		return resourceVSphereLicenseUpdate(d, meta)

After this, the test passes:

=== RUN   TestAccVSphereLicenseWithLabelsOnVCenter
--- PASS: TestAccVSphereLicenseWithLabelsOnVCenter (4.32s)

I think there is some re-factoring that could be done too. I will add annotations.

return errors.New("Labels are not allowed in ESXi")
}

info, err = manager.Update(context.TODO(), key, finalLabels)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since labels can't be used on ESXi period, it might be good to just remove finalLabels here and just use nil.


info, err = manager.Update(context.TODO(), key, finalLabels)
case "VirtualCenter":
info, err = manager.Add(context.TODO(), key, finalLabels)
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in the PR main comments, this needs to be re-factored into a two-step process - one where the license is added, and another where the labels are added afterwards. I think what you could probably do is break off part of the logic in Update into its own function, and then call out to it here. There is possibly some other re-factoring that could be done here too, considering the possible divergence of workflows.

return ErrNoSuchKeyFound
}

if d.HasChange("labels") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, this is the logic that should probably be spun off into its own function so it can be used in Create as well to add the labels as a separate step after the initial addition of the license is performed.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@girishramnani
Copy link
Author

Hello @vancluever, I have updated the code according to your comments could you please review it.

@girishramnani
Copy link
Author

girishramnani commented Aug 17, 2017

Hello @vancluever, the above commit a small fix which adds an error check statement for add license.

@girishramnani
Copy link
Author

Rebasing

@girishramnani
Copy link
Author

Hello @vancluever, thank you for merging master. Not rebasing.

@vancluever
Copy link
Contributor

@girishramnani - of course - it's important to us that work gets preserved! I needed to fix the conflicts on the website doc index and wanted to make sure I didn't have to force push.

This now LGTM! I am merging this shortly - but thank you very much for your patience on this one and your response to my feedback! I will be releasing a new version of the provider next week which will have your work in it 👍

Thanks again!

@vancluever vancluever merged commit fdb42c2 into hashicorp:master Aug 17, 2017
krzkowalczyk pushed a commit to krzkowalczyk/terraform-provider-vsphere that referenced this pull request Sep 8, 2017
commit e379e3a
Author: tf-release-bot <[email protected]>
Date:   Thu Sep 7 21:24:20 2017 +0000

    Cleanup after v0.2.2 release

commit b9f1e51
Author: tf-release-bot <[email protected]>
Date:   Thu Sep 7 21:20:50 2017 +0000

    v0.2.2

commit e243088
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:58:17 2017 -0700

    Update CHANGELOG.md

commit 7fb877e
Merge: 213762d 629376a
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:55:04 2017 -0700

    Merge pull request hashicorp#149 from terraform-providers/f-nas-datastore-resource

    New resource: vsphere_nas_datastore

commit 629376a
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:51:53 2017 -0700

    r/nas_datastore - Fix broken TF HCL

    host_system_ids needs to be supplied as a list.

commit 71c9329
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:50:24 2017 -0700

    r/nas_datastore: Wrap import section of docs properly

commit f3066d3
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:48:16 2017 -0700

    esxi2 -> esxi3 in VSPHERE_ESXI_HOST3 in devrc

commit 76b0e59
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:47:14 2017 -0700

    r/nas_datastore: Remove comment that should not be there

    Was just a misplaced start to the comment a few lines down.

commit f134f67
Author: Chris Marchesi <[email protected]>
Date:   Mon Sep 4 20:29:59 2017 -0700

    New resource: vsphere_nas_datastore

    This commit introduces the vsphere_nas_datastore resource, which can be
    used to manage NAS datastores via NFS v3 and v4.1.

    Details in the docs. :)

commit 213762d
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:34:59 2017 -0700

    Update CHANGELOG.md

commit fb3f4fb
Merge: 1eac679 2aab458
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:34:19 2017 -0700

    Merge pull request hashicorp#142 from terraform-providers/f-vmfs-datastore-resource

    New resource: vsphere_vmfs_datastore

commit 2aab458
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 20:04:45 2017 -0700

    r/vmfs_datastore: Fix import

    Smoke testing the import uncovered issues where certain fields weren't
    populated. Unfortunately populating all the fields properly and
    validating that the datastore is actually a datastore that the host has
    mounted also means that we need to know the host ID, so we have had to
    add that to the import ID.

    This has the unfortunate side effect of making it hard to test this,
    currently. I have created hashicorp/terraform#16036 to help address
    this, and will re-enable the test when it gets merged.

commit a61ebf3
Author: Chris Marchesi <[email protected]>
Date:   Wed Sep 6 12:04:42 2017 -0700

    r/vmfs_datastore: Make constants more specific, remove update state save

    The constant names were really general and we may have run into
    collisions eventually. Also, we don't need to record every disk update
    like I thought for some reason - if there is an error, it will just be
    picked up next refresh anyway. Removed this extra bit of complexity to
    be consistent with the fact that we really don't do this anywhere else.

commit fc772b4
Author: Chris Marchesi <[email protected]>
Date:   Mon Sep 4 20:45:57 2017 -0700

    r/vmfs_datastore: Fix expected folder to env var

    Was a static path before, which was causing issues with some of my tests
    because I have it set to a different path in my devrc.

commit 418b574
Author: Chris Marchesi <[email protected]>
Date:   Sat Sep 2 16:54:59 2017 -0700

    r/vmfs_datastore: Add folder support

    Just as a bonus, added folder support. This commit also ultimately
    scaffolds a lot of stuff that we will need for proper inventory support
    anyway, including helpers to determine well-known paths for the 4 major
    inventory types based off an existing managed object, which will allow
    for some saner control around where in inventory a specific item goes.
    As an example, with this approach, the vsphere_vmfs_datastore resource
    "folder" attribute can only place datastores in folders that are in the
    datacenter that the datastore is actually being set up in - so if the
    host that the datastore is being set up in is in the "dc1" datacenter,
    the folder needs to exist within "/dc1/datastore".

commit 923bab2
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 21:45:35 2017 -0700

    r/vmfs_datastore: Documentation

    Full documentation for the vsphere_vmfs_datastore resource.

commit a5b4034
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 15:40:51 2017 -0700

    r/vmfs_datastore: Add import feature

    Add an easy peasy import feature. MoRefs can be fetched via a special
    part of the vSphere web client that basically allows you to walk the
    ServiceInstance root object, which allows you to fetch datastores and a
    number of other managed object IDs.

commit c617982
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 12:39:24 2017 -0700

    r/vmfs_datastore: Fix some error strings, refine retry waiter

    Some error string cleanup, and also an update to the delete retry
    waiter so that it handles the actual ResourceInUse error instead of
    doing a string match.

commit 15c9b9a
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 11:28:37 2017 -0700

    r/vmfs_datastore: Better error messages

    Quoted most entities, and also provided better context for whole disk
    selection error messages.

commit c118a4d
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 11:17:09 2017 -0700

    r/vmfs_datastore: Support datastore renaming

    Since this resource uses MOID as the source of truth, we can support
    renaming of the datastore on this resource pretty easy. Add that
    support. This also removes the ForceNew situation if the name has
    drifted as well.

commit f4c1da1
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 10:44:19 2017 -0700

    r/vmfs_datastore: Flatten disk space denominations to MB

    Just to make things a bit more readable.

commit b2c0f0f
Author: Chris Marchesi <[email protected]>
Date:   Fri Sep 1 09:09:11 2017 -0700

    r/vmfs_datastore: Better error handling

    Moved helpers to check to see if removed datastores were missing over to
    more general and type-safe VIM fault helpers (introduced in
    vim_helper.go). This is how we will be checking for errors in the future
    - a bit of back-refactoring may need to be done later to accommodate
    this in existing code, but the path to check should be a lot more clear
    now.

commit f5e8c1c
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 23:23:43 2017 -0700

    New resource: vsphere_vmfs_datastore

    This commit introduces the vsphere_vmfs_datastore resource, which can be
    used to manage VMFS-based datastores.

    Currently only whole disk support is included, however import
    functionality is planned so that one can import existing datastores that
    don't have full-disk extents, although whole disks will only be allowed
    to be added from there.

    Support for disk expansion may also be planned, depending on business
    case.

commit 1eac679
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 22:06:16 2017 -0700

    Update CHANGELOG.md

commit 966ba86
Merge: 17c4453 b5407a9
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 22:04:25 2017 -0700

    Merge pull request hashicorp#141 from terraform-providers/f-vmfs-disks-data-source

    New data source: vsphere_vmfs_disks

commit b5407a9
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 21:59:55 2017 -0700

    New data source: vsphere_vmfs_disks

    This adds the vsphere_vmfs_disks data source, which allows someone to
    discover storage devices that can be used for VMFS datastores on a given
    ESXi host.

    The output of this is intended to be fed into a vsphere_vmfs_datastore
    resource, which allows for the creation of a VMFS datastore off a host
    or a set of hosts (ie: in the case of FC or iSCSI disks).

commit 17c4453
Author: TeamCity <[email protected]>
Date:   Thu Aug 31 23:39:37 2017 +0000

    Cleanup after v0.2.1 release

commit 2f68a47
Author: TeamCity <[email protected]>
Date:   Thu Aug 31 23:36:12 2017 +0000

    v0.2.1

commit 8a6bb57
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 16:30:53 2017 -0700

    Update CHANGELOG.md

commit c8761af
Merge: ae75db1 55de1a4
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 16:29:57 2017 -0700

    Merge pull request hashicorp#139 from terraform-providers/f-host-port-group-resource

    New resource: vsphere_host_port_group

commit 55de1a4
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 16:28:30 2017 -0700

    r/host_port_group: Add validation to vlan_id

    To ensure TF can validate the valid VLAN range.

commit ae75db1
Merge: 563f524 492e1bc
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 16:25:55 2017 -0700

    Merge pull request hashicorp#148 from terraform-providers/b-host-virtual-switch-doc-fix

    r/host_virtual_switch: Doc update for ID attribute

commit 492e1bc
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 15:03:00 2017 -0700

    r/host_virtual_switch: Doc update for ID attribute

    The ID attribute is now a composite attribute that we assemble in code,
    and not just the name of the resource, because that is not a unique
    value or very telling of where the resource is actually located.

    The ID change went in with hashicorp#138, but I forgot to update the docs.

commit 7a3c06d
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 14:53:53 2017 -0700

    New resource: vsphere_host_port_group

    This commit adds the vsphere_host_port_group resource, which can be used
    to add port groups on an ESXi host, and serves as the companion to
    vsphere_host_virtual_switch which can be used in tandem to this
    resource.

commit 563f524
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 11:28:58 2017 -0700

    Update CHANGELOG.md

commit 3d3c063
Merge: 181b638 5aaade0
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 11:27:20 2017 -0700

    Merge pull request hashicorp#138 from terraform-providers/f-host-vswitch-resource

    New resource: vsphere_host_virtual_switch

commit 5aaade0
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 11:00:08 2017 -0700

    r/host_virtual_switch: Remove unnecessary type declarations in fixtures

    These are implied by the defaults.

commit 1f40c63
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 10:36:07 2017 -0700

    r/host_virtual_switch: Break out rolling order negation

    To make it more explicit that we can't just negate the value of a
    pointer (which !obj.RollingOrder would be).

commit f5bd248
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 10:32:45 2017 -0700

    r/host_virtual_switch: Assert exactly 3 elements in ID

    SplitN should always give 3 elements on a proper ID.

commit 26ce39a
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 10:13:56 2017 -0700

    r/host_virtual_switch: Small test readability fix for missing case

    Change !expected to expected == false, to be more explicit.

commit b061d07
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 10:08:57 2017 -0700

    Make all *bool literals and assignments easier to read

    Added a small boolPtr helper function for this.

    As a TODO, I'd like to streamline helpers possibly into their own
    package, and add one for int32 which seems to be the standard int type
    in govmomi.

commit edb0836
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 21:46:08 2017 -0700

    New resource: vsphere_host_virtual_switch

    This commit adds a new resource, vsphere_host_virtual_switch, which can
    be used to manage a virtual switch on an ESXi host.

commit 181b638
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 09:02:14 2017 -0700

    Update CHANGELOG.md

commit 5ea05e1
Merge: c4e803d f06f4a8
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 31 09:00:56 2017 -0700

    Merge pull request hashicorp#146 from terraform-providers/f-host-data-source

    New data source: vsphere_host

commit c4e803d
Merge: 306b6dd 661a5df
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 23:00:49 2017 -0700

    Merge pull request hashicorp#147 from terraform-providers/vendor-tf-v0.10.3

    Vendor: Update TF to v0.10.3

commit 661a5df
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 21:49:27 2017 -0700

    Travis: Change go version used to 1.9

    So that tests work (we are using t.Helper now).

commit 64e113b
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 19:38:09 2017 -0700

    vendor: Add github.com/hashicorp/terraform/helper/validation

    We use the validators in some of the pending PR's.

commit 02e9f45
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 19:37:01 2017 -0700

    vendor: Update TF to v0.10.3

    There's some stuff some of the pending PR's here need, in particularly
    in the validation package which I will be adding shortly.

commit f06f4a8
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 14:58:54 2017 -0700

    New data source: vsphere_host

    This resource can be used to discover the managed object ID of a
    specific host. Like vsphere_datacenter, this has been written to
    facilitate the use of a managed object reference ID to fetch the host
    system object to work with various resources, such as host networking
    resources or datastores.

    Made the function name more terse as well.

commit 306b6dd
Merge: d0e15f1 10cf6a8
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 19:27:51 2017 -0700

    Merge pull request hashicorp#145 from terraform-providers/b-docs-datacenter-data-source

    d/datacenter: Re-word "default" datacenter doc references

commit 10cf6a8
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 16:21:39 2017 -0700

    d/datacenter: Re-word "default" datacenter doc references

    The "default" datacenter is actually for the most part a gvmomi thing, a
    consequence of using the DefaultDatacenter calls in the find package.
    This function simulates default datacenter fetching behaviour by
    returning a single datacenter object from inventory if, and only if, a
    singular datacenter object exists in inventory. This is always the case
    on ESXi, but not on vCenter, and if there are multiple datacenters found
    the call will fail. Docs have been updated to reflect this.

commit d0e15f1
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 15:45:22 2017 -0700

    Update CHANGELOG.md

commit 0aa17ed
Merge: 658941d d23cba6
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 15:43:32 2017 -0700

    Merge pull request hashicorp#144 from terraform-providers/f-datacenter-data-source

    New data source: vsphere_datacenter

commit d23cba6
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 15:14:53 2017 -0700

    r/datacenter: Update docs related to ESXi

    Couple of things:

    * Clarified the nature of the "default" datacenter on ESXi and how the
    name attribute has no meaning.
    * Moved all of this detail to the warning text.
    * Have decided (not 100% related to this resource) that vsphere_host
    will _require_ the vsphere_datacenter data source's output, even if
    using ESXi. The purpose of these data sources and moving to using MoRefs
    as the source of truth is to reduce ambiguity, and as such we shouldn't
    be introducing ambiguity in.

commit 03ef7d2
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 15:03:58 2017 -0700

    d/datacenter: Remove redundant datacenter_id variable

    We now just focus on the ID attribute to provide the managed object ID.

commit effd718
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 14:23:19 2017 -0700

    New data source: vsphere_datacenter

    This data source fetches the MOID for a vSphere datacenter, and is
    intended for use in other up-and-coming resources that will use a
    managed object reference to a datacenter to fetch other resources (like
    host systems), or tell resources where they need to be deployed to (may
    eventually be used in vsphere_virtual_machine, for example).

commit 701a445
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 30 13:25:31 2017 -0700

    Move getDatacenter to vsphere/datacenter_helper.go, add API handling

    Moved getDatacenter to its own helper code, as a lot of other resources
    use it. Also added the ability of it to detect the connected API type
    (ESXi vs vCenter), and just use the default if on ESXi.

commit 658941d
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 24 11:46:49 2017 -0700

    Update CHANGELOG.md

commit 730e48b
Merge: 8be9a76 17e75ce
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 24 11:45:48 2017 -0700

    Merge pull request hashicorp#79 from ewypych/p-vsphere-hostname-customization

    Set different hostname of a VM than name

commit 17e75ce
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 24 11:43:12 2017 -0700

    r/vsphere_virtual_machine: Small doc correction for hostname

    Just a small grammar fix, and also re-run the sample code through
    terraform fmt.

commit 8be9a76
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 24 11:12:34 2017 -0700

    Update CHANGELOG.md

commit 2dfd5ea
Merge: 4079169 2f58f25
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 24 11:10:25 2017 -0700

    Merge pull request hashicorp#128 from mjrider/BUGFIX-inprove-guest-ipstack-to-terraform-mapping

    Fix ip mapping from guest to terraform

commit f6f9121
Author: ewypych <[email protected]>
Date:   Tue Jun 13 21:49:12 2017 +0200

    standalone hostname during OS customization

commit 2f58f25
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 24 08:39:17 2017 +0200

    Suppress differences when ip's are equal

commit 4079169
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 17:22:53 2017 -0700

    0.1.x namespace -> 0.2.x namespace

    Just to be consistent with the current release.

commit d1c0822
Merge: ccaa380 0c1af9e
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 16:39:43 2017 -0700

    Merge branch 'master' of github.com:terraform-providers/terraform-provider-vsphere

commit ccaa380
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 16:38:04 2017 -0700

    Update README to reflect required TF and current provider version

    Due to some changes in go-plugin we needed to bump the required TF
    version. Also did a vanity update to the provider example to reflect the
    latest release.

commit 0c1af9e
Author: TeamCity <[email protected]>
Date:   Wed Aug 23 23:04:55 2017 +0000

    Cleanup after v0.2.0 release

commit 7ceeaa1
Author: TeamCity <[email protected]>
Date:   Wed Aug 23 23:01:14 2017 +0000

    v0.2.0

commit 6813403
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 15:56:18 2017 -0700

    CHANGELOG: Bump version to v0.2.0

    One "breaking change" and kind of a signification that we are actively
    working on making the provider better. Felt a little wrong to leave it
    at just v0.1.x.

commit 54485e8
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 12:20:25 2017 -0700

    Update CHANGELOG.md

    Also updated formatting for resource/data source change notifications to
    match the conventions of the AWS repo.

commit f43f979
Merge: 066c9bb 283cac0
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 11:49:55 2017 -0700

    Merge pull request hashicorp#94 from ewypych/change-def-adapter

    Change default adapter_type to lsiLogic

commit 066c9bb
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 23 11:26:54 2017 -0700

    Remove deep README

    This is an old README, and the new one supersedes this one. Anything
    that was in that file that is missing in the current top-level README
    can be added later.

commit b6a3cdc
Merge: 1126e73 547f4c5
Author: Chris Marchesi <[email protected]>
Date:   Tue Aug 22 22:36:39 2017 -0700

    Merge pull request hashicorp#137 from terraform-providers/vendor-tf-v0.10.2

    vendor: Update TF to v0.10.2

commit 547f4c5
Author: Chris Marchesi <[email protected]>
Date:   Tue Aug 22 13:09:12 2017 -0700

    vendor: Update TF to v0.10.2

    In particular, we are using GetOkExists in the port group resources so
    that we can determine if inheritance is needed on certain network policy
    attributes properly - and it was renamed from GetOkRaw in v0.10.1.

commit 427c373
Author: Robbert Müller <[email protected]>
Date:   Fri Aug 18 14:57:18 2017 +0200

    Make sure we do not map v4 addresses to v6

commit 1126e73
Merge: 9f49bd4 fdb42c2
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 17:17:36 2017 -0700

    Merge branch 'master' of github.com:terraform-providers/terraform-provider-vsphere

commit 9f49bd4
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 17:15:52 2017 -0700

    Add new variables to devrc include

    To support the new DC and license resources.

commit a8b8751
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 17:15:34 2017 -0700

    Update CHANGELOG.md

commit fdb42c2
Merge: f895a87 05cdd19
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 16:58:07 2017 -0700

    Merge pull request hashicorp#110 from girishramnani/license-resource

    Enhancement: Added resource for license management

commit 05cdd19
Merge: de493e3 f895a87
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 16:51:00 2017 -0700

    Merge branch 'master' into license-resource

commit f895a87
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 16:19:21 2017 -0700

    Update CHANGELOG.md

commit dbd9b09
Merge: a1c1cb1 f337494
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 16:16:29 2017 -0700

    Merge pull request hashicorp#126 from jorgenunez/new-resource-datacenter

    Enhancement: New resource datacenter

commit f337494
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 16:11:27 2017 -0700

    Small formatting fix for test fixtures for DC resource

    Just make sure the raw string terminated on a newline and also ran the
    TF code through terraform fmt.

commit e6fbc52
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 17 20:24:01 2017 +0200

    filter link local

commit a7b8195
Merge: a8fa93a a1c1cb1
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 17 20:09:17 2017 +0200

    Merge remote-tracking branch 'origin/master' into BUGFIX-inprove-guest-ipstack-to-terraform-mapping

commit a1c1cb1
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 10:33:20 2017 -0700

    Update CHANGELOG.md

commit a284473
Merge: fe30565 6d23f58
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 10:03:33 2017 -0700

    Merge pull request hashicorp#129 from mjrider/networkInterfaces

    Discovery network interfaces from pci devices instead from Guest information

commit 6d23f58
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 17 09:55:58 2017 -0700

    Add test case for VM refresh panic

    This adds a test case for @mjrider's new network device polling logic
    that fixes several issues resulting from the inconsistencies between
    physical devices and IP information when the guest is shut down. The
    test is similar to the VM test, but in a second step it powers down the
    VM and does another plan. This effectively triggers the panic on the old
    code.

commit f08a7d8
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 17 18:24:47 2017 +0200

    Use mvm instead of vm

commit e45fa9f
Author: Jorge Núñez <[email protected]>
Date:   Thu Aug 17 15:19:27 2017 +0200

    Fix missing ERROR messages and path to folder

commit 8f5d9a2
Author: Jorge Núñez <[email protected]>
Date:   Thu Aug 17 15:14:38 2017 +0200

    Implement second round of PR feedback (error messages, constant and path)

commit 995d9e8
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 17 08:18:25 2017 +0200

    add errorhanling

commit de493e3
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 17 11:48:02 2017 +0530

    moved the error

commit e03a78e
Author: Robbert Müller <[email protected]>
Date:   Thu Aug 17 08:12:40 2017 +0200

    Code cleanup

    - added [DEBUG] tags
    - removed many log statements
    - log the right device list

commit 44a3744
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 17 10:55:35 2017 +0530

    extracted updateLabels function and changed the create license procedure for vcenter

commit 40b2a8d
Author: Jorge Núñez <[email protected]>
Date:   Wed Aug 16 14:00:02 2017 +0200

    make fmt

commit 204a4b2
Author: Jorge Núñez <[email protected]>
Date:   Wed Aug 16 13:57:01 2017 +0200

    Remove "No updates are possible" line in the documentation

commit 7932401
Author: Jorge Núñez <[email protected]>
Date:   Wed Aug 16 13:54:11 2017 +0200

    Implement PR feedback

commit f76eba8
Author: girish.ramnani <[email protected]>
Date:   Tue Aug 15 04:07:45 2017 +0530

    made the config a const

commit fe30565
Merge: 0496b01 d8e57a4
Author: Chris Marchesi <[email protected]>
Date:   Mon Aug 14 14:36:33 2017 -0700

    Merge pull request hashicorp#123 from terraform-providers/vendor-tf-0.10

    vendor: github.com/hashicorp/terraform/[email protected]

commit c46af8d
Merge: fb832ff 0496b01
Author: Robbert Müller <[email protected]>
Date:   Fri Aug 11 16:25:22 2017 +0200

    Merge branch 'master' of github.com:terraform-providers/terraform-provider-vsphere into networkInterfaces

commit a8fa93a
Author: Robbert Müller <[email protected]>
Date:   Fri Aug 11 14:17:02 2017 +0200

    Fip ip mapping from guest to terraform

    - only accept the first ip adres per family instead of the last one
      This is a problem which machines with floating ipaddresses

    - for ipv6, reject link-local ipadresses, those are auto-generated

commit d669808
Author: girish.ramnani <[email protected]>
Date:   Fri Aug 11 11:27:14 2017 +0530

    mentioned the VSPHERE_TEST_ESXI env variable in the doc

commit 316e794
Author: girish.ramnani <[email protected]>
Date:   Fri Aug 11 11:24:22 2017 +0530

    split the test into vcenter and esxi specific and removed the tabs in config

commit da02d88
Author: Jorge Núñez <[email protected]>
Date:   Fri Aug 11 02:14:12 2017 +0200

    Add documentation for new resource vsphere_datacenter

commit 31a7067
Author: Jorge Núñez <[email protected]>
Date:   Fri Aug 11 02:13:56 2017 +0200

    Add new resource vsphere_datacenter

commit 7e239a1
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 10 23:32:01 2017 +0530

    changed VCPUs to CPUs in the docs

commit 0496b01
Merge: 573de3d 2d7f7e9
Author: Chris Marchesi <[email protected]>
Date:   Thu Aug 10 09:46:15 2017 -0700

    Merge pull request hashicorp#122 from terraform-providers/f-devrc-update

    Cleanup devrc

commit d8e57a4
Author: Radek Simko <[email protected]>
Date:   Thu Aug 10 15:23:20 2017 +0200

    vendor: github.com/hashicorp/terraform/[email protected]

commit a020155
Author: Radek Simko <[email protected]>
Date:   Thu Aug 10 15:22:07 2017 +0200

    vendor: Ignore github.com/hashicorp/terraform/backend

    This is to avoid dependency sprawl - e.g. vendoring AWS or Azure SDK
    when we don't really need remote backend functionality
    in provider code - it's core's responsibility.

commit 6f712bb
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 10 12:56:08 2017 +0530

    added error and ExpectError check for ESXi server

commit 48a46cf
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 10 12:04:59 2017 +0530

    error check for invalid license instead of decode error and indentation removed

commit a638adc
Author: girish.ramnani <[email protected]>
Date:   Tue Aug 8 17:28:42 2017 +0530

    solved the wrong config and inlined the key env variable

commit 62cd62a
Author: girish.ramnani <[email protected]>
Date:   Sat Aug 5 11:09:56 2017 +0530

    updated the docs,made labels static in the test config and set labels in the read method

commit 322c3e8
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 3 16:14:16 2017 +0530

    changed labels to TypeMap and updated the readme

commit 4339e00
Author: girish.ramnani <[email protected]>
Date:   Thu Aug 3 14:13:26 2017 +0530

    add consistent spacing, removed the check for license_key

commit 3495fd2
Author: girish.ramnani <[email protected]>
Date:   Wed Aug 2 10:50:25 2017 +0530

    use different method to add license for vsphere and standalone

commit 6cfc998
Author: girish.ramnani <[email protected]>
Date:   Tue Jul 25 11:55:54 2017 +0530

    final check and cleanup

commit d0bd3c5
Author: girish.ramnani <[email protected]>
Date:   Tue Jul 25 11:17:27 2017 +0530

    updated readme

commit d69af82
Author: girish.ramnani <[email protected]>
Date:   Tue Jul 25 11:14:32 2017 +0530

    changes to merge with github master

commit d361dc8
Author: girish.ramnani <[email protected]>
Date:   Mon Jul 24 16:53:56 2017 +0530

    changed the decode method with a list->filter

commit cad35d1
Author: girish.ramnani <[email protected]>
Date:   Mon Jul 24 14:57:11 2017 +0530

    managed invalid key

commit 0a4fbfb
Author: girish.ramnani <[email protected]>
Date:   Mon Jul 24 00:52:22 2017 +0530

    renamed to test to have uppercase initials and better comments

commit 6fe8231
Author: girish.ramnani <[email protected]>
Date:   Sun Jul 23 23:59:03 2017 +0530

    changed the tags from [G] to [INFO]

commit b51f522
Author: girish.ramnani <[email protected]>
Date:   Sun Jul 23 23:51:52 2017 +0530

    removed the TODO and changed the testNames for consistency

commit 333c9e3
Author: girish.ramnani <[email protected]>
Date:   Sun Jul 23 23:28:23 2017 +0530

    changed the test messages to be more informative

commit 38f1afe
Author: girish.ramnani <[email protected]>
Date:   Sun Jul 23 23:11:16 2017 +0530

    solved the wrong file name issue

commit 9fb4f69
Author: girish.ramnani <[email protected]>
Date:   Fri Jul 21 18:53:02 2017 +0530

    added documentation for the terraform site

commit 8ec88ee
Author: girish.ramnani <[email protected]>
Date:   Tue Jul 18 11:32:01 2017 +0530

    Added integration tests

commit 7eac7c5
Author: girish.ramnani <[email protected]>
Date:   Fri Jul 14 12:54:13 2017 +0530

    added check for deleting the key

commit 7c8bf4e
Author: girish.ramnani <[email protected]>
Date:   Fri Jul 14 12:14:26 2017 +0530

    resolved the update issue

commit 7fb8093
Author: girish.ramnani <[email protected]>
Date:   Thu Jul 13 17:57:18 2017 +0530

    added license resource

commit 2d7f7e9
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 9 20:29:19 2017 -0700

    Cleanup devrc

    Correct a spelling mistake and consolidate variables. Some of these vars
    are shared between tests and annotating them to a single resource did
    not make sense. On the other hand, added annotations to reflect what the
    variables represent so that there is as little ambiguity as possible.

commit 573de3d
Merge: 7331b88 00543d3
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 9 16:31:29 2017 -0700

    Merge pull request hashicorp#121 from terraform-providers/f-devrc-and-readme

    Test environment RC file, update base and drop inner README

commit 00543d3
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 9 16:02:31 2017 -0700

    Add more detail to top-level README, remove one in vsphere/ dir

    I want the top-level README to be the source of truth here, combined
    with the documentation on the official website.

commit 882c466
Author: Chris Marchesi <[email protected]>
Date:   Wed Aug 9 15:59:50 2017 -0700

    Add environment configuration via GNUmakefile

    This adds a couple of items:

    * The ability to configure environment varaibles through
    $HOME/.tf-vsphere-devrc.mk.

    * A file, tf-vsphere-devrc.mk.example, that will contain all of the
    variables required to run the acceptance tests. The idea would be that
    someone copies the file to $HOME/.tf-vsphere-devrc.mk, and edits the
    values appropriately.

    Hoping that the list of variables will drop as the provider becomes more
    self-hosting.

commit 7331b88
Author: Chris Marchesi <[email protected]>
Date:   Tue Aug 8 22:09:14 2017 -0700

    Update CHANGELOG.md

commit aa03f7e
Merge: 256069c 1562b41
Author: Chris Marchesi <[email protected]>
Date:   Tue Aug 8 22:03:02 2017 -0700

    Merge pull request hashicorp#114 from mjrider/updatePR96

    vendor/govmomi/* - update to v0.15.0

commit fb832ff
Author: Robbert Müller <[email protected]>
Date:   Fri Jul 28 11:08:29 2017 +0200

    Added network device discovery from Virtualhardware

commit 1562b41
Author: Robbert Müller <[email protected]>
Date:   Wed Jul 26 20:24:06 2017 +0200

    update govmomi and all subpackages

commit d99d3c8
Author: Robbert Müller <[email protected]>
Date:   Wed Jul 26 20:12:29 2017 +0200

    update and cleanup vendor github.com/vmware/govmomi

commit 256069c
Author: Jake Champlin <[email protected]>
Date:   Tue Jul 25 13:23:24 2017 -0400

    Update CHANGELOG.md

commit 12a5bc8
Merge: 8653ce6 8624dab
Author: Jake Champlin <[email protected]>
Date:   Tue Jul 25 13:22:31 2017 -0400

    Merge pull request hashicorp#111 from verdel/virtual-machine-annotation

    virtual machine - add annotation argument

commit 8624dab
Author: Vadim Aleksandrov <[email protected]>
Date:   Tue Jul 25 18:10:47 2017 +0300

    virtual machine - add annotation argument

commit 8653ce6
Author: Jake Champlin <[email protected]>
Date:   Fri Jul 21 11:47:28 2017 -0400

    add missing readme

commit 6258050
Author: Aleks Saul <[email protected]>
Date:   Tue Jun 20 08:26:31 2017 -0400

    vendor/govmomi - update to v0.15.0

    Updates govmomi to v0.15.0 release

commit 283cac0
Author: ewypych <[email protected]>
Date:   Wed Jun 14 12:51:20 2017 +0200

    change default adapter_type to lsiLogic
@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Type: Enhancement new-resource Feature: New Resource
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants