Skip to content

[wip] FWaaS v2.0 Rule Create#1768

Merged
jtopjian merged 8 commits intogophercloud:masterfrom
Elethiomel:fwaasv2_rule_create
Nov 19, 2019
Merged

[wip] FWaaS v2.0 Rule Create#1768
jtopjian merged 8 commits intogophercloud:masterfrom
Elethiomel:fwaasv2_rule_create

Conversation

@Elethiomel
Copy link
Copy Markdown
Contributor

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 14, 2019

Coverage Status

Coverage increased (+0.2%) to 76.97% when pulling f2ca260 on Elethiomel:fwaasv2_rule_create into b311dd7 on gophercloud:master.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Nov 14, 2019

Build succeeded.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

@Elethiomel Thanks for continuing to look into this. Overall this looks good. I've left a few comments. In addition, I'd still like to see some acceptance tests added. It should be pretty easy to mirror the current fwaas tests and modify for fwaasv2 - I'd be happy to help if needed.

Please let me know if you have any questions.

// CreateOpts contains all the values needed to create a new firewall rule.
type CreateOpts struct {
Protocol Protocol `json:"protocol" required:"true"`
Action string `json:"action" required:"true"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great idea :) I've added this in commit c677015

DestinationPort string `json:"destination_port,omitempty"`
Shared bool `json:"shared,omitempty"`
Enabled bool `json:"enabled,omitempty"`
PolicyID string `json:"firewall_policy_id"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FirewallPolicyID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've made this change in commit 19de2bd

Shared bool `json:"shared,omitempty"`
Enabled bool `json:"enabled,omitempty"`
PolicyID string `json:"firewall_policy_id"`
Position int `json:"position"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm unable to tell how this field is added to the result here: https://github.com/openstack/neutron-fwaas/blob/27906d0acff349c9e5ac7955d203fb2233c295db/neutron_fwaas/db/firewall/v2/firewall_db_v2.py#L269

Can you verify this field is really part of the JSON result?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well spotted! I've verified that it's not. Removed in commit f1ad97e

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The JSON result is also returning project_id, so I've added this in commit be00d44

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Nov 15, 2019

Build succeeded.

@Elethiomel
Copy link
Copy Markdown
Contributor Author

@jtopjian commit ee2fb65 introduces an acceptance test for creating a rule, but the test is currently failing with a rather odd error... Any suggestion appreciated :)

$ go test -tags fwaas_v2 . --- FAIL: TestRuleC (0.60s) fwaas_v2.go:24: Attempting to create rule TESTACC-6t7dLduz with source 192.168.1.73:73 and destination 192.168.2.73:73 fwaas_v2.go:42: Rule TESTACC-6t7dLduz successfully created convenience.go:35: Failure in fwaas_v2.go, line 45: expected "tcp" but got "tcp" FAIL FAIL github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/fwaas_v2 0.601s

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Nov 15, 2019

Build succeeded.

@jtopjian
Copy link
Copy Markdown
Contributor

Nice work :)

The error is because you're comparing a string "tcp" with the Protocol type "tcp". There are two ways to resolve this:

th.AssertEquals(t, rule.Protocol, "tcp")
th.AssertEquals(t, rule.Action, "allow")

or

th.AssertEquals(t, rule.Protocol, string(rules.ProtocolTCP))
th.AssertEquals(t, rule.Action, string(rules.ActionAllow))  

@Elethiomel
Copy link
Copy Markdown
Contributor Author

@jtopjian Whoops! Thanks for the help :) Fixed in f2ca260

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented Nov 18, 2019

Build succeeded.

@Elethiomel
Copy link
Copy Markdown
Contributor Author

@jtopjian What's the etiquette here in gophercloud dev land? Should I close off the changes requested or should I leave it to you?

@jtopjian
Copy link
Copy Markdown
Contributor

What's the etiquette here in gophercloud dev land? Should I close off the changes requested or should I leave it to you?

That's all on me. Sorry for the delay.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

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

LGTM - thank you!

@jtopjian jtopjian merged commit d8a57ca into gophercloud:master Nov 19, 2019
@Elethiomel Elethiomel deleted the fwaasv2_rule_create branch December 2, 2019 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants