Patch XML namespace problem for vm. UpdateNetworkConnectionSection #677
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #429
Problem
In some cases,
vm.UpdateNetworkConnectionSection
fails with error similar toHTTP 400 Bad Request - cvc-elt.1.a: Cannot find the declaration of element 'NetworkConnectionSection'
The cause
The
vm.UpdateNetworkConnectionSection
at first retrieves existing network configuration (vm.GetNetworkConnectionSection
) and the modifies it.In some environments, there is a problem that in some cases VCD randomly (not always) puts the payload for GET query into
ns2
namespace.For reference, the regular normal payload that this call returns (not wrapped into
ns2
namespace)Because Go XML library has issues with namespace handling (golang/go#9519), the
Xmlns
attribute valuehttp://www.vmware.com/vcloud/v1.5
gets lost in translation and this causes the described error when update occurs.The fix
The fix is to set hardcoded setting for
Xmlns
tohttp://www.vmware.com/vcloud/v1.5
for every update call. This will prevent malformed XML document query.Testing
I have triggered tests that include call to the method
vm.UpdateNetworkConnectionSection
and none of them failed: