Giter Club home page Giter Club logo

netbox-sync's Introduction

NetBox-Sync

This is a tool to sync data from different sources to a NetBox instance.

Available source types:

IMPORTANT: READ INSTRUCTIONS CAREFULLY BEFORE RUNNING THIS PROGRAM

Thanks

A BIG thank-you goes out to Raymond Beaudoin for creating vcenter-netbox-sync which served as source of a lot of ideas for this project.

Principles

copied from Raymond Beaudoin

The NetBox documentation makes it clear the tool is intended to act as a "Source of Truth". The automated import of live network state is strongly discouraged. While this is sound logic we've aimed to provide a middle-ground solution for those who desire the functionality.

All objects collected from vCenter have a "lifecycle". Upon import, for supported object types, they are tagged NetBox-synced to note their origin and distinguish them from other objects. Using this tagging system also allows for the orphaning of objects which are no longer detected in vCenter. This ensures stale objects are removed from NetBox keeping an accurate current state.

Requirements

Software

  • python >= 3.6
  • packaging
  • urllib3==1.26.9
  • wheel
  • requests==2.27.1
  • pyvmomi==7.0.3
  • aiodns==2.0.0
  • setuptools>=62.00.0
  • pyyaml==6.0

Environment

  • NetBox >= 2.9

Source: VMWare (if used)

  • VMWare vCenter >= 6.0

Source: check_redfish (if used)

  • check_redfish >= 1.2.0

Installing

  • here we assume we install in /opt

RedHat based OS

  • on RedHat/CentOS 7 you need to install python3.6 and pip from EPEL first
  • on RedHat/CentOS 8 systems the package name changed to python3-pip
yum install python36-pip

Ubuntu 18.04 & 20.04 && 22.04

apt-get update && apt-get install python3-venv

Clone repo and install dependencies

  • If you need to use python 3.6 then you would need requirements_3.6.txt to install requirements
  • download and setup of virtual environment
cd /opt
git clone https://github.com/bb-Ricardo/netbox-sync.git
cd netbox-sync
python3 -m venv .venv
. .venv/bin/activate
pip3 install --upgrade pip || pip install --upgrade pip
pip3 install wheel || pip install wheel
pip3 install -r requirements.txt || pip install -r requirements.txt

VMware tag sync (if necessary)

The vsphere-automation-sdk must be installed if tags should be synced from vCenter to NetBox

  • assuming we are still in an activated virtual env
pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git

NetBox API token

In order to updated data in NetBox you need a NetBox API token.

  • API token with all permissions (read, write) except:
    • auth
    • secrets
    • users

A short description can be found here

Running the script

usage: netbox-sync.py [-h] [-c settings.ini [settings.ini ...]] [-g]
                      [-l {DEBUG3,DEBUG2,DEBUG,INFO,WARNING,ERROR}] [-n] [-p]

Sync objects from various sources to NetBox

Version: 1.6.1 (2024-05-14)
Project URL: https://github.com/bb-ricardo/netbox-sync

options:
  -h, --help            show this help message and exit
  -c settings.ini [settings.ini ...], --config settings.ini [settings.ini ...]
                        points to the config file to read config data from
                        which is not installed under the default path
                        './settings.ini'
  -g, --generate_config
                        generates default config file.
  -l {DEBUG3,DEBUG2,DEBUG,INFO,WARNING,ERROR}, --log_level {DEBUG3,DEBUG2,DEBUG,INFO,WARNING,ERROR}
                        set log level (overrides config)
  -n, --dry_run         Operate as usual but don't change anything in NetBox.
                        Great if you want to test and see what would be
                        changed.
  -p, --purge           Remove (almost) all synced objects which were create
                        by this script. This is helpful if you want to start
                        fresh or stop using this script.

TESTING

It is recommended to set log level to DEBUG2 this way the program should tell you what is happening and why. Also use the dry run option -n at the beginning to avoid changes directly in NetBox.

Configuration

There are two ways to define configuration. Any combination of config file(s) and environment variables is possible.

  • config files (the default config file name is set to ./settings.ini.)
  • environment variables

The config from the environment variables will have precedence over the config file definitions.

Config files

Following config file types are supported:

  • ini
  • yaml

There is also more than one config file permitted. Example (config file names are also just examples):

/opt/netbox-sync/netbox-sync.py -c common.ini all-sources.yaml additional-config.yaml

All files are parsed in order of the definition and options will overwrite the same options if defined in a previous config file.

To get config file examples which include descriptions and all default values, the -g can be used:

# this will create an ini example
/opt/netbox-sync/netbox-sync.py -g -c settings-example.ini

# and this will create an example config file in yaml format
/opt/netbox-sync/netbox-sync.py -g -c settings-example.yaml 

Environment variables

Each setting which can be defined in a config file can also be defined using an environment variable.

The prefix for all environment variables to be used in netbox-sync is: NBS

For configuration in the common and netbox section a variable is defined like this

<PREFIX>_<SECTION_NAME>_<CONFIG_OPTION_KEY>=value

Following example represents the same configuration:

# yaml config example
common:
  log_level: DEBUG2
netbox:
  host_fqdn: netbox-host.example.com
  prune_enabled: true
# this variable definition is equal to the yaml config sample above
NBS_COMMON_LOG_LEVEL="DEBUG2"
NBS_netbox_host_fqdn="netbox-host.example.com"
NBS_NETBOX_PRUNE_ENABLED="true"

This way it is possible to expose for example the NBS_NETBOX_API_KEY only via an env variable.

The config definitions for sources need to be defined using an index. Following conditions apply:

  • a single source needs to use the same index
  • the index can be number or a name (but contain any special characters to support env var parsing)
  • the source needs to be named with _NAME variable

Example of defining a source with config and environment variables.

; example for a source
[source/example-vcenter]
enabled = True
type = vmware
host_fqdn = vcenter.example.com
username = vcenter-readonly
# define the password on command line
# here we use '1' as index
NBS_SOURCE_1_NAME="example-vcenter"
NBS_SOURCE_1_PASSWORD="super-secret-and-not-saved-to-the-config-file"
NBS_SOURCE_1_custom_dns_servers="10.0.23.23, 10.0.42.42"

Even to just define one source variable like NBS_SOURCE_1_PASSWORD the NBS_SOURCE_1_NAME needs to be defined as to associate to the according source definition.

Cron job

In Order to sync all items regularly you can add a cron job like this one

 # NetBox Sync
 23 */2 * * *  /opt/netbox-sync/.venv/bin/python3 /opt/netbox-sync/netbox-sync.py >/dev/null 2>&1

Docker

Run the application in a docker container. You can build it yourself or use the ones from docker hub.

Available here: bbricardo/netbox-sync

  • The application working directory is /app
  • Required to mount your settings.ini

To build it by yourself just run:

docker build -t bbricardo/netbox-sync:latest .

To start the container just use:

docker run --rm -it -v $(pwd)/settings.ini:/app/settings.ini bbricardo/netbox-sync:latest

Kubernetes

Run the containerized application in a kubernetes cluster

  • Create a config map with the default settings
  • Create a secret witch only contains the credentials needed
  • Adjust the provided cronjob resource to your needs
  • Deploy the manifest to your k8s cluster and check the job is running

config example saved as settings.yaml

netbox:
  host_fqdn: netbox.example.com

source:
  my-vcenter-example:
    type: vmware
    host_fqdn: vcenter.example.com
    permitted_subnets: 172.16.0.0/12, 10.0.0.0/8, 192.168.0.0/16, fd00::/8
    cluster_site_relation: Cluster_NYC = New York, Cluster_FFM.* = Frankfurt, Datacenter_TOKIO/.* = Tokio

secrets example saved as secrets.yaml

netbox:
  api_token: XYZXYZXYZXYZXYZXYZXYZXYZ
source:
  my-vcenter-example:
    username: vcenter-readonly
    password: super-secret

Create resource in your k8s cluster

kubectl create configmap netbox-sync-config --from-file=settings.yaml
kubectl create secret generic netbox-sync-secrets --from-file=secrets.yaml
kubectl apply -f k8s-netbox-sync-cronjob.yaml

How it works

READ CAREFULLY

Basic structure

The program operates mainly like this

  1. parsing and validating config
  2. instantiating all sources and setting up connection to NetBox
  3. read current data from NetBox
  4. read data from all sources and add/update objects in memory
  5. Update data in NetBox based on data from sources
  6. Prune old objects

NetBox connection

Request all current NetBox objects. Use caching whenever possible. Objects must provide "last_updated" attribute to support caching for this object type.

Actually perform the request and retry x times if request times out. Program will exit if all retries failed!

Supported sources

Check out the documentations for the different sources

If you have multiple vCenter instances or check_redfish folders just add another source with the same type in the same file.

Example:

[source/vcenter-BLN]

enabled = True
host_fqdn = vcenter1.berlin.example.com

[source/vcenter-NYC]

enabled = True
host_fqdn = vcenter2.new-york.example.com

[source/redfish-hardware]

type = check_redfish
inventory_file_path = /opt/redfish_inventory

If different sources overwrite the same attribute for ex. a host then the order of the sources should be considered. The last source in order from top to bottom will prevail.

Pruning

Prune objects in NetBox if they are no longer present in any source. First they will be marked as Orphaned and after X (config option) days they will be deleted from NetBox.

Objects subjected to pruning:

  • devices
  • VMs
  • device interfaces
  • VM interfaces
  • IP addresses

All other objects created (i.e.: VLANs, cluster, manufacturers) will keep the source tag but will not be deleted. Theses are "shared" objects might be used by different NetBox objects

License

You can check out the full license here

This project is licensed under the terms of the MIT license.

netbox-sync's People

Contributors

bb-ricardo avatar dependabot[bot] avatar haeki avatar houtek avatar llinuxde avatar miyukki avatar mmasquelin avatar muratbulat avatar n-rodriguez avatar obestwalter avatar pisaniej avatar quentinlegay avatar rizlas avatar rsp2k avatar worldworm avatar zvfvrv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbox-sync's Issues

check for global VLAN if site VLAN is not present

I'm having issues with VLANs being duplicated, we treat each VLAN ID as being globally unique even if a VLAN only exists in one site.
If a VLAN is only in one site then it gets tagged with that site, if its on multiple vCenters for VMs with DR or spanned across multiple sites then it doesn't get tagged with a site within Netbox.

The issue is that after we run a sync we end up with multiple copies of the same VLAN.
For example, VLAN 123 might be in Netbox without being tagged to a site, after the sync it will show 3 times, the original VLAN we created plus 2 extra (one for each vCenter site).
With the prefixes, etc being assigned to existing VLANs we created it kinda makes a mess of things having the duplicated VLANs.
For example the VM interfaces are attached to the duplicated VLAN not the same VLANs we attached the the prefixes to.

Would it be possible to have an option within netbox-sync to match the VLANs in Netbox with the vCenter VLANs based on ID only and not ID and site?
I believe this would stop the VLAN duplication issue we are seeing.

DNS Name Lookup not working

If I enable dns_name_lookup = True I am getting this error. What I am missing ?

  File "./netbox-sync.py", line 143, in <module>
    main()
  File "./netbox-sync.py", line 125, in main
    inventory.query_ptr_records_for_all_ips()
  File "/opt/netbox-sync/module/netbox/inventory.py", line 347, in query_ptr_records_for_all_ips
    records = perform_ptr_lookups(data.get("ips"), data.get("servers"))
  File "/opt/netbox-sync/module/common/support.py", line 143, in perform_ptr_lookups
    results = loop.run_until_complete(queue)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/opt/netbox-sync/module/common/support.py", line 173, in reverse_lookup
    response = await resolver.gethostbyaddr(ip)
AttributeError: 'DNSResolver' object has no attribute 'gethostbyaddr'```

multiple datacenter, same cluster name

I migrated from https://github.com/synackray/vcenter-netbox-sync and the sync worked perfectly.

the issue:
With the old sync but also with your sync, the hosts and vms in different datacenters but with the same cluster names are all assigned to the last discovered datacenter with the cluster name.

structure in vsphere:

DC01

  • CL01
  • CL03
  • CL06

DC02

  • CL01
  • CL02

result in netbox:

DC01

  • CL03
  • CL06

DC02

  • CL01
  • CL02

in DC01 the CL01 is missing, instead all objects are assigned to DC02 --> CL01

Sync issue: AttributeError: 'NoneType' object has no attribute 'get_display_name'

Hi,

I upgraded our test Netbox from 2.8 to 2.9.10 and also migrated from vcenter-netbox-sync to netbox-sync since vcenter-netbox-sync hasn't been updated to support Netbox 2.9.

The initial sync went well however follow up syncs are failing with a "AttributeError: 'NoneType' object has no attribute 'get_display_name'" error, If I delete the IP listed from Netbox the sync gets past the error until it hits another IP address.


2020-12-07 16:38:47,214 - DEBUG2: Parsing 'interface' data structure: vmk0 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,214 - DEBUG2: Compiling VLAN list
2020-12-07 16:38:47,215 - DEBUG2: Parsing 'VLAN' data structure: 205 (vCenter: dc01-vc01)
2020-12-07 16:38:47,215 - DEBUG2: Parsing 'site' data structure: vCenter: dc01-vc01
2020-12-07 16:38:47,215 - DEBUG: Updated site object: vCenter: dc01-vc01
2020-12-07 16:38:47,215 - DEBUG: Updated VLAN object: 205 (vCenter: dc01-vc01)
2020-12-07 16:38:47,216 - INFO: Created new interface object: vmk0 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,216 - DEBUG2: Trying to find prefix for IP: 10.8.1.12/24
2020-12-07 16:38:47,219 - DEBUG2: Found IP '10.8.1.12/24' matches global prefix '10.8.1.0/24'
2020-12-07 16:38:47,219 - DEBUG: No exiting IP address object found. Creating a new one.
2020-12-07 16:38:47,219 - DEBUG2: Parsing 'IP address' data structure: 10.8.1.12/24
2020-12-07 16:38:47,220 - INFO: Created new IP address object: 10.8.1.12/24
2020-12-07 16:38:47,220 - DEBUG2: Parsing 'interface' data structure: vmk1 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,220 - DEBUG2: Parsing 'VLAN' data structure: 208 (vCenter: dc01-vc01)
2020-12-07 16:38:47,221 - DEBUG2: Parsing 'site' data structure: vCenter: dc01-vc01
2020-12-07 16:38:47,221 - DEBUG: Updated site object: vCenter: dc01-vc01
2020-12-07 16:38:47,221 - DEBUG: Updated VLAN object: 208 (vCenter: dc01-vc01)
2020-12-07 16:38:47,221 - INFO: Created new interface object: vmk1 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,221 - DEBUG2: Trying to find prefix for IP: 10.8.2.13/24
2020-12-07 16:38:47,224 - DEBUG2: Found IP '10.8.2.13/24' matches global prefix '10.8.2.0/24'
2020-12-07 16:38:47,225 - DEBUG: No exiting IP address object found. Creating a new one.
2020-12-07 16:38:47,225 - DEBUG2: Parsing 'IP address' data structure: 10.8.2.13/24
2020-12-07 16:38:47,225 - INFO: Created new IP address object: 10.8.2.13/24
2020-12-07 16:38:47,225 - DEBUG: Setting IP '10.8.2.13/255.255.255.0' as primary IPv4 for 'dc01-esx002.domain.tld
2020-12-07 16:38:47,225 - DEBUG2: Parsing 'device' data structure: dc01-esx002.domain.tld
2020-12-07 16:38:47,225 - INFO: Device 'dc01-esx002.domain.tld' attribute 'primary_ip4' changed from 'None' to '10.8.2.13/24'
2020-12-07 16:38:47,226 - DEBUG2: Parsing 'interface' data structure: vmk2 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,226 - DEBUG2: Parsing 'VLAN' data structure: 208 (vCenter: dc01-vc01)
2020-12-07 16:38:47,226 - DEBUG2: Parsing 'site' data structure: vCenter: dc01-vc01
2020-12-07 16:38:47,227 - DEBUG: Updated site object: vCenter: dc01-vc01
2020-12-07 16:38:47,227 - DEBUG: Updated VLAN object: 208 (vCenter: dc01-vc01)
2020-12-07 16:38:47,227 - INFO: Created new interface object: vmk2 (dc01-esx002.domain.tld)
2020-12-07 16:38:47,227 - DEBUG2: Trying to find prefix for IP: 10.8.2.14/24
2020-12-07 16:38:47,230 - DEBUG2: Found IP '10.8.2.14/24' matches global prefix '10.8.2.0/24'
Traceback (most recent call last):
  File "/opt/netbox-sync/netbox-sync.py", line 143, in <module>
    main()
  File "/opt/netbox-sync/netbox-sync.py", line 119, in main
    source.apply()
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 370, in apply
    view_details.get("view_handler")(obj)
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 1746, in add_host
    p_ipv4=host_primary_ip4, p_ipv6=host_primary_ip6)
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 1064, in add_device_vm_to_inventory
    log.warning(f"Current interface '{current_nic.get_display_name()}' for IP "
AttributeError: 'NoneType' object has no attribute 'get_display_name'

Any idea on what might be causing the issue, I'd rather not have to spend ages removing each IP it has an issue with, even more sure if its going to have same issue later on 🙂

Thanks

Adding a new ip prefix in settings.ini, netbox v2.11

Hi!
Thanks for your work!
After update scrip a new version add support netbox 2.11 (#58)
I have a new problem, when i add new prefix (my public prefix) in config file and start script, he return the error.
How, i may fix it ?

2021-04-26 12:36:38,712 - WARNING: IP prefix length of '172.16.184.74/29' (vNIC 1 (vDS Vlan184 172.16.184.0) (aso-cod-01)) does not match network prefix length '172.16.184.0/24'!
Traceback (most recent call last):
File "./netbox-sync.py", line 143, in
main()
File "./netbox-sync.py", line 119, in main
source.apply()
File "/opt/scripts/netbox-sync/module/sources/vmware/connection.py", line 373, in apply
view_details.get("view_handler")(obj)
File "/opt/scripts/netbox-sync/module/sources/vmware/connection.py", line 2170, in add_virtual_machine
self.add_device_vm_to_inventory(NBVM, object_data=vm_data, site_name=site_name, vnic_data=nic_data,
File "/opt/scripts/netbox-sync/module/sources/vmware/connection.py", line 989, in add_device_vm_to_inventory
device_vm_object = self.inventory.add_object(object_type, data=object_data, source=self)
File "/opt/scripts/netbox-sync/module/netbox/inventory.py", line 153, in add_object
new_object = object_type(data, read_from_netbox=read_from_netbox, inventory=self, source=source)
File "/opt/scripts/netbox-sync/module/netbox/object_classes.py", line 96, in init
self.update(data=data, read_from_netbox=read_from_netbox, source=source)
File "/opt/scripts/netbox-sync/module/netbox/object_classes.py", line 375, in update
float(current_value) == float(new_value):
TypeError: float() argument must be a string or a number, not 'NoneType'

Tenant needs to be applied to clusters/vms to allow duplicate naming

Netbox won't allow duplicate names with VMs if the tenant value is not set, even if the cluster is specified.

This is a problem even if you don't have dupe names, since vsphere 7.1 adds the new vcls vms that will always have naming conflicts:

2020-11-20 20:25:30,491 - ERROR: NetBox returned body: {'name': ['A virtual machine with this name already exists.']}
2020-11-20 20:25:30,491 - ERROR: Request Failed for virtual machine. Used data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: phx'}], 'name': 'vCLS (2)', 'cluster': 5, 'role': 5, 'status': 'active', 'memory': 128, 'vcpus': 1, 'disk': 2, 'platform': 5, 'comments': "vSphere Cluster Services VM is deployed from an OVA with a minimal installed profile of PhotonOS. vSphere Cluster Services manage the resources, power state and availability of these VM's. vSphere Cluster Service VMs are required for maintaining the health and availability of vSphere Cluster Services. Any impact on the power state or resources of these VM's might degrade the health of the vSphere Cluster Services and cause vSphere DRS to cease operation for the cluster."}

I don't think it makes sense to auto-create a tenant based on the vsphere cluster name though, since in a business one tenant may have multiple clusters. I'd suggest adding a "tenant" option for each source inside settings.ini, so we can manually specify which tenant each clusters hosts/vms/everything get put into.

Add "match_host_by_serial" config option to disable host serial matching.

I have two sources:

I don't have hosts added with DNS names only raw IP addresses.

  1. vCenter with hosts: (For customers)

10.99.105.101
10.99.105.102
10.99.105.103
10.99.105.104 - Spare (Not responding now)

  1. vCenter with hosts: (Private)

10.99.105.105
19.99.105.106

When I run ./netbox-sync.py it will not create all of them, but only one randomly and recreate VLANs, NICs, etc.

It's the same when I use only the first source with hosts from .1 to .4

All hosts are in one BLADE. Is this a problem?

Netbox sites with comma in name not parsed correctly in site relation mappings

Our Netbox sites are in a "City, State" or "City, Country" format (ex. Chicago, IL or London, UK) and the cluster site relation function would split at the comma causing errors.

I don't know if it is the cleanest, but I fixed this locally with this regex and a slight modification to the strip functions in the vmware/connection.py @ line 190:

for relation in re.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)",config_settings.get(relation_option)):

            object_name = relation.split("=")[0].strip(' "')
            relation_name = relation.split("=")[1].strip(' "')`

Issues after migrating from old vcenter-netbox-sync: 'dict' object has no attribute 'get_display_name'

Hello,

Attempting to migrate from synackray/vcenter-netbox-sync to this version, while also upgrading from the last working version with synackray's version (2.8.9) to 2.10.4, I have encountered some issues and would like some guidance. I have followed the upgrade procedure as documented in the netbox repository, and netbox works perfectly on the new version.

The database is already populated with a few hundred virtual machines, ip-adresses, VLANs etc. and I was hoping that since this project is based on synackray's version they would somehow (almost) work.

The error I am getting when running the sync with this new sync tool is (VM names and IP-adresses has been changed):

2021-02-17 10:58:39,398 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'vm01', got: None
2021-02-17 10:58:39,398 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2021-02-17 10:58:39,398 - WARNING: Current interface 'vNIC0 (vm01 (None))' for IP '192.168.0.100/27' and this one 'vNIC 1 (vm02) (vm02)' are both enabled. IP assignment skipped because it is unclear which one is the correct one!
Traceback (most recent call last):
  File "netbox-sync.py", line 143, in <module>
    main()
  File "netbox-sync.py", line 119, in main
    source.apply()
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 372, in apply
    view_details.get("view_handler")(obj)
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 2170, in add_virtual_machine
    nic_ips=nic_ips, p_ipv4=vm_primary_ip4, p_ipv6=vm_primary_ip6)
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 958, in add_device_vm_to_inventory
    device_vm_object = self.get_object_based_on_macs(object_type, nic_macs)
  File "/opt/netbox-sync/module/sources/vmware/connection.py", line 512, in get_object_based_on_macs
    matching_object.get_display_name(including_second_key=True)))
AttributeError: 'dict' object has no attribute 'get_display_name' 

I am guessing that there are something in the old database that the new tool does not like, but this crashes and is not handled (the script stops completely).

Any suggestions would be appriciated, thank you.

Skip updating attribute 'name'

Thank you for running this project.

Would it be possible to have the option to skip updating the name of a host? What we store in netbox is the upper case hostname, and what's being returned and set is the lower case FQDN. For instance:

"INFO: Device 'esx-name.fqdn.local' attribute 'name' changed from 'ESX-NAME' to 'esx-name.fqdn.local'"

wrong host_site_relation match

I've got devices that get matched against the wrong site.
With the settings below, I would expect int-esx020 to be matched against site DC1, since it's a part of CLUS002.

cluster_site_relation = CLUS002 = DC1
host_site_relation = int-esx025* = DC3, int-esx026* = DC3
2021-02-03 00:06:30,021 - DEBUG2: Trying to find site name for device 'int-esx020.masked.local'
2021-02-03 00:06:30,021 - DEBUG2: Found a match (int-esx025*) for int-esx020.masked.local, using site 'DC3'

It matches int-esx020 to CLUS002, but site DC3, which prevents the device to get added, because the cluster belongs to a different site:

ERROR: NetBox returned: POST /api/dcim/devices/ Bad Request
ERROR: NetBox returned body: {'cluster': ['The assigned cluster belongs to a different site (DC1)']}

tagging issue on objects from multiple vcenter sources

Hi,

With multiple vcenter sources enabled, it seems the tagging only occurs for objects found in the first 3 sources in the settings.ini.
All objects from all vcenters are synced, however the tagging only occurs for objects from the first 3 vcenters.
This is both for the "Source: name" and the "Netbox-synced" tags.
The tag itself is created, but none of the objects from that source is tagged with it.

When simply moving a vcenter source up in the settings file, so it's one of the first 3 sources, the tagging does occur.

VLAN Sync orphaned problem

Hello!

This might be a niche case but posting it anyways, our setup is the following:

One vcenter, one datacenter in vcenter, and two clusters.

Each cluster has a distributed switch, and under this switch we have distributed port groups based on customer and VLAN. A customer might have machines in both of this clusters meaning that the distributed portgroup exists in two places(one time under each distributed switch). These portgroups are named differently depending on what cluster they exist in, example:

Two clusters named: vSAN-AF and vSAN-HY they have a distributed switch each named vDS vSAN-AF and vDS vSAN-HY. So lets say customerXX has a vm in each of these clusters that will result in two portgroups named: customerxx-vsan-af and customerxx-vsan-hy the VLAN is of course the same however. But when running the sync depending on(not sure what) loads of VLANs get tagged as orphaned im guessing based on name since there is technically two objects with different names but with one VLAN. Is there something that can be done regarding this or am i doing something wrong? Please let me know if i can assist in anyway.

Thanks for this great tool!

wrong vlan assigned when duplicate VLANs exist in same site

Hi,

We work with VRFs in netbox to separate an access & storage network.
We also have duplicate VLAN IDs, with different prefixes in both these VRFs.
The sync returns a warning saying the prefix vlan != interface vlan.

Example:

VLAN 100 (SomethingPublic)
-> Prefix: 217.0.x.x/24 (Global VRF)
VLAN 100 (SomethingStorage)
-> Prefix: 172.20.0.0/24 (Storage VRF)
VM vm001 has an vNIC in vlan 100, with an assigned IP in 172.20.0.0/24

The sync will output this:
WARNING: Prefix vlan '100 (SomethingStorage)' does not match interface vlan '100 (SomethingPublic)' for 'vNIC 2 (Portgroup SomethingStorage) (vm001)

Blade servers merging together on import

When I run the sync, my 12 UCS blade servers end up merging into only 2 server objects in Netbox. Below is the DEBUG2 for one of the overwrites.
2021-02-12 08_22_46-uslis-p-esx011 - Copy

2021-02-12 13:56:38,840 - DEBUG2: Parsing vCenter host: uslis-p-esx001.example.com
2021-02-12 13:56:38,845 - DEBUG2: Trying to find site name for device 'uslis-p-esx001.example.com'
2021-02-12 13:56:38,845 - DEBUG2: Found a match (.*lis.*) for uslis-p-esx001.example.com, using site 'Chicago, IL'
2021-02-12 13:56:39,858 - DEBUG2: Found host vSwitch vSwitch0
2021-02-12 13:56:39,858 - DEBUG2: Found host vSwitch iScsiBootvSwitch
2021-02-12 13:56:39,858 - DEBUG2: Found host vSwitch vSwitch1
2021-02-12 13:56:40,762 - DEBUG2: Found host proxySwitch DataCluster_dvSwitch
2021-02-12 13:56:41,690 - DEBUG2: Found host portGroup Fault Tolerance VMkernel Port
2021-02-12 13:56:41,690 - DEBUG2: Found host portGroup vMotion VMkernel Port
2021-02-12 13:56:41,690 - DEBUG2: Found host portGroup Management VMKernel Port
2021-02-12 13:56:41,690 - DEBUG2: Found host portGroup VM - iSCSI-A
2021-02-12 13:56:41,690 - DEBUG2: Found host portGroup iSCSI-A
2021-02-12 13:56:41,691 - DEBUG2: Found host portGroup VM - iSCSI-B
2021-02-12 13:56:41,691 - DEBUG2: Found host portGroup iSCSI-B
2021-02-12 13:56:42,571 - DEBUG2: Parsing PhysicalNic: vmnic0
2021-02-12 13:56:42,572 - DEBUG2: Trying to find a VLAN based on the VLAN id '27'
2021-02-12 13:56:42,573 - DEBUG2: Found a exact matching VLAN object: 27 (Chicago, IL)
2021-02-12 13:56:42,573 - DEBUG2: Trying to find a VLAN based on the VLAN id '26'
2021-02-12 13:56:42,575 - DEBUG2: Found a exact matching VLAN object: 26 (Chicago, IL)
2021-02-12 13:56:42,575 - DEBUG2: Trying to find a VLAN based on the VLAN id '20'
2021-02-12 13:56:42,577 - DEBUG2: Found a exact matching VLAN object: 20 (Chicago, IL)
2021-02-12 13:56:42,577 - DEBUG2: Parsing PhysicalNic: vmnic1
2021-02-12 13:56:42,577 - DEBUG2: Trying to find a VLAN based on the VLAN id '27'
2021-02-12 13:56:42,578 - DEBUG2: Found a exact matching VLAN object: 27 (Chicago, IL)
2021-02-12 13:56:42,579 - DEBUG2: Trying to find a VLAN based on the VLAN id '26'
2021-02-12 13:56:42,580 - DEBUG2: Found a exact matching VLAN object: 26 (Chicago, IL)
2021-02-12 13:56:42,580 - DEBUG2: Trying to find a VLAN based on the VLAN id '20'
2021-02-12 13:56:42,582 - DEBUG2: Found a exact matching VLAN object: 20 (Chicago, IL)
2021-02-12 13:56:42,582 - DEBUG2: Parsing PhysicalNic: vmnic2
2021-02-12 13:56:42,582 - DEBUG2: Parsing PhysicalNic: vmnic3
2021-02-12 13:56:42,582 - DEBUG2: Parsing PhysicalNic: vmnic4
2021-02-12 13:56:42,582 - DEBUG2: Parsing PhysicalNic: vmnic5
2021-02-12 13:56:43,456 - DEBUG2: Parsing HostVirtualNic: vmk0
2021-02-12 13:56:43,457 - DEBUG2: Trying to find a VLAN based on the VLAN id '20'
2021-02-12 13:56:43,458 - DEBUG2: Found a exact matching VLAN object: 20 (Chicago, IL)
2021-02-12 13:56:43,458 - DEBUG: IP address 'fe80::225:b5ff:fe01:a17/64' for vmk0 is a link local address. Skipping.
2021-02-12 13:56:43,459 - DEBUG2: Parsing HostVirtualNic: vmk1
2021-02-12 13:56:43,459 - DEBUG: IP address 'fe80::225:b5ff:feaa:a000/64' for vmk1 is a link local address. Skipping.
2021-02-12 13:56:43,459 - DEBUG2: Parsing HostVirtualNic: vmk2
2021-02-12 13:56:43,459 - DEBUG: IP address 'fe80::250:56ff:fe6b:e6e/64' for vmk2 is a link local address. Skipping.
2021-02-12 13:56:43,459 - DEBUG2: Parsing HostVirtualNic: vmk3
2021-02-12 13:56:43,459 - DEBUG2: Trying to find a VLAN based on the VLAN id '26'
2021-02-12 13:56:43,461 - DEBUG2: Found a exact matching VLAN object: 26 (Chicago, IL)
2021-02-12 13:56:43,461 - DEBUG: IP address 'fe80::250:56ff:fe6f:5e3d/64' for vmk3 is a link local address. Skipping.
2021-02-12 13:56:43,461 - DEBUG2: Parsing HostVirtualNic: vmk4
2021-02-12 13:56:43,461 - DEBUG2: Trying to find a VLAN based on the VLAN id '27'
2021-02-12 13:56:43,463 - DEBUG2: Found a exact matching VLAN object: 27 (Chicago, IL)
2021-02-12 13:56:43,463 - DEBUG: IP address 'fe80::250:56ff:fe6a:13ca/64' for vmk4 is a link local address. Skipping.
2021-02-12 13:56:43,463 - DEBUG2: Trying to find a device based on the collected name, cluster, IP and MAC addresses
2021-02-12 13:56:43,472 - DEBUG2: No exact match found. Trying to find device based on MAC addresses
2021-02-12 13:56:43,481 - DEBUG2: No match found. Trying to find device based on serial number
2021-02-12 13:56:43,481 - DEBUG2: Found a matching device object: uslis-p-esx009.example.com (Chicago, IL)
2021-02-12 13:56:43,481 - DEBUG2: Parsing 'device' data structure: uslis-p-esx001.example.com
2021-02-12 13:56:43,482 - DEBUG2: Parsing 'device type' data structure: UCSB-B200-M4
2021-02-12 13:56:43,482 - DEBUG2: Parsing 'manufacturer' data structure: Cisco Systems Inc
2021-02-12 13:56:43,482 - DEBUG: Updated manufacturer object: Cisco Systems Inc
2021-02-12 13:56:43,482 - DEBUG: Updated device type object: UCSB-B200-M4
2021-02-12 13:56:43,482 - DEBUG2: Parsing 'site' data structure: Chicago, IL
2021-02-12 13:56:43,482 - DEBUG: Updated site object: Chicago, IL
2021-02-12 13:56:43,482 - DEBUG2: Parsing 'cluster' data structure: LIS Data Cluster
2021-02-12 13:56:43,482 - DEBUG: Updated cluster object: LIS Data Cluster
2021-02-12 13:56:43,483 - DEBUG2: Parsing 'platform' data structure: VMware ESXi 6.5.0
2021-02-12 13:56:43,483 - DEBUG: Updated platform object: VMware ESXi 6.5.0
2021-02-12 13:56:43,483 - INFO: Device 'uslis-p-esx001.example.com' attribute 'name' changed from 'uslis-p-esx009.example.com' to 'uslis-p-esx001.example.com'
2021-02-12 13:56:43,483 - INFO: Device 'uslis-p-esx001.example.com' attribute 'device_type' changed from 'N20-B6625-1' to 'UCSB-B200-M4'
2021-02-12 13:56:43,483 - DEBUG2: Trying to match current object interfaces in NetBox with discovered interfaces
2021-02-12 13:56:43,491 - DEBUG2: Found '11' NICs in Netbox for 'uslis-p-esx001.example.com'
2021-02-12 13:56:43,491 - DEBUG2: Found 1:1 name match for NIC 'vmnic0'
2021-02-12 13:56:43,491 - DEBUG2: Found 1:1 name match for NIC 'vmnic1'
2021-02-12 13:56:43,491 - DEBUG2: Found 1:1 name match for NIC 'vmnic2'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmnic3'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmnic4'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmnic5'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmk0'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmk1'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmk2'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmk3'
2021-02-12 13:56:43,492 - DEBUG2: Found 1:1 name match for NIC 'vmk4'
2021-02-12 13:56:43,493 - DEBUG2: Parsing 'interface' data structure: vmnic0 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,493 - DEBUG2: Compiling VLAN list
2021-02-12 13:56:43,493 - INFO: Interface 'vmnic0 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:01:0A:14' to '00:25:B5:01:0A:17'
2021-02-12 13:56:43,493 - INFO: Interface 'vmnic0 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (vSwitch0)' to '10Gb/s  pNIC (vSwitch0)'
2021-02-12 13:56:43,493 - INFO: Interface 'vmnic0 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,493 - DEBUG2: Parsing 'interface' data structure: vmnic1 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,494 - DEBUG2: Compiling VLAN list
2021-02-12 13:56:43,494 - INFO: Interface 'vmnic1 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:01:0B:14' to '00:25:B5:01:0B:17'
2021-02-12 13:56:43,494 - INFO: Interface 'vmnic1 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (vSwitch0)' to '10Gb/s  pNIC (vSwitch0)'
2021-02-12 13:56:43,494 - INFO: Interface 'vmnic1 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,494 - DEBUG2: Parsing 'interface' data structure: vmnic2 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,494 - INFO: Interface 'vmnic2 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:01:0A:04' to '00:25:B5:01:0A:07'
2021-02-12 13:56:43,494 - INFO: Interface 'vmnic2 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (DataCluster_dvSwitch)' to '10Gb/s  pNIC (DataCluster_dvSwitch)'
2021-02-12 13:56:43,495 - INFO: Interface 'vmnic2 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,495 - DEBUG2: Parsing 'interface' data structure: vmnic3 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,495 - INFO: Interface 'vmnic3 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:01:0B:04' to '00:25:B5:01:0B:07'
2021-02-12 13:56:43,495 - INFO: Interface 'vmnic3 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (DataCluster_dvSwitch)' to '10Gb/s  pNIC (DataCluster_dvSwitch)'
2021-02-12 13:56:43,495 - INFO: Interface 'vmnic3 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,496 - DEBUG2: Parsing 'interface' data structure: vmnic4 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,496 - INFO: Interface 'vmnic4 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:AA:A0:08' to '00:25:B5:AA:A0:00'
2021-02-12 13:56:43,496 - INFO: Interface 'vmnic4 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (iScsiBootvSwitch)' to '10Gb/s  pNIC (iScsiBootvSwitch)'
2021-02-12 13:56:43,496 - INFO: Interface 'vmnic4 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,496 - DEBUG2: Parsing 'interface' data structure: vmnic5 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,496 - INFO: Interface 'vmnic5 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:BB:B0:08' to '00:25:B5:BB:B0:00'
2021-02-12 13:56:43,497 - INFO: Interface 'vmnic5 (uslis-p-esx001.example.com)' attribute 'description' changed from '20Gb/s  pNIC (vSwitch1)' to '10Gb/s  pNIC (vSwitch1)'
2021-02-12 13:56:43,497 - INFO: Interface 'vmnic5 (uslis-p-esx001.example.com)' attribute 'type' changed from 'other' to '10gbase-t'
2021-02-12 13:56:43,497 - DEBUG2: Parsing 'interface' data structure: vmk0 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,497 - INFO: Interface 'vmk0 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:01:0A:14' to '00:25:B5:01:0A:17'
2021-02-12 13:56:43,497 - INFO: Interface 'vmk0 (uslis-p-esx001.example.com)' attribute 'description' changed from 'Management VMkernel Port (vSwitch0, vlan ID: 20)' to 'Management VMKernel Port (vSwitch0, vlan ID: 20)'
2021-02-12 13:56:43,497 - DEBUG2: Trying to find prefix for IP: 172.17.5.181/24
2021-02-12 13:56:43,498 - DEBUG2: No matching prefix found for '172.17.5.181/24'
2021-02-12 13:56:43,507 - DEBUG2: Found existing NetBox IP address object: 172.17.5.181/24
2021-02-12 13:56:43,508 - DEBUG2: Parsing 'IP address' data structure: 172.17.5.181/24
2021-02-12 13:56:43,508 - DEBUG2: Parsing 'interface' data structure: vmk1 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,508 - INFO: Interface 'vmk1 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:25:B5:AA:A0:08' to '00:25:B5:AA:A0:00'
2021-02-12 13:56:43,508 - DEBUG2: Trying to find prefix for IP: 10.5.1.11/24
2021-02-12 13:56:43,509 - DEBUG2: No matching prefix found for '10.5.1.11/24'
2021-02-12 13:56:43,516 - DEBUG2: Found existing NetBox IP address object: 10.5.1.11/24
2021-02-12 13:56:43,516 - DEBUG2: Parsing 'IP address' data structure: 10.5.1.11/24
2021-02-12 13:56:43,516 - DEBUG2: Parsing 'interface' data structure: vmk2 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,516 - INFO: Interface 'vmk2 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:50:56:6B:6A:57' to '00:50:56:6B:0E:6E'
2021-02-12 13:56:43,516 - DEBUG2: Trying to find prefix for IP: 10.5.2.11/24
2021-02-12 13:56:43,517 - DEBUG2: No matching prefix found for '10.5.2.11/24'
2021-02-12 13:56:43,541 - DEBUG2: Found existing NetBox IP address object: 10.5.2.11/24
2021-02-12 13:56:43,541 - DEBUG2: Parsing 'IP address' data structure: 10.5.2.11/24
2021-02-12 13:56:43,541 - DEBUG2: Parsing 'interface' data structure: vmk3 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,541 - INFO: Interface 'vmk3 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:50:56:68:61:27' to '00:50:56:6F:5E:3D'
2021-02-12 13:56:43,541 - INFO: Interface 'vmk3 (uslis-p-esx001.example.com)' attribute 'description' changed from 'Fault Tolerance VMkernel Port (vSwitch0, vlan ID: 27)' to 'vMotion VMkernel Port (vSwitch0, vlan ID: 26)'
2021-02-12 13:56:43,542 - INFO: Interface 'vmk3 (uslis-p-esx001.example.com)' attribute 'untagged_vlan' changed from '27 (Chicago, IL)' to '26 (Chicago, IL)'
2021-02-12 13:56:43,542 - DEBUG2: Trying to find prefix for IP: 10.2.16.27/25
2021-02-12 13:56:43,543 - DEBUG2: Found IP '10.2.16.27/25' matches global prefix '10.2.0.0/16'
2021-02-12 13:56:43,543 - WARNING: IP prefix length of '10.2.16.27/25' (vmk3 (uslis-p-esx001.example.com)) does not match network prefix length '10.2.0.0/16'!
2021-02-12 13:56:43,545 - DEBUG2: Found existing NetBox IP address object: 10.2.16.27/25
2021-02-12 13:56:43,545 - DEBUG2: Parsing 'IP address' data structure: 10.2.16.27/25
2021-02-12 13:56:43,546 - DEBUG2: Parsing 'interface' data structure: vmk4 (uslis-p-esx001.example.com)
2021-02-12 13:56:43,546 - INFO: Interface 'vmk4 (uslis-p-esx001.example.com)' attribute 'mac_address' changed from '00:50:56:60:9E:C8' to '00:50:56:6A:13:CA'
2021-02-12 13:56:43,546 - INFO: Interface 'vmk4 (uslis-p-esx001.example.com)' attribute 'description' changed from 'vMotion VMkernel Port (vSwitch0, vlan ID: 26)' to 'Fault Tolerance VMkernel Port (vSwitch0, vlan ID: 27)'
2021-02-12 13:56:43,546 - INFO: Interface 'vmk4 (uslis-p-esx001.example.com)' attribute 'untagged_vlan' changed from '26 (Chicago, IL)' to '27 (Chicago, IL)'
2021-02-12 13:56:43,546 - DEBUG2: Trying to find prefix for IP: 10.2.16.155/25
2021-02-12 13:56:43,547 - DEBUG2: Found IP '10.2.16.155/25' matches global prefix '10.2.0.0/16'
2021-02-12 13:56:43,548 - WARNING: IP prefix length of '10.2.16.155/25' (vmk4 (uslis-p-esx001.example.com)) does not match network prefix length '10.2.0.0/16'!
2021-02-12 13:56:43,550 - DEBUG2: Found existing NetBox IP address object: 10.2.16.155/25
2021-02-12 13:56:43,550 - DEBUG2: Parsing 'IP address' data structure: 10.2.16.155/25

