netbox_textdatastore
Store raw text files for devices, like configuration files, unparsed command output or test results Use version 0.0.5 for netbox 3.6
TextData Object: ''' { "id": Int, # unique id "name": String, # Object Name, eg "device config" 'device': Device ID, # Device ID from Netbox 'hash': String, # Hash of your Text Data 'data': String, # Your text data, eg Device Configfile } '''
Example:
extend python-netbox
https://github.com/jagter/python-netbox
''' from netbox import NetBox as NetBoxOrig
class textdata(object):
def __init__(self, netbox_con):
self.netbox_con = netbox_con
def get_data(self, **kwargs):
return self.netbox_con.get('/plugins/textdata/data/', **kwargs)
def add_data(self, device, name, hash, data, **kwargs):
required_fields = {
"name": name,
'device': device,
'hash': hash,
'data': data,
}
print(required_fields)
return self.netbox_con.post(
'/plugins/textdata/data/',
required_fields,
**kwargs
)
def update_data_id(self, pk, **kwargs):
return self.netbox_con.patch(
'/plugins/textdata/data/',
pk,
**kwargs
)
class NetBox(NetBoxOrig):
def __init__(self, host, **kwargs):
super().__init__(host, **kwargs)
self.textdata = textdata(self.connection)
'''
use it in napalm
''' def store_config(task, obj, content): """store config to netbox"""
hasher = md5()
hasher.update(content.encode('utf-8'))
hash = hasher.hexdigest()
device_id = task.host.data["id"]
res = obj.netbox.textdata.get_data(
device_id=device_id,
name="device config"
)
if(len(res) > 0):
res = res[0]
if(res["hash"] == hash):
print("No change")
return
print(obj.netbox.textdata.update_data_id(
pk=res["pk"],
data=content,
hash=hash
))
return
print(obj.netbox.textdata.add_data(
device=device_id,
name="device config",
hash=hash,
data=content
))
def backup_config(task, obj): """ get config from devices"""
from nornir_napalm.plugins.tasks import napalm_get
device_config = task.run(task=napalm_get, getters=["config"])
task.run(
task=store_config,
obj=obj,
content=device_config.result["config"]["running"]
)
'''
Metadata
Release files for netbox-textdatastore 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbox_textdatastore-0.1.1.tar.gz | 13.9 kB | Without provenance | Details for netbox_textdatastore-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netbox_textdatastore-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for netbox_textdatastore-0.1.1-py3-none-any.whl |
Total release size: 30.3 kB
Release files / netbox_textdatastore-0.1.1.tar.gz
| Download URL | netbox_textdatastore-0.1.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7dcc04a6852ad0148e100200642b0a716b8aae96a39c600f698c7f2dcb26aa0
|
|
BLAKE2b-256 checksum How to use checksums |
8953b9b78babcd5ef487f56562c52dad882bd47e7ec4d4ba22d511ff4026a14c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / netbox_textdatastore-0.1.1-py3-none-any.whl
| Download URL | netbox_textdatastore-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85dae89441cee74a147c162100d375e1d8fe74b00aa89343c1eb5c14aefd677e
|
|
BLAKE2b-256 checksum How to use checksums |
24ad757169dc484655438ecc2c42daefa222203b0a7ac9b31da288af220b8dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for netbox-textdatastore 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.