Skip to content

Commit 746a439

Browse files
committed
update README
1 parent e20280c commit 746a439

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,41 @@ class ExampleExpandableStringVar(es.Script):
105105
# data['vm_name'] => ['my-new-vm1.exmaple.com', 'my-new-vm2.exmaple.com', 'my-new-vm3.exmaple.com']
106106
pass
107107
108+
```
109+
110+
## make_link
111+
112+
The helper returns a reference to the object enclosed in the `<a>` tag. This can be useful in a script output.
113+
114+
```
115+
...
116+
from netbox_scripthelper.utils import make_link as _ml
117+
118+
119+
class ExampleMakeLink(Script):
120+
121+
...
122+
123+
def run(self, data, commit):
124+
...
125+
prefix = Prefix.objects.create(prefix='192.168.0.0/24')
126+
self.info_log(f'Created prefix: {_ml(prefix)}')
127+
128+
```
129+
130+
## IPSpliter
131+
132+
IPSliter splits set of networks to smaller networks with fixed mask.
133+
134+
```
135+
from netbox_scripthelper.utils import IPSpliter
136+
from netaddr import IPSet, IPNetwork
137+
138+
spliter = IPSplitter(IPSet([
139+
IPNetwork('192.168.1.0/24'),
140+
IPNetwork('192.168.3.0/24')
141+
]))
142+
143+
# subnets => [IPNetwork('192.168.1.0/28', '192.168.1.16/28', ...)]
144+
subnetes = spliter.split(28)
108145
```

0 commit comments

Comments
 (0)