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

Rename index_string to index:str2num #15916

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PipoCanaja
Copy link
Contributor

@PipoCanaja PipoCanaja commented Apr 1, 2024

Renaming index_string to a more self explanatory index:str2num. Documentation also updated.

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@PipoCanaja PipoCanaja self-assigned this Apr 1, 2024
Copy link
Member

@murrant murrant left a comment

Choose a reason for hiding this comment

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

you shouldn't use a colin like that as it is already used for other things

@PipoCanaja
Copy link
Contributor Author

you shouldn't use a colin like that as it is already used for other things

I also thought of str2num($index) which would lead to {{ str2num($index) }} in the YAML file. It is a little bit long but at least it means "feed current index variable to a str2num function" which is basically what we do here.

What would you suggest ?

@murrant
Copy link
Member

murrant commented Apr 15, 2024

That makes it look like you can run functions inside {{}}, which we don't want to indicate.

str_index_as_numeric ?

Question, should $index always be numeric?

maybe we delete this and always convert strings in an index to numeric for $index?

I think the main trick with this is enum in index. But those should be displayed differently I think:
.3.enum.0 vs .3."string".0

@PipoCanaja
Copy link
Contributor Author

That makes it look like you can run functions inside {{}}, which we don't want to indicate.

str_index_as_numeric ?
Why not. I prefered the look of the original one, but clearly this one does not lead to confusion with functions and will (very probably) never collision with a real OID (so many underscores :) ), so good candidate.

Question, should $index always be numeric?
maybe we delete this and always convert strings in an index to numeric for $index?
I think the main trick with this is enum in index. But those should be displayed differently I think: .3.enum.0 vs .3."string".0
There is no way to differentiate an enum from a numerical OID if the enum is only made of digits so it would probably break thinks here.
Basically, if we had a way to get data out of snmpwalk/get in a clean and typed datastructure (like a JSON reply with both row SNMP oid and reply, as well as all the type magic that is taken from the MIB, instead of the text that is not parsable in a safe and reproductible way). But that does not exist ...

I'll go with str_index_as_numeric asap and update here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants