Domain¶
Domain data model¶
- This module provide model for domains. There are 2 models
Domain: which represent a DNS domain like example.com
DomainEntry: which represent a named entry like www.example.com
-
class
slam_domain.models.Domain(*args, **kwargs)[source]¶ - Domain class represent a fqdn domain like example.com
name: immutable name of the domain (example.com)
description: a short description of the domain
dns_master: IP of DNS master (used to push data in production)
contact: a contact email for the domain
creation_date: when domain has been created
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
static
create(name, args=None)[source]¶ A custom way to create a domain.
- Parameters
name – the DNS name
args – some optional information about a domain
- Returns
-
static
get(name, short=False)[source]¶ A custom way to get a domain.
- Parameters
name – the name of the domain
short – Return a short version of the object
- Returns
-
static
remove(name)[source]¶ This method is a custom way to delete a domain. As models.Model already have a method called delete(), we must use another name for our method.
- Parameters
name – domain name
- Returns
-
static
search(filters=None)[source]¶ This is a custom way to get all domains 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
-
class
slam_domain.models.DomainEntry(*args, **kwargs)[source]¶ - Domain entry is a name in domain like www.example.com
name: the name of the entry
domain: the domain associated (fqdn is name.domain)
type: the DNS entry type (A, CNAME, NS, …). AAAA entries are marked as A type
entries: In some cases (CNAME, NS, …) entry refered to another entry
description: a short description of the entry
creation_date: when entry as been created
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
static
create(name, domain, ns_type='A', sub_entry=None, description=None)[source]¶ This method is a custom way to create NS entry.
- Parameters
name – the name of the entry
domain – the domain
ns_type – the NS type of the entry
sub_entry –
description – A short description of the entry
- Returns
-
static
exclude(name, domain, ns_type='A', sub_entry=None)[source]¶ - Parameters
name –
domain –
ns_type –
sub_entry –
- Returns
-
static
get(name, domain, ns_type='A')[source]¶ A custom way to get a entry :param name: name of the entry :param domain: domain of the entry :param ns_type: NS type of the entry :return:
-
static
remove(name, domain, ns_type='A')[source]¶ A custom way to delete a entry. As a entry is unique from name/domain/ns_type, we need to have all this information to delete the right entry.
- Parameters
name – name of entry
domain – domain of entry
ns_type – NS type of entry
- Returns
Domain view¶
This module provide different view to manage domain. To avoid shadow name declaration, we use those following nomenclature
*_view: a function that manage the web interface (per example domains_view manage web interface
of domains, …) - domain: a specific domain (per example example.com) - domains: a list of domain - entry: a name associated with a domain that represent a entry in DNS - entries: a list of entry
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 itselfmkdir -p /opt/slam
-
slam_domain.views.domain_view(request, uri_domain)[source]¶ This function manage interaction between user and SLAM for a specific domain management. URI is represented by https://slam.example.com/domains/example.com
- Parameters
request – full HTTP request from user
uri_domain – the name of domain from URI (per example example.com is our URI)
-
slam_domain.views.domains_view(request)[source]¶ This function manage interaction between user and SLAM for all domains management. URI is represented by https://slam.example.com/domains
- Parameters
request – full HTTP request from user
-
slam_domain.views.entry_view(request, uri_domain, uri_entry)[source]¶ This function manage interaction between user and SLAM for a specific domain management. URI is represented by https://slam.example.com/domains/example.com/www if we want to represent www.example.com
- Parameters
request – full HTTP request from user
uri_domain – the name of domain from URI (per example example.com in our URI)
uri_entry – the entry name in a domain (per example www.example.com in our URI)