Skip to main content
  1. Posts/

Faker - a fake data generator

·169 words·1 min·
netdevops blog python
Maximilian Thoma
Author
Maximilian Thoma
network engineer
Table of Contents

When developing scripts, you sometimes need fake data to test your code and implementations. This is where Faker comes into play. Faker is a Python package that generates fake data for you. It can create nearly everything you need, particularly for network automation: user accounts, IP addresses, subnets, MAC addresses, and more. Whether you need to bootstrap your database or anonymize data taken from a production service, Faker is the tool for you.

Install
#

pip install Faker

Usage examples
#

Initialize Faker

from faker import Faker

fake = Faker()

User accounts
#

for _ in range(5):
    print(fake.user_name())

Results:

tcaldwell
kaylamoreno
richardbeck
gweber
loriatkinson

Names
#

for _ in range(5):
    print(fake.name())

Results

Joshua Turner
Jennifer Guzman
Brooke Jensen
Michael Riley
Tonya Jones

IP addresses
#

# private
for _ in range(5):
    print(fake.ipv4_private())

# public ips
for _ in range(5):
    print(fake.ipv4_public())

Subnets
#

# private networks
for _ in range(5):
    print(fake.ipv4_private(network=True))

#  public networks
for _ in range(5):
    print(fake.ipv4_public(network=True))

MACs
#

for _ in range(5):
    print(fake.mac_address())

Documentation
#

Faker documentation

Related

LiveLab: Netbox VLAN deployment to Cisco devices
·1886 words·9 mins
netdevops livelab blog python netbox apiflask
Welcome to my latest blog post where I’ll be taking you through an exciting demonstration of integrating NetBox with custom middleware to automate VLAN deployments on Cisco devices.
Flask decorator for Netbox webhook authentication
·151 words·1 min
netdevops blog python netbox webhook flask apiflask
Today, I am excited to share with you a decorator for Flask/APIFlask, specifically designed for Netbox webhook authentication.
Netdevops python libraries toolbox
·1720 words·9 mins
netdevops blog python apiflask flask loguru ciscoconfparse dynaconf pymongo rq netmiko paramiko ansible pandas ntc_templates textfsm requests
In the ever-evolving landscape of network management and automation, the role of Network DevOps has become increasingly pivotal.