Allow matching a vmware device to an existing device via serial number / asset tag

I have all my servers in netbox already, but when running sync it's created new devices for each of my esxi hosts using the vmware IP. I could just merge the two together, but down the road there's a high probability that I'm going to reprovision the same hardware and move it from one vmware cluster to another.

Ideally it'd be possible to discover a vmware host already exists in netbox just by matching the serial number (on my systems this is the dell service tag), this way netbox-sync would just move it over to the correct location when the host is reprovisioned.

There's probably complications here I'm not thinking about though, like how to deal with all the interfaces and their physical connections (can't just delete anything not matching, would have to update based on the vmnic# name probably?)

DEBUG: Starting new HTTPS connection (1): xxxx%0a%0aport%20=%2080%0a%0adisable_tls%20=%20false%0a%0avalidate_tls_certs%20=%20false:443

Hi,

It is not clear to me why the netbox is being accessed with https .. Please suggest

I am running on Ubuntu 18 & (v2.9.3)

./netbox-sync.py -n -l DEBUG3

2020-11-22 00:29:33,378 - INFO: Starting NetBox Sync
2020-11-22 00:29:33,379 - DEBUG: Using config file: /opt/netbox-sync/settings.ini
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.api_token = JDA***
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.host_fqdn = xxxx

port = 80

disable_tls = false

validate_tls_certs = false
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.port = None
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.disable_tls = False
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.validate_tls_certs = True
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.prune_enabled = False
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.prune_delay_in_days = 30
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.default_netbox_result_limit = 200
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.timeout = 30
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.max_retry_attempts = 4
2020-11-22 00:29:33,379 - DEBUG: Config: netbox.use_caching = True
2020-11-22 00:29:33,379 - WARNING: Log level is set to DEBUG3, Request logs will only be printed to console
2020-11-22 00:29:33,379 - DEBUG: Created new requests Session for NetBox.
2020-11-22 00:29:33,381 - DEBUG: Starting new HTTPS connection (1): xxxx%0a%0aport%20=%2080%0a%0adisable_tls%20=%20false%0a%0avalidate_tls_certs%20=%20false:443
encoding with 'idna' codec failed (UnicodeError: label too long)

Problem with POST

Ho i have problem with creating anything with this tool, Netbox latest version and netbox-sync lastest version of main

The problem started with creating site and with another:

2021-02-17 14:52:55,705 - DEBUG2: Sending POST to 'http://localhost/api/dcim/sites/' with data 'b'{"name": "C4C", "slug": "c4c"}''.
2021-02-17 14:52:55,705 - DEBUG2: Received HTTP Status 200.
2021-02-17 14:52:55,705 - DEBUG2: Adding unresolved dependencies back to object: ['tags']
2021-02-17 14:52:55,705 - DEBUG2: Parsing 'site' data structure: None
2021-02-17 14:52:55,705 - DEBUG2: Compiling TAG list
2021-02-17 14:52:55,705 - DEBUG2: Parsing 'tag' data structure: None
2021-02-17 14:52:55,706 - INFO: Found unset key 'name' while parsing None. Skipping This key
2021-02-17 14:52:55,706 - DEBUG: Updated tag object: None
2021-02-17 14:52:55,706 - DEBUG2: Parsing 'tag' data structure: None
2021-02-17 14:52:55,706 - INFO: Found unset key 'name' while parsing None. Skipping This key
2021-02-17 14:52:55,706 - DEBUG: Updated tag object: None
Traceback (most recent call last):
  File "netbox-sync.py", line 143, in <module>
    main()
  File "netbox-sync.py", line 133, in main
    nb_handler.update_instance()
  File "/opt/netbox/netbox-sync/module/netbox/connection.py", line 696, in update_instance
    self.update_object(nb_object_sub_class)
  File "/opt/netbox/netbox-sync/module/netbox/connection.py", line 666, in update_object
    this_object.update(data=unresolved_dependency_data)
  File "/opt/netbox/netbox-sync/module/netbox/object_classes.py", line 369, in update
    new_value_str = str(new_value.get_display_name())
  File "/opt/netbox/netbox-sync/module/netbox/object_classes.py", line 754, in get_display_name
    return sorted([x.get_display_name() for x in self])
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'

Adopt to NetBox v2.11+ version with changed vcpus data type

In NetBox 2.11 the data type the attribute vcpus for virtualization.virtual-machines has changed to "float" (even though it is returned as string).

To avoid VM updates on every run both (current and new) values have to be casted to the same type and be compared.

FR: Add possibility to map platform

Hi Ricardo,

It would be nice to filter or map vms with defined platform.
We also want to support you in development, if you want.

Best regards,
David

new site created for standalone hosts

Hi,

I've set cluster_site_relation = .* = Datacenter, and no host_site_relation.
I would expect it to link all devices from this vcenter source, to the "Datacenter" site, cause if no host_site_relation exists, it falls back to the cluster_site_relation, right?

The hosts that are a part of clusters in vcenter, are linked to the correct site.
But standalone ESX hosts are not linked to this same site. A new site is created for these hosts, causing some VLANs that already exist in the "Datacenter" site, to be created as a duplicate in this new site.

Is this expected behaviour, am I interpreting the settings file wrong?

DEBUG2: Parsing vCenter host: esx111.srv.masked
DEBUG2: Host name and cluster name are equal 'esx111.srv.masked'. Assuming this host is a 'standalone' host.
DEBUG2: Trying to find site name for device 'esx111.srv.masked'
DEBUG2: Found a matching cluster site for esx111.srv.masked, using site 'None'
DEBUG: No site relation for 'esx111.srv.masked' found, using default site 'vCenter: vcenter006'
DEBUG2: Parsing 'cluster' data structure: esx111.srv.masked
INFO: Created new cluster object: esx111.srv.masked
DEBUG2: Found matching MAC 'B8:CA:3A:5C:DB:C4' on device 'esx111.srv.masked (Datacenter)'
DEBUG2: Found matching MAC 'B8:CA:3A:5C:DB:C4' on device 'esx111.srv.masked (Datacenter)'
DEBUG2: Found matching MAC 'B8:CA:3A:5C:DB:C5' on device 'esx111.srv.masked (Datacenter)'
DEBUG2: Found matching MAC 'B8:CA:3A:5C:DB:C6' on device 'esx111.srv.masked (Datacenter)'
DEBUG2: Found matching MAC 'B8:CA:3A:5C:DB:C7' on device 'esx111.srv.masked (Datacenter)'
DEBUG2: Found one device 'esx111.srv.masked (Datacenter)' based on MAC addresses and using it
DEBUG2: Found a matching device object: esx111.srv.masked (Datacenter)
DEBUG2: Parsing 'device' data structure: esx111.srv.masked
DEBUG2: Parsing 'cluster' data structure: esx111.srv.masked
DEBUG: Updated cluster object: esx111.srv.masked
INFO: Device 'esx111.srv.masked' attribute 'site' changed from 'Datacenter' to 'vCenter: vcenter006'
INFO: Device 'esx111.srv.masked' attribute 'cluster' changed from 'Standalone ESXi Host' to 'esx111.srv.masked'
INFO: Device 'esx111.srv.masked' attribute 'platform' changed from 'VMware ESXi' to 'VMware ESXi 6.5.0'

Handle missing "API-Version" HTTP header properly

Hi!
help me please. i don't start this script
How fix it ?

(venv) root@netbox:/opt/netbox/scripts/netbox-sync/module/netbox# python3 /opt/netbox/scripts/netbox-sync/netbox-sync.py
2021-04-15 17:39:00,595 - INFO: Starting NetBox Sync
Traceback (most recent call last):
File "/opt/netbox/scripts/netbox-sync/netbox-sync.py", line 143, in
main()
File "/opt/netbox/scripts/netbox-sync/netbox-sync.py", line 82, in main
nb_handler = NetBoxHandler(settings=netbox_settings, inventory=inventory)
File "/opt/netbox/scripts/netbox-sync/module/netbox/connection.py", line 99, in init
api_version = self.get_api_version()
File "/opt/netbox/scripts/netbox-sync/module/netbox/connection.py", line 217, in get_api_version
result = str(response.headers["API-Version"])
File "/opt/netbox/scripts/vcenter-netbox-sync/venv/lib/python3.8/site-packages/requests/structures.py", line 54, in getitem
return self._store[key.lower()][1]
KeyError: 'api-version'

Multiple instances of netbox-sync collides

I have two completely isolated networks, no connectivity between the two of them. I attempted to run two copies of netbox-sync, and used different source names in each instance.

The problem, though - is each instance is marking the other instances items as orphaned.

I can understand the logic in this, but could it be a setting? e.g. "orphan_missing_sources=false"

Do not change hosts in netbox if they were add manually

Hi

We have issue when couple hosts with correct domain name already exist in netbox. They already have physical interfaces but when netbox-sync was running it modified their physical interfaces list in netbox.

For example, our case looks like:

  1. we add manually host in netbox with physical interfaces (serial number, device-type, etc...)
  2. we connected host to switches inside netbox
  3. we exported communation matrix from netbox
  4. we connected host to switches inside our datacenter based netbox information which was exported in step 3

As you can see this case can exist if somebody use netbox to store commutation matrix (cables) inside netbox. So it is very lovely case because netbox is point of truth for all cables inside your data center.
But after script was running it broke up our truth and created physical interfaces in netbox. Be noticed, that vmk-interfaces should be sync.

What do you think about it ?

IP prefix length warning

Hi,

The docs mention this, and logs contain WARNING: IP prefix length of 'x.x.x.x/32' (vNIC 1 (x_NFW_3814) (vm)) does not match network prefix length 'x.x.x.x/24'

But the reported IP's for VMWare virtual machines do not include a subnet, so IP's collected from VMWare sources will always be /32, right? I don't think there is a way for pyvmomi to retrieve the subnet for the IP's of the vm's, or am I wrong?
And as such, that warning will always be displayed.

orphaned logic for vcenter-netbox-sync

I did a sync on a copy of our netbox that was synced from "vcenter-netbox-sync".
I renamed Synced -> "Netbox: Synced", and Orphaned -> "Netbox-Synced: Orphaned".
Only the tag name was changed by me, I noticed that it changed the tag slug itself during sync.

The "Synced" vs "Netbox: Synced" value seems correct: 37091 (old) vs 39564 (new).
However, the "NetBox-synced: Orphaned" now has 11168 items, and before only 147.

It tagged devices, VM's, IP's as Orphaned, which are very much not Orphaned 😃
It also deleted 116 objects that were previously tagged as Orphaned, but this all seems correct.

DEBUG2: Object 'device' 'esx001-cloud001.srv.masked' is Orphaned. Last time changed: 2021-01-27T15:16:06
DEBUG2: Object 'IP address' 'xx.xxx.179.220/32' is Orphaned. Last time changed: 2021-01-27T16:30:30

Any idea what's going wrong?

Changing a cluster name via site_relation, doesn't actually apply the change to netbox

I defined the cluster_site_relation and host_site_relation in the settings, it seems to be getting handled properly but the changes are never applied to netbox:

2020-11-20 21:35:09,123 - DEBUG2: Parsing vCenter cluster: c1-V1
2020-11-20 21:35:09,123 - DEBUG2: Trying to find site name for cluster 'c1-V1'
2020-11-20 21:35:09,123 - DEBUG2: Found a match (.*) for c1-V1, using site 'Van 3'
2020-11-20 21:35:09,123 - DEBUG2: Parsing 'cluster' data structure: c1-V1
2020-11-20 21:35:09,123 - DEBUG2: Parsing 'cluster type' data structure: VMware ESXi
2020-11-20 21:35:09,123 - DEBUG: Updated cluster type object: VMware ESXi
2020-11-20 21:35:09,123 - DEBUG2: Parsing 'cluster group' data structure: c1-V1
2020-11-20 21:35:09,123 - DEBUG: Updated cluster group object: c1-V1
2020-11-20 21:35:09,123 - DEBUG2: Parsing 'site' data structure: Van 3
2020-11-20 21:35:09,123 - DEBUG: Updated site object: Van 3
2020-11-20 21:35:09,123 - INFO: Cluster 'c1-V1' attribute 'site' changed from 'vCenter: c1' to 'Van 3'
2020-11-20 21:35:09,123 - DEBUG: Updated cluster object: c1-V1

Even with debug3, I don't see it actually sending a request to netbox to apply that change.

Error while running script

after starting I see an error, please help

[root@netbox-sync]# python3 netbox-sync.py
2020-10-26 18:43:23,767 - INFO: Starting NetBox Sync
2020-10-26 18:43:23,768 - DEBUG: Using config file: /opt/netbox-sync/settings.ini
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.api_token = 4c8***
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.host_fqdn = netbox.domain.com
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.port = 443
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.disable_tls = True
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.validate_tls_certs = True
2020-10-26 18:43:23,768 - DEBUG: Config: netbox.prune_enabled = True
2020-10-26 18:43:23,769 - DEBUG: Config: netbox.prune_delay_in_days = 30
2020-10-26 18:43:23,769 - DEBUG: Config: netbox.default_netbox_result_limit = 200
2020-10-26 18:43:23,769 - DEBUG: Config: netbox.timeout = 30
2020-10-26 18:43:23,769 - DEBUG: Config: netbox.max_retry_attempts = 4
2020-10-26 18:43:23,769 - DEBUG: Created new Session for NetBox.
HTTPConnectionPool(host='netbox.domain.com', port=443): Max retries exceeded with url: /api/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f1342ac2978>: Failed to establish a new connection: [Errno 111] Connection refused',))

Trying to find {object_type.name} based on serial number

I'm trying to setup this sync tool. Unforfunately running into an issue.

  • Netbox: 2.9.8
  • vCenter 7.0.1.

When running the sync, it hangs on the following:
2020-11-23 15:46:13,931 - DEBUG: vCenter returned '7' hosts
2020-11-23 15:46:13,932 - DEBUG2: Parsing vCenter host: esxi007.infra.domain.com
2020-11-23 15:46:13,936 - DEBUG2: Trying to find site name for device 'esxi007.infra.domain.com'
2020-11-23 15:46:13,936 - DEBUG2: Found a matching cluster site for esxi007.infra.domain.com, using site 'SITE1'
2020-11-23 15:46:15,239 - DEBUG2: Found host proxySwitch Compute01-VDS
2020-11-23 15:46:16,350 - DEBUG2: Parsing PhysicalNic: vmnic0
2020-11-23 15:46:16,350 - DEBUG2: Parsing PhysicalNic: vmnic1
2020-11-23 15:46:16,350 - DEBUG2: Parsing PhysicalNic: vmnic2
2020-11-23 15:46:16,350 - DEBUG2: Parsing PhysicalNic: vmnic3
2020-11-23 15:46:16,351 - DEBUG2: Parsing PhysicalNic: vmnic4
2020-11-23 15:46:16,351 - DEBUG2: Parsing PhysicalNic: vmnic5
2020-11-23 15:46:16,906 - DEBUG2: Parsing HostVirtualNic: vmk0
2020-11-23 15:46:16,907 - DEBUG: IP address 'fe80::eef4:bbff:fec8:15f8/64' for vmk0 is a link local address. Skipping.
2020-11-23 15:46:16,907 - DEBUG2: Parsing HostVirtualNic: vmk1
2020-11-23 15:46:16,907 - DEBUG: IP address 'fe80::250:56ff:fe6f:3647/64' for vmk1 is a link local address. Skipping.
2020-11-23 15:46:16,907 - DEBUG2: Trying to find a device based on the collected name, cluster, IP and MAC addresses
2020-11-23 15:46:16,908 - DEBUG2: No exact match found. Trying to find device based on MAC addresses
2020-11-23 15:46:16,908 - DEBUG2: No match found. Trying to find {object_type.name} based on serial number
Traceback (most recent call last):
File "./netbox-sync.py", line 143, in
main()
File "./netbox-sync.py", line 119, in main
source.apply()
File "/appl/netbox-sync/module/sources/vmware/connection.py", line 365, in apply
view_details.get("view_handler")(obj)
File "/appl/netbox-sync/module/sources/vmware/connection.py", line 1583, in add_host
p_ipv4=host_primary_ip4, p_ipv6=host_primary_ip6)
File "/appl/netbox-sync/module/sources/vmware/connection.py", line 891, in add_device_vm_to_inventory
device_vm_object = self.get_by_data(object_type, data={"serial": object_data.get("serial")})
AttributeError: 'VMWareHandler' object has no attribute 'get_by_data'

Any pointers here?

Thanks!

Error while requesting virtual machines

Hi,

You are doing great job! But I had following error:

2020-11-08 15:05:36,995 - DEBUG: Created new requests Session for NetBox.
2020-11-08 15:05:37,030 - INFO: Successfully connected to NetBox '10.X.X.44'
2020-11-08 15:05:37,030 - DEBUG: Detected NetBox API version: 2.9
2020-11-08 15:05:37,030 - INFO: Initializing sources
<..>
2020-11-08 15:05:37,144 - INFO: Successfully connected to vCenter '10.X.X.253'
2020-11-08 15:05:37,145 - INFO: Querying necessary objects from Netbox. This might take a while.
2020-11-08 15:05:37,145 - DEBUG: Requesting virtual machines from NetBox
2020-11-08 15:05:37,244 - DEBUG2: Received HTTP Status 200.

Traceback (most recent call last):
File "netbox-sync.py", line 162, in
main()
File "netbox-sync.py", line 126, in main
NB_handler.query_current_data(list(set(netbox_objects_to_query)))
File "/opt/netbox-sync/module/netbox/connection.py", line 290, in query_current_data
pickle.dump(nb_data.get("results"), open( f"cache/{nb_object_class.name}.cache", "wb" ) )
FileNotFoundError: [Errno 2] No such file or directory: 'cache/NBVMs.cache'

So I've created "cache" directory and started to work. Adding this directory to the git would prevent error to other people

"ERROR: (vmodl.fault.NotSupported)"

This might not be a legitimate error, but it's showing up in the debug logs so just wanted to flag it for your attention.

The context around it doesn't seem to indicate what exactly is failing here, so I think this might just be a bulk request from vmware that includes a not supported sub-object?

   (vim.alarm.AlarmState) {
      dynamicType = <unset>,
      dynamicProperty = (vmodl.DynamicProperty) [],
      key = 'alarm-9.vm-6505',
      entity = 'vim.VirtualMachine:vm-6505',
      alarm = 'vim.alarm.Alarm:alarm-9',
      overallStatus = 'gray',
      time = 2020-11-16T17:59:09.186577Z,
      acknowledged = false,
      acknowledgedByUser = <unset>,
      acknowledgedTime = <unset>,
      eventKey = <unset>
   }
]2020-11-20 00:43:59,866 - ERROR: (vmodl.fault.NotSupported) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = '',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) []
}

send: b'POST /sdk HTTP/1.1\r\nHost: 10.32.0.200\r\nContent-Length: 682\r\nCookie: vmware_soap_session="196f12d4851c9682469ed280e"; Path=/; HttpOnly; Secure;\r\nSOAPAction: "urn:vim25/6.7.3"\r\nContent-Type: text/xml; charset=UTF-8\r\nUser-Agent: pyvmomi Python/3.8.5 (Linux; 5.4.0-47-generic; x86_64)\r\nAccept-Encoding: gzip, deflate\r\n\r\n'
send: b'<?xml version="1.0" encoding="UTF-8"?>\n<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">\n<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">property>reply: 'HTTP/1.1 200 OK\r\n'

This happens 4 times during each sync

virtual machines are not removed from netbox

I deleted several virtual machines from vcenter, started synchronization, but after synchronization the virtual machines remained in the netbox off. What information do you need to provide to help solve problems?

VLAN using ESXi standard port groups

Hi,

Great script, does everything perfectly except one thing, using ESXi standard port groups is not an option. Basically the VLANs and prefix assignments are setup in ESXi as standard port groups instead of using DistributedirtualPortGroups, hence the only VLAN that is create is the ESXi Management Network (ID: 10). I have tried looking at the vSphere API in a way to modify the script to use standard port groups from ESXi but cannot seem to find a way. I'm new to the API so not too sure how to go about it.

Also because of not finding the prefixes in the VLANs, the VMs are not assigned to the correct prefixes as there are none imported. I know this can be done manually but with a large number of VMs it isnot feasibile to manually do this.

Is this a possible feature that could be added? I would do it myself if I knew how to query the API properly for the port groups & VLANs.

If you need more details please let me know.

errors in log

In the synchronization log, I am seeing an error. Can you tell me how to remove them? Or can I ignore them?

2021-01-13 14:08:42,349 - ERROR: NetBox returned: PATCH /api/dcim/interfaces/253/ Bad Request
2021-01-13 14:08:42,349 - ERROR: NetBox returned body: {'type': ['Virtual and wireless interfaces cannot be connected to another interface or circuit. Disconnect the interface or choose a suitable type.']}
2021-01-13 14:08:42,349 - ERROR: Request Failed for interface. Used data: {'name': 'vmk0', 'type': 'virtual', 'mtu': 1500, 'mac_address': 'AC:1F:6B:BD:32:05', 'description': 'Management Network (vSwitch0, vlan ID: 150)', 'mode': 'access', 'untagged_vlan': 17, 'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: my-example'}]}
2021-01-13 14:08:42,350 - INFO: Updating NetBox 'interface' object 'vmk1 (192.168.50.200)' with data: {'name': 'vmk1', 'type': 'virtual', 'mtu': 1500, 'mac_address': 'AC:1F:6B:BD:32:04', 'description': 'VMkernel (vSwitch0, vlan ID: 150)', 'mode': 'access', 'untagged_vlan': 17, 'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: my-example'}]}
2021-01-13 14:08:42,396 - ERROR: NetBox returned: PATCH /api/dcim/interfaces/254/ Bad Request
2021-01-13 14:08:42,397 - ERROR: NetBox returned body: {'type': ['Virtual and wireless interfaces cannot be connected to another interface or circuit. Disconnect the interface or choose a suitable type.']}
2021-01-13 14:08:42,397 - ERROR: Request Failed for interface. Used data: {'name': 'vmk1', 'type': 'virtual', 'mtu': 1500, 'mac_address': 'AC:1F:6B:BD:32:04', 'description': 'VMkernel (vSwitch0, vlan ID: 150)', 'mode': 'access', 'untagged_vlan': 17, 'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: my-example'}]}

