-
Notifications
You must be signed in to change notification settings - Fork 77
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 GetVirtualHardwareSection fuction #200
Conversation
Returning the Vdc.Status as a string breaks the usage of the `types.VDCStatuses[]` map as the value returned is of `type string` and not `type int` as the map is defined here https://github.com/vmware/go-vcloud-director/blob/master/types/v56/types.go#37. Currently something like this is required to use the `types.VDCStatues[]` map: ``` i, err := strconv.Atoi(vdc.Vdc.Status) if err != nil { return err } log.Info(types.VDCStatuses[i]) // Returns the mapped value ``` This change would give `Vdc.Status` the same behavior as `Vapp.Status` when using either of their corresponding maps and allow for this to work: ``` log.Info(types.VDCStatuses[vdc.Vdc.Status]) ```
Hi, @frenchtoasters. Thanks for the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR - just small improvements needed. And also unit test will be big help.
Ya sure I didnt see one for the |
@frenchtoasters as a preparation for merge, please provide a commit message following the guidelines https://chris.beams.io/posts/git-commit/ as referenced in |
govcd/vm_test.go
Outdated
}, | ||
} | ||
|
||
vm, err := vcd.client.Client.FindVMByHREF(newVM.HREF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call cannot work.
You are calling a function that finds a VM by HREF, but the HREF is empty, as it is only available for entities that have been created or fetched from vCD.
The test should use an already existing VM (preferred), or create a new one, and then get its contents.
@frenchtoasters Are you planning to complete this one? |
Yes I do just have not been able to budget out the time to correct the unit test. Though I believe the fix is fairly simple, in that I should just be using the Though I am wondering @dataclouder would it be acceptable to set the |
Both approaches work, though I am not sure the first one could get predictable results. Looking forward to evaluating your improvements! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @frenchtoasters,
Sorry for leaving you in limbo for this long. We had the release on tight schedule.
I have ran your test and it failed on my side.
go test -tags functional -check.vv -check.f "Test_GetVirtualHardwareSection" -timeout=15m .
START: vm_test.go:815: TestVCD.Test_GetVirtualHardwareSection
Running: TestGetVirtualHardwareSection
vm_test.go:851:
check.Assert(item.Address, Equals, vm.VM.VirtualHardwareSection.Item[0].Address)
... obtained string = "00:50:56:29:01:fd"
... expected string = "1.1.1.1"
FAIL: vm_test.go:815: TestVCD.Test_GetVirtualHardwareSection
I have left some ideas inline on how to make this working.
Co-Authored-By: Dainius <Didainius@users.noreply.github.com>
The tests seems to be passing for me. Could you merge latest |
Be sure to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-Authored-By: Dainius <Didainius@users.noreply.github.com>
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing!
It is now merged. Thank you @frenchtoasters ! |
IMPORTANT
To help us process your pull request efficiently, please follow the
guidelines shown below.
A Pull Request should be associated with an Issue
We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
and potentially we'll be able to point development in a particular direction.
We accept PRs without associated issues provided the change is sufficiently evident
from the commit message. If you have typos or simple bug fixes go for it.
Description
Related issue: #199
Add GetVirtualHardwareSection fuction
This function is near identical to
GetNetworkConnectionSection()
in/govcd/vm.go
and does essentially the same thing. It gathers the/vApp/{id}/virtualHardwareSection
endpoint of aVM
from the restapi and then returns that the*types.VirtualHardwareSection
pointer which already has the corresponding structs written, here. It also references a new mime typetypes.MimeVirtualHardwareSection
which was derived from here.