You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are saying that the openstack CLI is converting "any" to null.
However, the docs explicitly mention that "any" is like 0, and seem to imply that not passing the property (or passing null as a value) has the same effect. That is, applying the security group rule regardless of the protocol.
What improvement do you expect once Gophercloud sends nullinstead of "any" to the Neutron API?
Hi, general in wiki 0 protocol is valid number for IPv6 Hop-by-Hop Option
So far I found in horizon valid also -1 (instead of openstack cli) and it's the correct way but different endpoint is used (/project/security_groups/9c516eff-e9d0-4fea-8bd5-424d1e4dd726/add_rule/):
RuleProtocol is a string in Gopherloud; using nil will simply not compile. If you need to pass null (or to not pass the property), you can override the property in a custom CreateOpts:
EDIT: see below. The example that was here was not useful
Note that if you find a functional reason to do that, we might as well change Protocol to be a pointer in v3 to accomodate for a nil value. Or maybe, rather, raise a bug in Neutron about it.
There is a way to implement an own CreateOptsBuilder interface that does this. It could be done in openstack terraform provider as well, without dependencies from gophercloud.
I fear it won't be fixed, because it's not a bug for python, only problem for typization in go.
Correct way is to add in gophercloud supporting passing nil value in json body
I will assume you mean null in the JSON body.
Can you please explain why you say that null would be the correct value of protocol when you want to create a security group rule that applies to all protocols?
Can you please explain why you say that null would be the correct value of protocol when you want to create a security group rule that applies to all protocols?
I have checked in openstack, when you push 0 and null in field protocol it's different results.
Based on my current understanding of the issue (which I ideally want confirmed by the Neutron team), you can use Gophercloud to create a rule that applies regardless of the protocol, by not setting the Protocol property:
Not setting Property means that you implicitly set it to the zero value for the type, which is not sent over the wire by default. Not sending it seems to be equivalent to sending null.
This is the code with which I have tested that protocol is not sent when not set in Gophercloud:
There are further issues with listing, and as @kayrus notes, comparing rules with each other.
Listing all rules that apply to any protocol is tricky because based on how the rule was created, the value of protocol can either be 0, null or "". Filtering by 0 will only return the first case. Filtering by the empty string might work, but I haven't tried. Good luck with filtering by null against the HTTP API.
Comparing is something Gophercloud might assist with, by artificially setting a well-known value (like "") when getting any of the three possible values from Neutron. I am not 100% convinced by this solution, because a user might want the raw response in some cases.
I really look forward to an answer by the Neutron folks, if we ever get one.
Without any change in Gophercloud, you can already achieve what you want by not setting the Property value of RuleCreateOpts
I guess we need documentation for "hack" to know how it can go in terraform provider as well when protocol can be null, "" or omitted to have "what ever protocol"
I really look forward to an answer by the Neutron folks, if we ever get one.
Even if they fix this bug to use protocol -1 for example explicitly it will be not so fast :(
Even if they fix this bug to use protocol -1 for example explicitly it will be not so fast :(
To be honest my ask is just that the API documentation be amended with one recommended (and working) way to set "all protocols".
If they really want to go the extra mile, they could make it so that whatever value of protocol you use to say "any", it is persisted the same way. But from the Gophercloud point of view that's not very relevant for now, as we will continue supporting old (unfixed) versions for a long time.
Why would protocol not be optional any more? Not setting it is exactly like setting "": it will be omitted in the call. If you don't set a protocol, then it's "any"... exactly like in the HTTP API.
Regarding the numeric protocols: I have tried using curl to send numbers in strings (e.g. "6" for TCP) and Neutron seems to be fine with it. Which means that you can already send numeric protocols with Gophercloud like this:
Activity
pierreprinetti commentedon Jul 19, 2024
You are saying that the openstack CLI is converting
"any"tonull.However, the docs explicitly mention that
"any"is like0, and seem to imply that not passing the property (or passingnullas a value) has the same effect. That is, applying the security group rule regardless of the protocol.What improvement do you expect once Gophercloud sends
nullinstead of"any"to the Neutron API?HappyFX commentedon Jul 20, 2024
Hi, general in wiki 0 protocol is valid number for
IPv6 Hop-by-Hop OptionSo far I found in horizon valid also
-1(instead of openstack cli) and it's the correct way but different endpoint is used (/project/security_groups/9c516eff-e9d0-4fea-8bd5-424d1e4dd726/add_rule/):For
anyand0results are different in database0:any:-1:HappyFX commentedon Jul 20, 2024
In terraform provider no option to create security group with protocol "any" - please see the issue
pierreprinetti commentedon Jul 21, 2024
RuleProtocolis a string in Gopherloud; usingnilwill simply not compile. If you need to passnull(or to not pass the property), you can override the property in a custom CreateOpts:EDIT: see below. The example that was here was not useful
Note that if you find a functional reason to do that, we might as well change
Protocolto be a pointer inv3to accomodate for a nil value. Or maybe, rather, raise a bug in Neutron about it.HappyFX commentedon Jul 24, 2024
I fear it won't be fixed, because it's not a bug for python, only problem for typization in go.
Correct way is to add in gophercloud supporting passing
nilvalue in json bodykayrus commentedon Jul 24, 2024
There is a way to implement an own
CreateOptsBuilderinterface that does this. It could be done in openstack terraform provider as well, without dependencies from gophercloud.pierreprinetti commentedon Jul 24, 2024
There you go:
fix: create security group rule with any protocol
pierreprinetti commentedon Jul 24, 2024
I will assume you mean
nullin the JSON body.Can you please explain why you say that
nullwould be the correct value ofprotocolwhen you want to create a security group rule that applies to all protocols?The documentation of the Neutron API clearly states:
HappyFX commentedon Jul 24, 2024
I have checked in openstack, when you push
0andnullin fieldprotocolit's different results.Also it's looks like a bug in documentation openstack about 0 is any. Take a look in openstack python client converting
anytonullCheck neutron lib it's also bug with two valid NUM for
0:and I have created in my openstack two groups. One with
nulland one with0.With
0- not working, withnullworking. In web interface looks like:HappyFX commentedon Jul 24, 2024
I have managed to record gif, if no access to running openstack.

pierreprinetti commentedon Jul 25, 2024
OK I may have found the problem you want to fix.
I have tried creating a group and a rule with this code:
And what I got is this error message:
pierreprinetti commentedon Jul 25, 2024
I have filed this bug against Neutron: https://bugs.launchpad.net/neutron/+bug/2074056
Based on my current understanding of the issue (which I ideally want confirmed by the Neutron team), you can use Gophercloud to create a rule that applies regardless of the protocol, by not setting the
Protocolproperty:Not setting
Propertymeans that you implicitly set it to the zero value for the type, which is not sent over the wire by default. Not sending it seems to be equivalent to sendingnull.This is the code with which I have tested that
protocolis not sent when not set in Gophercloud:Based on my findings:
Propertyvalue ofRuleCreateOpts.rules.ProtocolAnydoes not work, and we will need to address the problem to avoid confusion.@HappyFX @kmlebedev thoughts?
pierreprinetti commentedon Jul 25, 2024
There are further issues with listing, and as @kayrus notes, comparing rules with each other.
Listing all rules that apply to any protocol is tricky because based on how the rule was created, the value of
protocolcan either be0,nullor"". Filtering by0will only return the first case. Filtering by the empty string might work, but I haven't tried. Good luck with filtering bynullagainst the HTTP API.Comparing is something Gophercloud might assist with, by artificially setting a well-known value (like
"") when getting any of the three possible values from Neutron. I am not 100% convinced by this solution, because a user might want the raw response in some cases.I really look forward to an answer by the Neutron folks, if we ever get one.
HappyFX commentedon Jul 25, 2024
I guess we need documentation for "hack" to know how it can go in terraform provider as well when
protocolcan benull,""or omitted to have "what ever protocol"Even if they fix this bug to use protocol
-1for example explicitly it will be not so fast :(pierreprinetti commentedon Jul 25, 2024
@HappyFX
To be honest my ask is just that the API documentation be amended with one recommended (and working) way to set "all protocols".
If they really want to go the extra mile, they could make it so that whatever value of
protocolyou use to say "any", it is persisted the same way. But from the Gophercloud point of view that's not very relevant for now, as we will continue supporting old (unfixed) versions for a long time.HappyFX commentedon Jul 25, 2024
For now:
protocol==anyprotocol = "0"==protocol = 0x00it'sHOPOPTand not act asanyprotocol = null==anyTo clear all this cases and make it obvious, I suggest:
protocolno more optionalany0) are still valid and act as it waspierreprinetti commentedon Jul 26, 2024
Why would
protocolnot be optional any more? Not setting it is exactly like setting"": it will be omitted in the call. If you don't set a protocol, then it's "any"... exactly like in the HTTP API.Regarding the numeric protocols: I have tried using curl to send numbers in strings (e.g.
"6"for TCP) and Neutron seems to be fine with it. Which means that you can already send numeric protocols with Gophercloud like this:fix: create security group rule with any protocol