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

New functionality for handling vApp network NAT #316

Merged
merged 37 commits into from
Jun 23, 2020

Conversation

vbauzys
Copy link
Contributor

@vbauzys vbauzys commented Jun 9, 2020

Add function needed for implementing vApp network NAT rules resource:

  • vapp.UpdateNetworkNatRules

This PR is derived from #308 so shows that PR code too.

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

Some changes required

govcd/api.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved

util.Logger.Printf("[TRACE] Looking for networks: %s --- %d", id, len(vapp.VApp.NetworkConfigSection.NetworkConfig))
for _, vappNetwork := range vapp.VApp.NetworkConfigSection.NetworkConfig {
// break early for disconnected network interfaces. They don't have all information
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be "empty" instead of "disconnected"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from UI perspective they are disconected

Copy link
Contributor

Choose a reason for hiding this comment

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

I am OK with using UI names in Terraform, but in the SDK we should follow the API.

govcd/vapp_network_test.go Outdated Show resolved Hide resolved
govcd/vapp_network_test.go Show resolved Hide resolved
govcd/vapp_network_test.go Show resolved Hide resolved
types/v56/types.go Outdated Show resolved Hide resolved
types/v56/types.go Outdated Show resolved Hide resolved
vbauzys added 3 commits June 10, 2020 15:34
# Conflicts:
#	CHANGELOG.md
#	govcd/vapp_network.go
#	govcd/vapp_network_test.go
#	types/v56/types.go
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

Some small changes needed


util.Logger.Printf("[TRACE] Looking for networks: %s --- %d", id, len(vapp.VApp.NetworkConfigSection.NetworkConfig))
for _, vappNetwork := range vapp.VApp.NetworkConfigSection.NetworkConfig {
// break early for disconnected network interfaces. They don't have all information
Copy link
Contributor

Choose a reason for hiding this comment

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

I am OK with using UI names in Terraform, but in the SDK we should follow the API.

govcd/vapp_network.go Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

My main concern and topic for discussion is that we are overwriting FW and NAT service enabled/disabled state to enabled after updating the network, regardless of what it was before. Is this really what we want and why?

govcd/vapp_network.go Outdated Show resolved Hide resolved
vbauzys added 3 commits June 16, 2020 16:11
# Conflicts:
#	govcd/common_test.go
#	govcd/lb_test.go
#	govcd/vm_test.go
Copy link
Collaborator

@Didainius Didainius 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 a few concerns from me about RemoveAll* functions.

types/v56/types.go Outdated Show resolved Hide resolved
types/v56/types.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Outdated Show resolved Hide resolved
govcd/vapp_network.go Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

Some more comments and change requests

return nil
}

// RemoveAllNetworkFirewallRules removes all network all firewall rules from a vApp network.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// RemoveAllNetworkFirewallRules removes all network all firewall rules from a vApp network.
// RemoveAllNetworkFirewallRules removes all network firewall rules from a vApp network.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ty, fixed

check.Assert(result.Configuration.Features.NatService.NatRule[1].OneToOneVMRule.MappingMode, Equals, "manual")
check.Assert(result.Configuration.Features.NatService.NatRule[1].OneToOneVMRule.VAppScopedVMID, Equals, vm2.VM.VAppScopedLocalID)
check.Assert(result.Configuration.Features.NatService.NatRule[1].OneToOneVMRule.VMNicID, Equals, 0)
check.Assert(*result.Configuration.Features.NatService.NatRule[1].OneToOneVMRule.ExternalIPAddress, Equals, "192.168.100.1")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check that the pointer is not nil before comparing its value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

types/v56/types.go Show resolved Hide resolved
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

Approved. Just one mroe comment about some commented out code chunk.

govcd/vapp_network_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

LGTM

@vbauzys vbauzys merged commit c31f2de into vmware:master Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants