-
Notifications
You must be signed in to change notification settings - Fork 76
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 vApp network functions #290
Conversation
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]> # Conflicts: # CHANGELOG.md
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.
First trivial ask:
The PR subject ("Vapp netw") needs to become a proper sentence with proper words and proper capitalization. Some good examples are here:
hashicorp/terraform-provider-vcd@7a6deb1
hashicorp/terraform-provider-vcd@ae4a431
a453fb9
This is actual to fix now as the last PR got merged with the incomplete PR subject into the log:
hashicorp/terraform-provider-vcd@86fb83f
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
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.
First round. I've left many open questions instead of problems yet.
(Changelog confict also waits you :)
govcd/system.go
Outdated
|
||
// Returns the UUID part of an HREF | ||
// Similar to getBareEntityUuid, but tailored to HREF | ||
func GetUuidFromHref(href string) (string, error) { |
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.
A few questions - do we really need this to be exported? Maybe it could work internally only?
Also - is there any difference between our current private function getUuidFromHref
? Can they be wrapped or reused?
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 functions used widely in terraform also due that we need get ID from href -> specific vapp network handling. Private function is slight different - regular expression is slight changed.
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.
The only difference between the regular expressions in public and private functions is that the public one allows text after the UUID.
I think that, instead of adding a function that is 99% the same as another, we should add a parameter to match either open ended or closed strings.
Alternatively, the two functions should have a different name, because getUuidFromHref
matches an entity UUID (ID at the end), while GetUuidFromHref
matches an UUID from an action HREF (ID/action at the end).
Given that the action is discarded, I suggest this interface:
func GetUuidFromHref(href string, idAtEnd bool) (string, error) {
searchExpression := `^https://.+/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})`
if idAtEnd {
searchExpression +=`$`
} else {
searchExpression += `.*$`
}
reGetID := regexp.MustCompile(searchExpression)
// [...]
}
This way, we use just one function for two needs.
Calls to getUuidFromHref
will become GetUuidFromHref(href, true)
, while calls to GetUuidFromHref
will become GetUuidFromHref(href, false)
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.
I'm in favor of a common function as well to avoid duplication.
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.
good idea, change added.
govcd/vapp.go
Outdated
NetworkName: newNetworkSettings.Name, | ||
Description: newNetworkSettings.Description, | ||
Configuration: &types.NetworkConfiguration{ | ||
FenceMode: types.FenceModeNAT, |
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.
Is it correct even when isolated network is being created?
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.
improved
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]> # Conflicts: # CHANGELOG.md
govcd/vapp.go
Outdated
@@ -786,6 +798,329 @@ func (vapp *VApp) AddIsolatedNetwork(newIsolatedNetworkSettings *VappNetworkSett | |||
|
|||
} | |||
|
|||
// AddNetwork creates isolated or nat routed(connected to Org VDC network) network for vApp. |
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 function (and the related Async
function) need a better name.
In both AddNetwork
and AddOrgNetwork
we are passing an OrgVdcNetwork
as a parameter, but in one case we are assigning an existing network to the vApp, and in the other we are creating a vApp network.
I think the name in this case should be CreateVappNetwork
or AddVappNetwork
to avoid confusion
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.
@Didainius what is your vote for naming?
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.
We are creating a new network here so probably CreateVappNetwork
.
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.
renamed
govcd/vapp.go
Outdated
return vAppNetworkConfig, nil | ||
} | ||
|
||
// RemoveNetworkAsync asyncronously removes any network (be it isolated or connected to an Org Network) from vApp |
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.
// RemoveNetworkAsync asyncronously removes any network (be it isolated or connected to an Org Network) from vApp | |
// RemoveNetworkAsync asynchronously removes any network (be it isolated or connected to an Org Network) from vApp |
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. updated
govcd/vapp.go
Outdated
return vAppNetworkConfig, nil | ||
} | ||
|
||
// AddNetworkAsync creates asyncronously isolated or nat routed network for vApp. Returns Task or error |
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.
// AddNetworkAsync creates asyncronously isolated or nat routed network for vApp. Returns Task or error | |
// AddNetworkAsync creates asynchronously isolated or nat routed network for vApp. Returns Task or error |
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. updated
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
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.
Few last comments from me.
Thanks for test fixes
govcd/vapp.go
Outdated
@@ -786,6 +798,329 @@ func (vapp *VApp) AddIsolatedNetwork(newIsolatedNetworkSettings *VappNetworkSett | |||
|
|||
} | |||
|
|||
// AddNetwork creates isolated or nat routed(connected to Org VDC network) network for vApp. |
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.
We are creating a new network here so probably CreateVappNetwork
.
Signed-off-by: Vaidotas Bauzys <[email protected]>
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 fixes.
Signed-off-by: Vaidotas Bauzys <[email protected]>
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
Add new function need for handling vApp networks: