Replies: 7 comments 7 replies
-
I think that would require something like JSONNET instead of JSON - or to be able to provide custom code for the merging function. |
Beta Was this translation helpful? Give feedback.
-
I have a similar problem. I use a Netbox to Zabbix integration and it uses config context to list what management templates to add to an object in Zabbix. Normally, for devices, we use to factors to decide what templates to use and that is device type and role. Device type 1 {
"zabbix" {
"templates": [
"Template dev-type 1"
]
}
} Role 1 {
"zabbix" {
"templates": [
"Template role 1"
]
}
} Devices of type 1 with role 1 {
"zabbix" {
"templates": [
"Template dev-type 1",
"Template role 1"
]
}
} |
Beta Was this translation helpful? Give feedback.
-
There are multiple use cases for the so what your saying is have config context sprawl, or do the config management outside netbox. Kind of defeats the point of the config context feature.
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Brian Candler ***@***.***>
Sent: Saturday, June 3, 2023 5:36:07 PM
To: netbox-community/netbox ***@***.***>
Cc: Damo Dye ***@***.***>; Author ***@***.***>
Subject: Re: [netbox-community/netbox] concatinating json arrays (Discussion #12719)
You could do this by having "device_role_templates" and "device_type_templates" and combining them externally in your Zabbix integration.
—
Reply to this email directly, view it on GitHub<#12719 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKPM7ZA2EIOMROT5TFJ74O3XJNRXPANCNFSM6AAAAAAYZH3YZQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I could but the integration is also a python package from Internet and changing the code either in Netbox or in the Zabbix-Netbox isn’t desirable.
I rather discuss a change in Netbox to become even better.
MHV
/Anders Hagman
… 3 juni 2023 kl. 18:36 skrev Brian Candler ***@***.***>:
You could do this by having "device_role_templates" and "device_type_templates" and combining them externally in your Zabbix integration.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
This is definitely in netbox, when you do to the device context tab on a device or VM. The issue is netbox replaces the config in that context rather than combine as such this is a netbox defect because it correctly combines keys on 1st level objects. So why have to do the rest outside by having to make multiple API call to get round the a incorrect calculation on the main object is a netbox issue. Either that or the documentation needs to reflect that this feature is limited only works on 1 level object keys, not with arrays or sub objects as they are taken as a key and replaced as a redeclaration rather than follow the same behaviour of 1st level keys which only replaces values but combines the object.
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: andershagman ***@***.***>
Sent: Saturday, June 3, 2023 7:13:55 PM
To: netbox-community/netbox ***@***.***>
Cc: Damo Dye ***@***.***>; Author ***@***.***>
Subject: Re: [netbox-community/netbox] concatinating json arrays (Discussion #12719)
I could but the integration is also a python package from Internet and changing the code either in Netbox or in the Zabbix-Netbox isn’t desirable.
I rather discuss a change in Netbox to become even better.
MHV
/Anders Hagman
3 juni 2023 kl. 18:36 skrev Brian Candler ***@***.***>:
You could do this by having "device_role_templates" and "device_type_templates" and combining them externally in your Zabbix integration.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
—
Reply to this email directly, view it on GitHub<#12719 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKPM7ZCQXLAUGGRZE5RFYY3XJN5GHANCNFSM6AAAAAAYZH3YZQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
You are right. There are conflicts but we have weight.
Example:
Same weight - append
Different weight - overwrite
Device local - overwrite
MHV
/Anders Hagman
… 3 juni 2023 kl. 21:12 skrev Brian Candler ***@***.***>:
I rather discuss a change in Netbox to become even better.
The trouble is, I don't think there's a new behaviour which is unambiguously "better" in all cases for merging raw JSON objects.
Say for example, at one level I have "dns_servers": ["8.8.8.8","8.8.4.4"]. At another level, I want to override this with "dns_servers": ["1.1.1.1","1.0.0.1"]. I don't want them to be merged into a list of 4 dns servers.
Therefore, I think the starting point would be to dinfe exactly what semantics you want 'object merge' to have, and exactly what extra knobs or configuration settings you want to have, so that it doesn't break existing users of config contexts.
This is a problem which other projects have found complex to solve. For example in kubernetes / kustomize there is inline patch, strategic merge patch, and JSON patch (RFC6902). Another solution would be to use JSONNET instead of JSON.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
Am happy with that approach as logically that works fine to resolve the conflicts
Sent from Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: andershagman ***@***.***>
Sent: Saturday, June 3, 2023 9:14:25 PM
To: netbox-community/netbox ***@***.***>
Cc: Damo Dye ***@***.***>; Author ***@***.***>
Subject: Re: [netbox-community/netbox] concatinating json arrays (Discussion #12719)
You are right. There are conflicts but we have weight.
Example:
Same weight - append
Different weight - overwrite
Device local - overwrite
MHV
/Anders Hagman
3 juni 2023 kl. 21:12 skrev Brian Candler ***@***.***>:
I rather discuss a change in Netbox to become even better.
The trouble is, I don't think there's a new behaviour which is unambiguously "better" in all cases for merging raw JSON objects.
Say for example, at one level I have "dns_servers": ["8.8.8.8","8.8.4.4"]. At another level, I want to override this with "dns_servers": ["1.1.1.1","1.0.0.1"]. I don't want them to be merged into a list of 4 dns servers.
Therefore, I think the starting point would be to dinfe exactly what semantics you want 'object merge' to have, and exactly what extra knobs or configuration settings you want to have, so that it doesn't break existing users of config contexts.
This is a problem which other projects have found complex to solve. For example in kubernetes / kustomize there is inline patch, strategic merge patch, and JSON patch (RFC6902). Another solution would be to use JSONNET instead of JSON.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
—
Reply to this email directly, view it on GitHub<#12719 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKPM7ZHHIHUSL64KWZNRF2LXJOLKDANCNFSM6AAAAAAYZH3YZQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
NetBox version
V3.51
Feature type
Change to existing functionality
Proposed functionality
would it be possible to combine values in a json array like it is possible to combine json object attributes.
example
have a config context with
and a second one with
desired outcome is
Use case
this would allow for adding rules based on properties in which both the MSP and the Tenant could need sudo access for instance
Database changes
No response
External dependencies
No response
Beta Was this translation helpful? Give feedback.
All reactions