Network¶
Network data model¶
- This module provide model for networks. There are 2 models
Network: which represent a IPv6 or IPv4 network
Address: which represent a IPv6 or IPv5
As we use django models.Model, pylint fail to find objects method. We must disable pylint test E1101 (no-member)
-
class
slam_network.models.Address(*args, **kwargs)[source]¶ - Address class represent a specific address on a network.
ip: IPv4 or IPv6 address
ns_entries: all other NS entries for this IP (CNAME, A, …)
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
static
create(ip, network, ns_entry=None)[source]¶ This is a custom method to create a Address.
- Parameters
ip –
network –
ns_entry –
- Returns
-
static
exclude(ip, network, ns_entry, ns_type='A')[source]¶ This is a custom method to remove a NS entry from address
- Parameters
ip – IP address
network – network
ns_entry – NS entry
ns_type – NS type
- Returns
-
static
get(ip, network)[source]¶ This is a custom method to get information about a address
- Parameters
ip – IP address
network – Network
- Returns
-
static
include(ip, network, ns_entry, ns_type='A')[source]¶ This is a custom method to add a entry in a address
- Parameters
ip – IP address
network – network
ns_entry – NS entry
ns_type – NS entry type
- Returns
-
static
match_network(ip)[source]¶ This method return the network associated with the address
- Returns
-
static
remove(ip, network, ns_entry=True)[source]¶ This is a custom method to delete Address
- Parameters
ip – The IP address we will delete
network – The network name
ns_entry – If true, we also remove PTR and A resolution name (default True)
- Returns
-
class
slam_network.models.Network(*args, **kwargs)[source]¶ - Network class represent a IPv4 or IPv6 network
name: The human reading name of the network
description: A short description of the network
address: network address (192.168.0.0)
prefix: network prefix (/24)
gateway: the IP of the network gateway
dns_master: The IP of DNS master for reverse resolution (used to push data in production)
contact: a contact email for the network
dhcp: the IP of DHCP server (used to push data in production)
freeradius: the IP of freeradius server (used to push data in production)
vlan: the VLAN id of the network
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
static
create(name, address, prefix, description='A short description', gateway=None, dns_master=None, dhcp=None, radius=None, vlan=1, contact=None)[source]¶ This is a custom way to create a network
- Parameters
name – human reading name of the network
address – IPv4 or IPv6 network address
prefix – network prefix
description – A short description of the network
gateway – IP of the network gateway
dns_master – IP of DNS master
dhcp – IP of DHCP server
vlan – VLAN id of the network
contact – a contact email for the network
- Returns
-
static
get(name)[source]¶ This is a custom method to get all information for a network
- Parameters
name – name of the network
- Returns
-
is_include(ip)[source]¶ This method check if ip is included on a network
- Parameters
ip – IP address
- Returns
-
static
remove(name)[source]¶ This is a custom method to delete a network. As delete is already used by models.Model, we should call it with another name
- Parameters
name – name of network we want delete
- Returns
-
static
search(filters=None)[source]¶ This is a custom method to get all networks that match the filters
- Parameters
filters – a dict of field / regex
- Returns
-
show(key=False, short=False)[source]¶ - This method return a dict construction of the object. We have 3 types of output,
standard: all information about object it-self, short information about associated objects (like ForeignKey and ManyToManyField)
short: some basic information about object it-self, primary key of associated objects
key: primary key of the object
- Parameters
short – if set to True, method return a short output
key – if set to True, method return a key output. It will overwrite short param
- Returns
-
static
update(name, description=None, gateway=None, dns_master=None, dhcp=None, vlan=None, contact=None, radius=None)[source]¶ This is a custom method to update value on a existing network
- Parameters
name – human reading name of the network
description – A short description of the network
gateway – The IP of the gateway
dns_master – The IP of DNS master
dhcp – The IP of DHCP server
vlan – The VLAN id
contact – a contact email for the network
- Returns
Network view¶
This module provide different view to manage domain. To avoid shadow name declaration, we use those following nomenclature
network: a specific network (per example 192.168.0.0/24)
networks: a list of networks
host: a host is a association between a network (or a IP) with a DNS entry
*_view: a function that manage the web interface (per example domains_view manage web interface
of domains, …) - rest_api: a boolean which say if REST API is used. If not, HTML rendering will be used - options: a generic structure that represent arguments we send/receive to/from function - result: a temporary structure that represent the output of the view - result_*: a temporary structure that represent a part of the output (per example result_entries) - uri_*: input retrieve from URI structure itself
-
slam_network.views.address_view(request, uri_network, uri_address)[source]¶ This function manage interaction between user and SLAM for a specific host. URI is represented by https://slam.example.com/networks/192.168.0.1
- Parameters
request – full HTTP request from user
uri_network – the name of the network from URI
uri_address – the IP address from URI
-
slam_network.views.entry_view(request, uri_network, uri_address, uri_entry)[source]¶ This function manage interaction between user and SLAM for specific address. URI is represented by https://slam.example.com/networks/192.168.0.1/www.example.com
- Parameters
request – full HTTP request from user
uri_network – the name of the network from URI
uri_address – the IP address from URI
uri_entry – the NS entry from URI
- Returns
-
slam_network.views.network_view(request, uri_network)[source]¶ This function manage interaction between user and SLAM for network management. URI is represented by https://slam.example.com/networks/my-network
- Parameters
request – full HTTP request from user
uri_network – the network name
-
slam_network.views.networks_view(request)[source]¶ This function manage interaction between user and SLAM for all network management. URI is represented by https://slam.example.com/networks
- Parameters
request – full HTTP request from user