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

Add vSphere host resource #836

Merged
merged 1 commit into from
Sep 24, 2019
Merged

Add vSphere host resource #836

merged 1 commit into from
Sep 24, 2019

Conversation

koikonom
Copy link
Contributor

@koikonom koikonom commented Sep 5, 2019

This is a first draft of a resource that allows terraform users to add new ESXi hosts to a vsphere cluster and manage things like:

[x] connection status
[x] maintenance status
[x] lockdown mode

Once we settle on what it should look like we can work on adding more features.

@ghost ghost added the size/xxl Relative Sizing: Extra-Extra-Large label Sep 5, 2019
@aareet aareet added the enhancement Type: Enhancement label Sep 6, 2019
Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

Looks awesome so far! Have a few questions and comments. Many are just about consistency with the rest of the providers style.

vsphere/internal/helper/hostsystem/host_system_helper.go Outdated Show resolved Hide resolved
vsphere/internal/helper/hostsystem/host_system_helper.go Outdated Show resolved Hide resolved
vsphere/internal/helper/hostsystem/host_system_helper.go Outdated Show resolved Hide resolved
vsphere/resource_vsphere_host.go Outdated Show resolved Hide resolved
vsphere/resource_vsphere_host.go Outdated Show resolved Hide resolved
vsphere/resource_vsphere_host.go Show resolved Hide resolved
vsphere/resource_vsphere_host_test.go Show resolved Hide resolved
vsphere/resource_vsphere_host_test.go Outdated Show resolved Hide resolved
vsphere/resource_vsphere_host_test.go Show resolved Hide resolved
@koikonom koikonom marked this pull request as ready for review September 12, 2019 20:00
@koikonom koikonom changed the title [WIP] Add vSphere host resource Add vSphere host resource Sep 12, 2019
@ghost ghost added the documentation Type: Documentation label Sep 17, 2019
Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

Just a few minor requests and questions.

vsphere/resource_vsphere_host.go Show resolved Hide resolved
@@ -51,7 +51,7 @@ func FromID(client *govmomi.Client, id string) (*object.HostSystem, error) {
defer cancel()
hs, err := finder.ObjectReference(ctx, ref)
if err != nil {
return nil, fmt.Errorf("could not find host system with id: %s: %s", id, err)
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the error messages coming from the API can be a bit vague sometimes. Adding a little bit of text gives better context and we can also track the source of the error just by grepping for the error message if we have to :) .

Copy link
Contributor

Choose a reason for hiding this comment

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

You went the other way here though, right? It looks like it originally included "could not find host system with..." and that part was removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm you're right.... I guess I read the diff the other way. This must have happened by accident. The good news is that I have another branch I'm working on where I'm revisiting all this code and adding some text instead of just returning the vsphere error, so this will be adressed there.

vsphere/resource_vsphere_host.go Show resolved Hide resolved
return fmt.Errorf("Host addition failed. %s", err)
}

log.Printf("[DEBUG] Task Result: %#v", taskResult)
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 its generally better to avoid the fully verbose interpolation (especially with vSphere since it can get quite verbose), but there are certainly cases where it makes sense. Just want to make sure its purposeful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops :) Yeah these are not left like that purpose. I'll do a quick sweep to be sure I haven't left any others like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

log.Printf("[DEBUG] Task Result: %#v", taskResult)
var hostID string
taskResultType := taskResult.(types.ManagedObjectReference).Type
switch taskResultType {
Copy link
Contributor

Choose a reason for hiding this comment

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

ComputeResource and HostSystem should be sufficient, but I'd recommend a default with an error about an unexpected type just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

vsphere/resource_vsphere_host.go Show resolved Hide resolved
Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

LGTM. Nice feature addition!

This is a first draft of a resource that allows terraform users to add
new ESXi hosts to a vsphere cluster and manage things like:

[x] connection status
[x] maintenance status
[x] lockdown mode

Once we settle on what it should look like we can work on adding more
features.
@koikonom
Copy link
Contributor Author

(Squashed all commits into one)

@koikonom koikonom merged commit 76ac598 into master Sep 24, 2019
@koikonom koikonom deleted the f-host-resource branch September 26, 2019 15:25
@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Type: Documentation enhancement Type: Enhancement size/xxl Relative Sizing: Extra-Extra-Large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants