-
Notifications
You must be signed in to change notification settings - Fork 510
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
Vpnaas: Create VPN service #760
Conversation
Build succeeded.
|
Build succeeded.
|
@jtopjian This is ready for review |
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.
@simonre Thank you for working on this. This is a really good start.
In general, everything looks good. I've left some comments for some minor changes.
This PR will need two additional items before it can be merged:
- A
doc.go
file similar to this. - An acceptance test. Documentation for acceptance tests can be found here. You can use the existing networking tests as an example.
Please let me know if you have any questions or need any help.
} | ||
|
||
// CreateOpts contains all the values needed to create a new VPN service | ||
type CreateOpts struct { |
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.
doc nit: all fields should have a descriptive comment even if it's something simple like:
Name is the human-readable name of the VPN Service.
RouterID string `json:"router_id" required:"true"` | ||
Description string `json:"description,omitempty"` | ||
AdminStateUp *bool `json:"admin_state_up"` | ||
ProjectID string `json:"project_id"` |
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 don't see project_id
defined anywhere here, so maybe it's an internal neutron field? What happens if TenantID
and ProjectID
are different UUIDs?
// CreateOptsBuilder allows extensions to add additional parameters to the | ||
// Create request. | ||
type CreateOptsBuilder interface { | ||
ToVPNServiceCreateMap() (map[string]interface{}, 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.
This should be ToServiceCreateMap
.
} | ||
|
||
// ToVPNServiceCreateMap casts a CreateOpts struct to a map. | ||
func (opts CreateOpts) ToVPNServiceCreateMap() (map[string]interface{}, 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.
ToServiceCreateMap
) | ||
|
||
// Service is a VPN Service | ||
type Service struct { |
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.
doc nit: these fields should have comments to describe what they are.
// Service is a VPN Service | ||
type Service struct { | ||
TenantID string `json:"tenant_id"` | ||
SubnetID string `json:"subnet_id,omitempty"` |
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.
omitempty
isn't valid for results. it can safely be removed.
Build failed.
|
@simonre Thank you for the updates. Travis is failing due to some The OpenLab failures were a temporary issue with the CI system. I wouldn't worry about those. |
@simonre Thank you again for the updates. This looks good to me. Unfortunately I can't test this myself since I don't have access to VPNaaS, but from reviewing the Neutron code, this looks correct. In addition, the acceptance test looks correct, too. Can you verify that this code works? Meaning: have you tested it yourself to create an actual VPN service? If it works for you, I'll go ahead and merge this. The inline comments/docs could use some formatting, but I don't consider doc updates to be blocking unless there are other changes required. If you plan on continuing to work on the other parts of the VPNaaS, then maybe fix them there. You can use this file for reference (or really any of the The reason we want to make sure formatting is correct is because the inline comments turn into the official godoc reference documentation. |
Build succeeded.
|
…me formatting on inline comments
@jtopjian Thanks for the quick feedback. I just updated the doc.go sample code to code that I can verify worked for me to create an actual VPN service. I also updated the inline formatting in requests.go, is that what you had in mind? If yes, I'll keep that in mind for the rest of the code and I'll update the other files as well! |
Build succeeded.
|
Yep - That's exactly what I had in mind. Though the same format should be applied to the
Perfect - thank you 😄 |
I'll fix it now. Just wanted to make sure I'm actually doing the right thing before doing it for all files. |
@simonre I apologize - I missed one thing in the unit tests: There should be a comparison to the struct that is returned from the Create / Extract call: expected := services.Service{
RouterID: "66e3b16c-8ce5-40fb-bb49-ab6d8dc3f2aa",
...
}
actual, err := services.Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, expected, actual) This same pattern will need to be in the other unit tests (where applicable), so best to get in the habit now :) |
Build succeeded.
|
Build succeeded.
|
@simonre We definitely want to ensure a struct can be compared successfully, and not just individual fields. Using "networks" as an example, the However, the CreateOpts Unless there's a good reason to keep the result field as |
…rison. Also changed AdminStateUp type from *bool to bool
Build succeeded.
|
@jtopjian You're right. I changed it again. I also did the same in the ipsecpolicy branch. |
@simonre This looks good to me. Thank you very much for your help and patience. |
For #723
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
API:
https://developer.openstack.org/api-ref/network/v2/#create-vpn-service