Core

Core utils tools

This module provide some usefull function to avoid copy / paste.

slam_core.utils.error_message(plugin, value, message)[source]

This function return a dict construction for error message

Parameters
  • plugin – plugin name

  • value – value of plugin name

  • message – error message

Returns

slam_core.utils.name_validator(name)[source]

This function check if a name haven’t some wierd char

Parameters

name – mac-address provided by user

Returns

Core producer

Core producer utils tools

This module provide some useful tools for GitPython

slam_core.producer.utils.commit()[source]

This method trig a git commit for DNS/DHCP and freeradius

Returns

slam_core.producer.utils.diff()[source]

This function trig a git diff command to let user see differences before pushing data

Returns

slam_core.producer.utils.publish(message='This is the default comment')[source]

This function trig a git push command to make data available for production

Returns

Core bind9 producer

This module provide tools to produce DNS Bind9 configuration. It will put all records on a file named example.com.db (for example.com) and update SOA serial in a file example.com.soa.db. For some reason, the serial number should be on its own line with the following format:

2020010401 ; Serial

class slam_core.producer.bind.Bind(domain, directory)[source]

This class manage Bind9 file production. This only manage name resolution, not reverse IP resolution.

save()[source]

This method write on example.com.db file all the records.

Returns

show()[source]

This method make the rendering and return it as a string. To make git diff easier to read, we don’t add some timestamp into the file.

Returns

update_soa()[source]

This method update SOA to change Serial number, it s required by bind9 to make modification available for other DNS server.

Returns

class slam_core.producer.bind.BindReverse(network, directory)[source]

This class manage Bind9 file production. This only reverse IP resolution.

produce()[source]

This method will create a set of file for reverse DNS. As bind need to have reverse DNS from /8, /16 or /24 network, if we want to manage a different prefix (/21 per example), we need to create a file for each /24 that compose the subnet.

Returns

save()[source]

This method write on example.com.db file all the records.

Returns

show()[source]

This method make the rendering and return it as a string. To make git diff easier to read, we don’t add some timestamp into the file.

Returns

update_soa()[source]

This method update SOA to change Serial number, it s required by bind9 to make modification available for other DNS server.

Returns

Core ISC-DHCP producer

This module provide tools to produce ISC-DHCP configuration. It will put all DHCP entries on a file named network.conf (for local.conf).

class slam_core.producer.isc_dhcp.IscDhcp(network, hosts, directory)[source]

This class manage ISC-DHCP configuration. It will only provide host configuration, you have to include those file on DHCP configuration

save()[source]

This method write on example.com.db file all the records.

Returns

show()[source]

This method make the rendering and return it as a string. To make git diff easier to read, we don’t add some timestamp into the file.

Returns

Core freeradius producer

This module provide tools to produce freeradius configuration. A freeradius file look like

00:11:22:33:44:55 Cleartext-Password := 00:11:22:33:44:55

Tunnel-Type = VLAN, Tunnel-Medium-Type = IEEE-802, Tunnel-Private-Group-Id = vlan-id

DEFAULT Auth-Type := Reject

Reply-Message = “Pas d’autorisation”

class slam_core.producer.freeradius.FreeRadius(hosts, directory)[source]

This class manage freeradius configuration

save()[source]

This method write on example.com.db file all the records.

Returns

show()[source]

This method make the rendering and return it as a string. To make git diff easier to read, we don’t add some timestamp into the file.

Returns

Core views

This module provide HTTP view for SLAM. slam_core just provide basic view like home, login, logout. each django’s App (slam_*) provide it’s own view

slam_core.views.commit(request)[source]

This function trig DNS/DHCP and freeradius rendering. It will return a raw git diff.

Parameters

request – full HTTP request from user

Returns

slam_core.views.csrf(request)[source]

This page is only a empty page to force CSRF token to be send to browser. In case of REST API, CSRF can be painful to retrieve as it is not sent on every pages. This page force Django to resend a new CSRF Token.

As django view are generic function with “request” as parameter and we don’t use it, we must tell to pylint to not check W0613 (unused-argument) from this function.

Parameters

request – full HTTP request from user

slam_core.views.diff(request)[source]

This function provide a git diff output. This is a raw version of git diff command so it can be painfull to read.

Parameters

request – full HTTP request from user

Returns

slam_core.views.index(request)[source]

This is the default home page of SLAM. It will only be available through a Web browser as it will only return a HTTP rendering (which will need javascript support).

Parameters

request – a full HTTP request from user

slam_core.views.login(request)[source]
This is the sign in form. 2 method type are supported
  • GET: to show the HTTP login page

  • POST: to trig login action

Parameters

request – full HTTP request from user

slam_core.views.logout(request)[source]

This is the logout page. Whatever we provide, that trig user logout and that’s all.

Parameters

request – full HTTP request from user

slam_core.views.logs(request)[source]

This function display slam log file into a web pages

Parameters

request – full HTTP request from user

Returns

slam_core.views.publish(request)[source]

This function trig a git push command to publish DNS/DHCP and freeradius rendering available.

Parameters

request – full HTTP request from user

Returns

slam_core.views.search(request)[source]

This function will return a list of objects that match the filter. We just provide basic filter as string filter but searching will be done on all field. If no filter has been provide by user, we get all object database.

The output is a dict abstraction of object in short format (see show method from modules for more information)

Parameters

request – full HTTP request from user

Returns