synackray / vcenter-netbox-sync

Sync objects between vCenter and Netbox via Python3
Apache License 2.0
108 stars 28 forks source link

Sync only prefix related ip-addresses #106

Open inetman28 opened 4 years ago

inetman28 commented 4 years ago

Is your feature request related to a problem? Please describe. We must manually fill up ip-list IPV4-ALLOWED (IPV6-ALLOWED)

Describe the solution you'd like In some environment like own I already have fill up ip-prefixes in netbox. We can automate it and do not fill up ip-list manually.

synackray commented 4 years ago

@inetman28 Hello! How would you prefer this is automated? Are you suggesting that all prefixes which exist already inside the NetBox instance would be permitted and anything not created there would be ignored?

inetman28 commented 4 years ago

@inetman28 Hello! How would you prefer this is automated? Are you suggesting that all prefixes which exist already inside the NetBox instance would be permitted and anything not created there would be ignored?

Yes, you are right. I mean something like this:

import pynetbox

IPV4_ALLOWED = []
IPV6_ALLOWED = []
all_prefixes = nb.ipam.prefixes.all()
for prefix in all_prefixes:
    if prefix.family.value == 4:
        IPV4_ALLOWED.append(prefix.prefix)
    elif prefix.family.value == 6:
        IPV6_ALLOWED.append(prefix.prefix)