def query_netbox(): nb = netbox_api(request.form['netbox_address'], token=request.form['netbox_token']) for device in nb.dcim.devices.all(): device_ip = device.primary_ip4 or device.primary_ip6 factory( 'Device', **{ 'name': device.name, 'ip_address': str(device_ip).split('/')[0], 'subtype': request.form['netbox_type'], 'longitude': 0., 'latitude': 0. }) return jsonify(True)
def query_netbox() -> bool: nb = netbox_api(request.form["netbox_address"], token=request.form["netbox_token"]) for device in nb.dcim.devices.all(): device_ip = device.primary_ip4 or device.primary_ip6 factory( "Device", **{ "name": device.name, "ip_address": str(device_ip).split("/")[0], "subtype": request.form["netbox_type"], "longitude": 0.0, "latitude": 0.0, }, ) return True
def query_netbox(self, **kwargs: str) -> None: nb = netbox_api(kwargs["netbox_address"], token=kwargs["netbox_token"]) for device in nb.dcim.devices.all(): device_ip = device.primary_ip4 or device.primary_ip6 factory( "Device", **{ "name": device.name, "ip_address": str(device_ip).split("/")[0], "subtype": str(device.device_role), "model": str(device.device_type), "location": str(device.site), "vendor": str(device.device_type.manufacturer), "operating_system": str(device.platform), "longitude": str(nb.dcim.sites.get(name=device.site).longitude), "latitude": str(nb.dcim.sites.get(name=device.site).latitude), }, )
def query_netbox(self, **kwargs): nb = netbox_api(self.config["netbox"]["address"], token=environ.get("NETBOX_TOKEN")) for device in nb.dcim.devices.all(): device_ip = device.primary_ip4 or device.primary_ip6 factory( "device", **{ "name": device.name, "ip_address": str(device_ip).split("/")[0], "subtype": str(device.device_role), "model": str(device.device_type), "location": str(device.site), "vendor": str(device.device_type.manufacturer), "operating_system": str(device.platform), "longitude": str(nb.dcim.sites.get(name=device.site).longitude), "latitude": str(nb.dcim.sites.get(name=device.site).latitude), }, )
def query_netbox(self): nb = netbox_api(self.netbox_address, app.get_password(self.netbox_token)) for device in nb.dcim.devices.all(): device_ip = device.primary_ip4 or device.primary_ip6 db.factory( "device", **{ "name": device.name, "ip_address": str(device_ip).split("/")[0], "subtype": str(device.device_role), "model": str(device.device_type), "location": str(device.site), "vendor": str(device.device_type.manufacturer), "operating_system": str(device.platform), "longitude": str(nb.dcim.sites.get(name=device.site).longitude), "latitude": str(nb.dcim.sites.get(name=device.site).latitude), }, )