Role is overwritten on update

Hi again,

Now the sync is working correctly, I am having the issue that my defined role is overwritten when the sync runs.
I currently have the following highlevel flow for provisioning a VM:
Ansible create VM --> Register in Netbox with this specific VM's role <-- AWX inventory syncs with netbox (uses roles)
After some time netbox-sync comes around to ensure the specifics are up to date (CPU/mem/IP) in case this changed.

I would like to have the option to NOT overwrite the VM role if it allready has been set. Am I missing a way I could achieve this?

Not works with Netbox v2.10.4

In the logs I see a successful connection with vsphere, and the creation of objects in netbox, but in fact, objects are not created. I did it according to the instructions. And I especially put an empty netbox image to check that the data is not loaded.

2021-02-01 17:15:39,645 - INFO: Starting NetBox Sync
2021-02-01 17:15:39,668 - INFO: Successfully connected to NetBox '127.0.0.1'
2021-02-01 17:15:39,668 - INFO: Initializing sources
2021-02-01 17:15:40,021 - INFO: Successfully connected to vCenter 'vcenter01.hw.lab'
2021-02-01 17:15:40,022 - INFO: Querying necessary objects from Netbox. This might take a while.
2021-02-01 17:15:41,572 - INFO: Finished querying necessary objects from Netbox
2021-02-01 17:15:41,573 - INFO: Created new tag object: NetBox-synced: Orphaned
2021-02-01 17:15:41,573 - INFO: Created new tag object: NetBox-synced
2021-02-01 17:15:41,573 - INFO: Query data from vCenter: 'vcenter01.hw.lab'
2021-02-01 17:15:41,908 - INFO: Created new site object: vCenter: selectel
2021-02-01 17:15:41,909 - INFO: Created new cluster object: esx07.hw.lab
2021-02-01 17:15:44,045 - INFO: Found unset key 'model' while parsing None. Skipping This key
2021-02-01 17:15:44,045 - INFO: Found unset key 'name' while parsing None. Skipping This key
2021-02-01 17:15:44,045 - INFO: Created new manufacturer object: None
2021-02-01 17:15:44,045 - INFO: Created new device type object: None
2021-02-01 17:15:44,046 - INFO: Created new platform object: VMware ESXi 7.0.1
2021-02-01 17:15:44,046 - INFO: Created new device object: esx07.hw.lab
2021-02-01 17:15:44,047 - INFO: Created new interface object: vmnic0 (esx07.hw.lab)
2021-02-01 17:15:44,047 - INFO: Created new interface object: vmnic1 (esx07.hw.lab)
2021-02-01 17:15:44,048 - INFO: Created new VLAN object: 40 (vCenter: selectel)
2021-02-01 17:15:44,048 - INFO: Created new VLAN object: 35 (vCenter: selectel)

172.21.0.1 - - [01/Feb/2021:14:15:39 +0000] "GET /api/ HTTP/1.1" 200 467 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:40 +0000] "GET /api/extras/tags/?limit=200&exclude=config_context HTTP/1.1" 200 627 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:40 +0000] "GET /api/dcim/manufacturers/?limit=200&exclude=config_context HTTP/1.1" 200 413 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:40 +0000] "GET /api/dcim/device-types/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:40 +0000] "GET /api/dcim/platforms/?limit=200&exclude=config_context HTTP/1.1" 200 691 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/virtualization/cluster-types/?limit=200&exclude=config_context HTTP/1.1" 200 203 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/virtualization/cluster-groups/?limit=200&exclude=config_context HTTP/1.1" 200 198 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/dcim/device-roles/?limit=200&exclude=config_context HTTP/1.1" 200 238 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/dcim/sites/?limit=200&exclude=config_context HTTP/1.1" 200 923 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/virtualization/clusters/?limit=200&exclude=config_context HTTP/1.1" 200 562 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/dcim/devices/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/virtualization/virtual-machines/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/virtualization/interfaces/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/dcim/interfaces/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/ipam/ip-addresses/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/ipam/prefixes/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/tenancy/tenants/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/ipam/vrfs/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"
172.21.0.1 - - [01/Feb/2021:14:15:41 +0000] "GET /api/ipam/vlans/?limit=200&exclude=config_context HTTP/1.1" 200 52 "-" "netbox-sync/0.0.1"

new version, bugs, questions

installed a new version today

  1. after running the script, I get an error FileNotFoundError: [Errno 2] No such file or directory: 'cache / NBPlatforms.cache'
  2. installation instructions
    virtualenv .env - there is no such command on centos
    3). .env / bin / activate - after entering this command - system response No such file or directory
  3. pip install -r requirements.txt - I think you need to add to the instructions what you need to run like this
    pip3 install -r requirements.txt
  4. in the config file I chose like this
    type = vmware, I have vcenter - is this correct?
  5. I don't understand the cluster_site_relation function
    , for example, I have several clusters (on a screenshot), how can I write them correctly in this function?
    image

ESX host not being pulling in

It seems if sync cannot do a DNS lookup it will add not the esx host
ERROR: Unfortunately updated item assigned_object_id for object 10.21.17.22/24 could not be fully resolved: <NBInterface instance 'vmk0 (lonesx3.blah.com)

 [root@zronetbox1 ]# host 10.21.17.22
22.17.21.10.in-addr.arpa domain name pointer lonesx3.blah.com.

is there a way to force this?

Can't add virtual machine interface - virtual_machine: this field is required

Not sure what's going on here exactly, it showed up once I added more than 1 cluster into my settings and these two errors are for different vmware clusters:

2020-11-20 20:49:02,879 - DEBUG2: Received HTTP Status 400.
2020-11-20 20:49:02,879 - DEBUG: Response Body:
2020-11-20 20:49:02,879 - ERROR: NetBox returned: POST /api/virtualization/interfaces/ Bad Request
2020-11-20 20:49:02,879 - ERROR: NetBox returned body: {'virtual_machine': ['This field is required.']}
2020-11-20 20:49:02,879 - ERROR: Request Failed for virtual machine interface. Used data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: c1'}], 'name': 'vNIC 1 (2060-c1_servers-10.33.10.0%2f24)', 'mac_address': '00:50:56:9F:B3:48', 'description': 'Network adapter 1 (VirtualVmxnet3) (vlan ID: 2060)', 'enabled': False, 'mtu': 1500, 'mode': 'access', 'untagged_vlan': 77}
2020-11-20 20:49:02,879 - DEBUG2: Adding unresolved dependencies back to object: ['virtual_machine']
2020-11-20 20:49:02,879 - DEBUG2: Parsing 'virtual machine interface' data structure: vNIC 1 (2060-c1_servers-10.33.10.0%2f24) (Windows Server 2019)
2020-11-20 20:49:02,879 - INFO: Creating new NetBox 'virtual machine interface' object 'vNIC 1 (2100-c2-management-10.34.0.0%2f24) (VMware Usage Meter)' with data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: c2'}], 'name': 'vNIC 1 (2100-c2-management-10.34.0.0%2f24)', 'mac_address': '00:50:56:8A:E9:A1', 'description': 'Network adapter 1 (VirtualVmxnet3) (vlan ID: 2100)', 'enabled': True, 'mtu': 1500, 'mode': 'access', 'untagged_vlan': 89}
2020-11-20 20:49:02,880 - DEBUG2: Sending POST to 'http://172.16.0.12:8000/api/virtualization/interfaces/' with data 'b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: c2"}], "name": "vNIC 1 (2100-c2-management-10.34.0.0%2f24)", "mac_address": "00:50:56:8A:E9:A1", "description": "Network adapter 1 (VirtualVmxnet3) (vlan ID: 2100)", "enabled": true, "mtu": 1500, "mode": "access", "untagged_vlan": 89}''.
2020-11-20 20:49:02,911 - DEBUG: http://172.16.0.12:8000 "POST /api/virtualization/interfaces/ HTTP/1.1" 400 47
2020-11-20 20:49:02,912 - DEBUG2: Received HTTP Status 400.
2020-11-20 20:49:02,912 - DEBUG: Response Body:
2020-11-20 20:49:02,912 - ERROR: NetBox returned: POST /api/virtualization/interfaces/ Bad Request
2020-11-20 20:49:02,912 - ERROR: NetBox returned body: {'virtual_machine': ['This field is required.']}
2020-11-20 20:49:02,912 - ERROR: Request Failed for virtual machine interface. Used data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: c2'}], 'name': 'vNIC 1 (2100-c2-management-10.34.0.0%2f24)', 'mac_address': '00:50:56:8A:E9:A1', 'description': 'Network adapter 1 (VirtualVmxnet3) (vlan ID: 2100)', 'enabled': True, 'mtu': 1500, 'mode': 'access', 'untagged_vlan': 89}
2020-11-20 20:49:02,912 - DEBUG2: Adding unresolved dependencies back to object: ['virtual_machine']

IP not assigned to VM error when updating the VM object

2020-11-19 02:09:34,920 - INFO: Creating new NetBox 'virtual machine' object 'sav-v1-vcenter' with data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: sav'}], 'name': 'sav-v1-vcenter', 'cluster': 4, 'role': 5, 'status': 'active', 'memory': 19456, 'vcpus': 4, 'disk': 499, 'platform': 9, 'comments': 'VMware vCenter Server Appliance', 'primary_ip4': 252}
,
 'nat_inside': None,
 'nat_outside': None,
 'role': None,
 'status': {'label': 'Active', 'value': 'active'},
 'tags': [{'color': '9e9e9e',
           'id': 11,
           'name': 'NetBox-synced',
           'slug': 'netbox-synced',
           'url': 'http://scrubbed/api/extras/tags/11/'},
          {'color': '9e9e9e',
           'id': 12,
           'name': 'Source: sav',
           'slug': 'source-sav',
--
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: X-Frame-Options: SAMEORIGIN
{'primary_ip4': ['The specified IP address (10.32.14.147/24) is not assigned '
                 'to this VM.']}
{'_body_position': None,
 '_cookies': <RequestsCookieJar[]>,
 'body': b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: sav"}], "name'
         b'": "sav-v1-vcenter", "cluster": 4, "role": 5, "status": "active", "m'
         b'emory": 19456, "vcpus": 4, "disk": 499, "platform": 9, "comments": "'
         b'VMware vCenter Server Appliance", "primary_ip4": 252}',
 'headers': {'User-Agent': 'netbox-sync/0.0.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 'Token 79c5341a8229cef4dc3800b526585d459d04f4b4', 'Content-Length': '257', 'Content-Type': 'application/json'}2020-11-19 02:09:34,921 - DEBUG2: Sending POST to 'http://172.16.0.12:8000/api/virtualization/virtual-machines/?limit=200&exclude=config_context' with data 'b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: sav"}], "name": "sav-v1-vcenter", "cluster": 4, "role": 5, "status": "active", "memory": 19456, "vcpus": 4, "disk": 499, "platform": 9, "comments": "VMware vCenter Server Appliance", "primary_ip4": 252}''.
2020-11-19 02:09:34,951 - DEBUG: http://172.16.0.12:8000 "POST /api/virtualization/virtual-machines/?limit=200&exclude=config_context HTTP/1.1" 400 89
2020-11-19 02:09:34,952 - DEBUG2: Received HTTP Status 400.
2020-11-19 02:09:34,952 - DEBUG: Response Body:
2020-11-19 02:09:34,952 - ERROR: NetBox returned: POST /api/virtualization/virtual-machines/?limit=200&exclude=config_context Bad Request
2020-11-19 02:09:34,952 - ERROR: NetBox returned body: {'primary_ip4': ['The specified IP address (10.32.0.200/24) is not assigned to this VM.']}
2020-11-19 02:09:34,952 - ERROR: Request Failed for virtual machine. Used data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: sav'}], 'name': 'sav-v1-vcenter', 'cluster': 4, 'role': 5, 'status': 'active', 'memory': 19456, 'vcpus': 4, 'disk': 499, 'platform': 9, 'comments': 'VMware vCenter Server Appliance', 'primary_ip4': 252}
2020-11-19 02:09:34,956 - INFO: Creating new NetBox 'virtual machine interface' object 'vNIC 1 (2000-sav_management-10.32.0.0%2f24) (sav-v1-vcenter)' with data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: sav'}], 'name': 'vNIC 1 (2000-sav_management-10.32.0.0%2f24)', 'mac_address': '00:0C:29:DD:6B:55', 'description': 'Network adapter 1 (VirtualVmxnet3) (vlan ID: 2000)', 'enabled': True, 'mtu': 1500, 'mode': 'access', 'untagged_vlan': 63}
2020-11-19 02:09:34,956 - DEBUG2: Sending POST to 'http://172.16.0.12:8000/api/virtualization/interfaces/?limit=200&exclude=config_context' with data 'b'{"tags": [{"name": "NetBox-synced"}, {"name": "Source: sav"}], "name": "vNIC 1 (2000-sav_management-10.32.0.0%2f24)", "mac_address": "00:0C:29:DD:6B:55", "description": "Network adapter 1 (VirtualVmxnet3) (vlan ID: 2000)", "enabled": true, "mtu": 1500, "mode": "access", "untagged_vlan": 63}''.
2020-11-19 02:09:34,977 - DEBUG: http://172.16.0.12:8000 "POST /api/virtualization/interfaces/?limit=200&exclude=config_context HTTP/1.1" 400 47
2020-11-19 02:09:34,977 - DEBUG2: Received HTTP Status 400.
2020-11-19 02:09:34,977 - DEBUG: Response Body:
2020-11-19 02:09:34,977 - ERROR: NetBox returned: POST /api/virtualization/interfaces/?limit=200&exclude=config_context Bad Request
2020-11-19 02:09:34,977 - ERROR: NetBox returned body: {'virtual_machine': ['This field is required.']}
2020-11-19 02:09:34,977 - ERROR: Request Failed for virtual machine interface. Used data: {'tags': [{'name': 'NetBox-synced'}, {'name': 'Source: sav'}], 'name': 'vNIC 1 (2000-sav_management-10.32.0.0%2f24)', 'mac_address': '00:0C:29:DD:6B:55', 'description': 'Network adapter 1 (VirtualVmxnet3) (vlan ID: 2000)', 'enabled': True, 'mtu': 1500, 'mode': 'access', 'untagged_vlan': 63}
2020-11-19 02:09:34,977 - DEBUG2: Adding unresolved dependencies back to object: ['virtual_machine']
2020-11-19 02:09:34,977 - DEBUG2: Parsing 'virtual machine interface' data structure: None (sav-v1-vcenter)
2020-11-19 02:09:34,992 - INFO: Updating NetBox 'IP address' object '10.32.0.200/24' with data: {'assigned_object_type': 'virtualization.vminterface'}
2020-11-19 02:09:34,993 - DEBUG2: Sending PATCH to 'http://172.16.0.12:8000/api/ipam/ip-addresses/252/?limit=200&exclude=config_context' with data 'b'{"assigned_object_type": "virtualization.vminterface"}''.
2020-11-19 02:09:35,084 - DEBUG: http://172.16.0.12:8000 "PATCH /api/ipam/ip-addresses/252/?limit=200&exclude=config_context HTTP/1.1" 200 890
2020-11-19 02:09:35,084 - DEBUG2: Received HTTP Status 200.
2020-11-19 02:09:35,084 - DEBUG: Response Body:
2020-11-19 02:09:35,084 - DEBUG2: Adding unresolved dependencies back to object: ['assigned_object_id']
2020-11-19 02:09:35,084 - DEBUG2: Parsing 'IP address' data structure: 10.32.0.200/24
2020-11-19 02:09:35,085 - DEBUG: Ip address '10.32.0.200/24' attribute 'assigned_object_id' changed from 'None' to 'vNIC 1 (2000-sav_management-10.32.0.0%2f24) (sav-v1-vcenter)'
2020-11-19 02:09:35,085 - DEBUG: Pruning disabled. Skipping
2020-11-19 02:09:35,085 - INFO: Completed NetBox Sync in 37.17 seconds

Not seeing much to go on here, let me how to help debug further!

UnboundLocalError: local variable 'ip' referenced before assignment

Very nice too see this project revived, thank you for your work!

Im trying to get this setup in our testing environment, we have been using the original project for a while.

Im getting the following error when im trying to sync:

2020-11-13 10:47:02,966 - DEBUG2: Parsing vCenter VM: XX-XX-CRM
2020-11-13 10:47:02,985 - DEBUG2: Trying to find site name for cluster 'vSAN-HY'
2020-11-13 10:47:02,986 - DEBUG2: Found a match (vSAN-HY) for vSAN-HY, using site 'DC01'
2020-11-13 10:47:03,055 - DEBUG2: Found default IPv4 gateway 10.54.115.1
2020-11-13 10:47:03,055 - DEBUG2: Parsing device VirtualVmxnet3: 00:50:56:B2:D6:27
2020-11-13 10:47:03,062 - DEBUG2: Trying to find a virtual machine based on the collected name, cluster, IP and MAC addresses
2020-11-13 10:47:03,064 - DEBUG2: No exact match found. Trying to find virtual machine based on MAC addresses
2020-11-13 10:47:03,070 - DEBUG2: No match found. Trying to find virtual machine based on primary IP addresses
Traceback (most recent call last):
File "netbox-sync.py", line 165, in
main()
File "netbox-sync.py", line 146, in main
source.apply()
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 319, in apply
view_details.get("view_handler")(obj)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 1510, in add_virtual_machine
p_ipv4=vm_primary_ip4, p_ipv6=vm_primary_ip6)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 652, in add_device_vm_to_inventory
device_vm_object = self.get_object_based_on_primary_ip(object_type, p_ipv4, p_ipv6)
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 466, in get_object_based_on_primary_ip
if _matches_device_primary_ip(grab(device, "data.primary_ip4"), primary_ip4) is True:
File "/opt/netbox-sync-dev/module/sources/vmware/connection.py", line 447, in _matches_device_primary_ip
if ip is not None and ip.split("/")[0] == ip_needle:
UnboundLocalError: local variable 'ip' referenced before assignment

The VM it self is not yet in Netbox, the set_primary_ip directive is set to always in settings.ini. Please advice, Thanks!

PR: add vm_role_relation

Hi Ricardo,

it would be nice to have an extra option to map vms to specific roles.
Same like #vm_tenant_relation = grafana.* = Infrastructure.

Should also be:

#Map vms to specified roles
#vm_role_relation = grafana.* = Grafana_role

Best regards,
David

allow partial sync with source orphaned logic

Would it be possible to tag objects as Orphaned, only when the source is being actively polled, and not if the source is defined but set as ènabled = false?
This would allow for a custom sync schedule on a per-vcenter(s) base.

For example if you sync from 8 vcenters (vcenter1 to vcenter8), and you want to (temporarily) disable sync from vcenter7 and vcenter8 by setting enabled = false.
Right now, all of the objects that were synced from those two vcenters would get tagged as Orphaned.

ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None

Hello,

Thank you for this script which works very well,

I am just ending up with some issues which seems to be marginal but still, would like to get to the bottom of it:

2020-11-19 17:59:02,479 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,479 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,480 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,480 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,480 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,480 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,480 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,481 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,481 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,481 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,481 - ERROR: Unable to determine second key 'virtual_machine' for virtual machine interface 'None', got: None
2020-11-19 17:59:02,481 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!
2020-11-19 17:59:02,488 - ERROR: Unable to determine second key 'device' for interface 'None', got: None
2020-11-19 17:59:02,488 - ERROR: This could cause serious errors and lead to wrongly assigned object relations!!!

Not all IPs synced on one object

Hello!

We are having an issue with one virtual firewall that doesn't get all ip's synced in to Netbox. Checked the logs and have the following, what could be the issue?

2021-01-13 08:26:34,204 - ERROR: Problems resolving relation 'primary_ip4' for object 'fw00XX-dc0X-cp' and value '{'id': 285, 'url': 'https://netbox/api/ipam/ip-addresses/285/', 'family': 4, 'address': '172.16.103.1/24'}'

2021-01-13 08:26:34,307 - ERROR: Problems resolving relation 'primary_ip4' for object 'fw00XX-dc0X-cp' and value '{'id': 285, 'url': 'https://netbox/api/ipam/ip-addresses/285/', 'family': 4, 'address': '172.16.103.1/24'}'

Way to not overwrite device name after changing device name in netbox

Hello,

Is there a way how to not overwrite the device name after changing the name in netbox after successfully added the device?

Let's explain. We have ESXi hosts added to vCenter only with IP addresses, because of not carrying about DNS from past days. Now we have a DNS record for every ESXi host, but we don't want to change hosts in clusters, because it's not so easy.

So I would like to change the name in Netbox, which will be for us fine, because of the easiest way to find the device, but when I did it, then with the new cron job of sync device names were changed back to IP Address. Will be nice to have an option to not overwrite the device name within cron job, when the device is already found and added on first run.

@bb-Ricardo what you think?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.