dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
84 stars 14 forks source link

pyVmomi ingest vm ip address #94

Closed dietybright closed 9 months ago

dietybright commented 9 months ago

From the log I saw pyVmomi able to discover vm ip address with key "guest_address". Is it able to ingest to Netbox with vm ip address?

dainok commented 9 months ago

No because it's missing the netmask/prefixlength (hope I can remember correctly).

dietybright commented 9 months ago

Got it, appreciated if you could ingest ip address with all /32 to netbox, it would be appeared to IPAM under major prefix, easy for tracking all IPAM at least

dainok commented 9 months ago

It's better to integrate a script polling operating system. Linux is already supported. The reason is that I don't want to ingest partial or wrong information to NetBox. But... you can implement custom scripts if you think that it's useful for you.

dietybright commented 9 months ago

Hi @dainok ,

With .guest.net, it can polling out data macaddress, ipaddress, prefixlength of each nic. I am not familar with coding, still try to explore the script, hope if you can have a look on it.

For exp:

print(vm[38].guest.net)
(vim.vm.GuestInfo.NicInfo) [ (vim.vm.GuestInfo.NicInfo) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], network = '', ipAddress = (str) [ '192.168.x.136', 'fe80::250:56ff:fe8a:6414' ], macAddress = '00:50:56:8a:64:14', connected = true, deviceConfigId = 4000, dnsConfig = , ipConfig = (vim.net.IpConfigInfo) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = (vim.net.IpConfigInfo.IpAddress) [ (vim.net.IpConfigInfo.IpAddress) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = '192.168.x.136', prefixLength = 26, origin = , state = 'preferred', lifetime = }, (vim.net.IpConfigInfo.IpAddress) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = 'fe80::250:56ff:fe8a:6414', prefixLength = 64, origin = , state = 'unknown', lifetime = } ], dhcp = , autoConfigurationEnabled = }, netBIOSConfig = }, (vim.vm.GuestInfo.NicInfo) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], network = '', ipAddress = (str) [ '42.116.x.238', 'fe80::250:56ff:fe8a:c5ab' ], macAddress = '00:50:56:8a:c5:ab', connected = true, deviceConfigId = 4001, dnsConfig = , ipConfig = (vim.net.IpConfigInfo) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = (vim.net.IpConfigInfo.IpAddress) [ (vim.net.IpConfigInfo.IpAddress) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = '42.116.x.238', prefixLength = 29, origin = , state = 'preferred', lifetime = }, (vim.net.IpConfigInfo.IpAddress) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], ipAddress = 'fe80::250:56ff:fe8a:c5ab', prefixLength = 64, origin = , state = 'unknown', lifetime = } ], dhcp = , autoConfigurationEnabled = }, netBIOSConfig = } ]

dietybright commented 9 months ago

Hi @dainok ,

I have modified your discovery pyvmomi script to get ipaddress and prefixmask, then ingest to netbox with data_vm_interface with value "address" but there is an issue "unexpected keyword arguments: 'address'".

Seem address of vm interface need to ingest under IPAM or something, would you mind to have a look?