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

Vswitch import #625

Merged
merged 13 commits into from
Oct 5, 2018
Merged

Vswitch import #625

merged 13 commits into from
Oct 5, 2018

Conversation

pablo-ruth
Copy link
Contributor

This update adds import functionality on vsphere_host_virtual_switch resource.

@ghost ghost added the size/s Relative Sizing: Small label Sep 25, 2018
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 good! Just have a couple comments and requests on the PR.

In addition to the inline comments, can you please also add an import test (see here for an example), and run make fmt again with go v1.11? We just switched over to go v1.11.0 which has a few minor fmt differences.

vsphere/host_network_system_helper.go Show resolved Hide resolved
d.Set("host_system_id", hostID)
d.Set("name", switchName)

err = resourceVSphereHostVirtualSwitchRead(d, meta)
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 call Read here as it will be called after import.

return []*schema.ResourceData{}, err
}

d.Set("host_system_id", hostID)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error returned from d.Set should be handled.

}

d.Set("host_system_id", hostID)
d.Set("name", switchName)
Copy link
Contributor

Choose a reason for hiding this comment

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

The error returned from d.Set should be handled.

@@ -174,3 +174,16 @@ the resource. This is set to an ID value unique to Terraform - the convention
is a prefix, the host system ID, and the virtual switch name. An example would
be `tf-HostVirtualSwitch:host-10:vSwitchTerraformTest`.

## Importing

An existing vSwitch can be [imported][docs-import] into this resource via the id
Copy link
Contributor

Choose a reason for hiding this comment

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

The id for vswitches isn't very intuitive. I think having an explaination that the ID is the <prefix (tf-HostVirtualSwitch)>:: would help make it more clear. Sorry the id isn't simpler in this case!

@pablo-ruth
Copy link
Contributor Author

I tried to code the import test but I don't have a test vsphere env so it's very difficult... I'll try to set up one and do that next week.

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.

Looking very close! Thanks for taking the time to contribute and work through some reviews. On the acceptance test, I'd be happy to run the test for you on my environment. Or if you'd prefer, I can write the test and get it over to you. I'll follow your lead on it!

## Importing

An existing vSwitch can be [imported][docs-import] into this resource by its id.
The convention of the id is a prefix, the host system ID, and the virtual switch
Copy link
Contributor

Choose a reason for hiding this comment

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

One last thing on this, can host system ID be changed to host system [managed objectID][docs-about-morefs]? And add:
[docs-about-morefs]: /docs/providers/vsphere/index.html#use-of-managed-object-references-by-the-vsphere-provider

There are several different ID types used throughout the provider, so it is just helpful to be extra clear when specifying.

@@ -174,3 +174,18 @@ the resource. This is set to an ID value unique to Terraform - the convention
is a prefix, the host system ID, and the virtual switch name. An example would
be `tf-HostVirtualSwitch:host-10:vSwitchTerraformTest`.

## Importing

An existing vSwitch can be [imported][docs-import] into this resource by its id.
Copy link
Contributor

Choose a reason for hiding this comment

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

id -> ID

vsphere/host_network_system_helper.go Show resolved Hide resolved
@ghost ghost added size/m Relative Sizing: Medium and removed size/s Relative Sizing: Small labels Oct 4, 2018
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 good. Thanks for all the work!

@bill-rich bill-rich merged commit 6c2852e into hashicorp:master Oct 5, 2018
@pablo-ruth pablo-ruth deleted the vswitchImport branch October 6, 2018 09:35
@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
size/m Relative Sizing: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants