roster_config_manager Package

db_recovery Module

This module contains all of the logic for the recovery system.

It should be only called by the roster recovery system.

class roster_config_manager.db_recovery.Recover(username, config_instance)[source]

Bases: object

Roster Recovery

This class contains methods pertaining to recover roster after catastrophic failure.

PushBackup(audit_log_id)[source]

Restores database from sql backup with specified audit log id

Inputs:
audit_log_id: integer of audit log id
RunAuditRange(audit_log_id)[source]

Runs a range of audit steps

Inputs:
audit_log_id: integer of audit_log_id
RunAuditStep(audit_log_id)[source]

Runs a step from the audit_log

Inputs:
audit_log_id: integer of audit_log_id

tree_exporter Module

This module is used for exporting data in the database for all hosts to a BIND readable text form.

class roster_config_manager.tree_exporter.BindTreeExport(config_file_name, directory=None)[source]

Bases: object

This class exports zones

AddToTarFile(tar_file, file_name, file_string)[source]

Adds file string to tarfile object

Inputs:
tarfile: tarfile object file_name: string of filename to add file_string: string of file
CookData(data)[source]

Cooks data for zone exporter

Inputs:
data: dictionary of raw data from database
Outputs:

dict: dictionary keyed by dns_server_set ex: {u’external_dns’: {

‘dns_servers’: [u’[ns1.university.edu]’, u’[dns2.university.edu]’,
u’[dns3.university.edu]’],
‘views’: {u’external’:
{u’university.edu’: {‘records’:
[{u’serial_number’: 20091227, u’refresh_seconds’: 5,
‘target’: u’university.edu.’, u’name_server’: u’ns1.university.edu.’, u’retry_seconds’: 5, ‘ttl’: 3600, u’minimum_seconds’: 5, ‘record_type’: u’soa’, ‘view_name’: u’external’, ‘last_user’: u’sharrell’, ‘zone_name’: u’university.edu’, u’admin_email’: u'admin@university.edu.’, u’expiry_seconds’: 5},
{‘target’: u’computer1’, ‘ttl’: 3600, ‘record_type’: u’a’,
‘view_name’: u’external’, ‘last_user’: u’sharrell’, ‘zone_name’: u’university.edu’, u’assignment_ip’: u‘1.2.3.5’}, ‘zone_origin’: u’example.’, ‘zone_type’: u’master’}}}}}
CookRawDump(raw_dump)[source]

This takes raw data from the database and turns it into a mysqldump-like output.

Inputs:
raw_dump: list of dictionaries that contain all of the tables
and their associated metadata
Outputs:
list: tuple of list of strings to be concatenated into mysql dump files
ExportAllBindTrees(force=False)[source]

Exports bind trees to files

Inputs:
force: boolean of if the export should continue if no changes are found
in the database
GetRawData()[source]

Gets raw data from database

Outputs:
tuple of two dictionaries:
dictionary of raw data keyed by data name with values of dicts
containing values of that type’s attributes
dictionary of the raw dump keyed by data name with values of
dicts containing the db dump keyed by row, column, and schema
example:
({‘view_acl_assignments’: ({
‘view_acl_assignments_view_name’: u’external’, ‘view_acl_assignments_acl_name’: u’public’, ‘view_acl_assignments_acl_range_allowed’: 1})},
{ u’zones’:
{‘rows’:[{}],

‘columns’: [u’zones_id’, u’zone_name’], ‘schema’:(

u’CREATE TABLE zones (
zones_id mediumint(8) ‘,
‘unsigned NOT NULL auto_increment,
zone_name varchar(255) ‘,
‘NOT NULL,

PRIMARY KEY (zones_id), UNIQUE KEY ;

zone_name (zone_name),
KEY zone_name_1
‘(zone_name)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT ‘,
‘CHARSET=utf8’)}}),
ListACLNamesByView(data, view)[source]

Lists acl names

Inputs:
data: data from GetRawData view: string of view name
Outputs:
list: list of acl names ex:
[‘private’, ‘public’]
ListLatestNamedConfGlobalOptions(data, dns_server_set)[source]

Lists latest named.conf global options

This function is duplicated in roster-core/roster_core/core_helpers.py

Inputs:
data: data from GetRawData dns_server_set: string of dns server set name
Outputs:
string: string of latest named.conf global options
ListRecordArgumentDefinitions(record_arguments)[source]

Lists record argument definitions given table from database

This function is duplicated in roster-core/roster_core/core.py

Inputs:
record_arguments: record arguments from database
Outputs:
dictionary keyed by record type with values of lists

of lists of record arguments sorted by argument order. example: {‘mx’: [{‘argument_name’: u’priority’,

‘record_arguments_type’: u’mx’, ‘argument_data_type’: u’UnsignedInt’, ‘argument_order’: 0},
{‘argument_name’: u’mail_server’,
‘record_arguments_type’: u’mx’, ‘argument_data_type’: u’Hostname’, ‘argument_order’: 1}]}
MakeNamedConf(data, cooked_data, dns_server_set)[source]

Makes named.conf file strings

Inputs:
data: data from GetRawData cooked_data: data from cooked_data dns_server_set: string of dns_server_set
Outputs:
string: string of named.conf file
NamedHeaderChangeDirectory(named_conf_header, new_directory)[source]

Adds/Changes directory in named.conf header

Inputs:
named_conf_header: string of namedconf header new_directory: {}
Outputs:
string: string of namedconf header
SortRecords(records)[source]

Sorts records for zone exporter

Inputs:
records: list of records
Outputs:

dict: dictionary keyed by tuple (zone, view_dep) ex: {(u’university.edu’, u’internal_dep’):

{11: {‘target’: u’computer4’, ‘ttl’: 3600, ‘record_type’: u’a’,
‘view_name’: u’internal’, ‘last_user’: u’sharrell’, ‘zone_name’: u’university.edu’, u’assignment_ip’: u‘192.168.1.4’},
12: {u’serial_number’: 20091225, u’refresh_seconds’: 5,
‘target’: u’university.edu.’, u’name_server’: u’ns1.university.edu.’, u’retry_seconds’: 5, ‘ttl’: 3600, u’minimum_seconds’: 5, ‘record_type’: u’soa’, ‘view_name’: u’internal’, ‘last_user’: u’sharrell’, ‘zone_name’: u’university.edu’, u’admin_email’: u'admin@university.edu.’, u’expiry_seconds’: 5}}}
exception roster_config_manager.tree_exporter.ChangesNotFoundError[source]

Bases: roster_config_manager.tree_exporter.Error

exception roster_config_manager.tree_exporter.Error[source]

Bases: roster_core.errors.CoreError

exception roster_config_manager.tree_exporter.MaintenanceError[source]

Bases: roster_config_manager.tree_exporter.Error

zone_exporter_lib Module

This module contains all of the logic for the zone exporter.

It should be only called by the exporter.

exception roster_config_manager.zone_exporter_lib.DuplicateRecordError[source]

Bases: roster_config_manager.zone_exporter_lib.Error

exception roster_config_manager.zone_exporter_lib.Error[source]

Bases: roster_core.errors.CoreError

roster_config_manager.zone_exporter_lib.FormatRecordsForZone(unsorted_records, origin, zone_name, view_name)[source]

Gets the records from the db and sorts them.

Inputs:
unsorted_records: unsorted records dictionary origin: string of zone origin zone_name: string of zone name view_name: string of view name
Outputs:
dictionary keyed by record type with values of sorted lists of
record dictionaries.
roster_config_manager.zone_exporter_lib.MakeZoneString(records, zone_origin, argument_definitions, zone_name, view_name)[source]

Makes zone string that can be written to a file. Inputs:

records: dictionary of sorted records zone_origin: string of zone origin argument_definitions: dictionary of argument definitions zone_name: string of zone name view_name: string of view name
Outputs:
string of exported zone file.
exception roster_config_manager.zone_exporter_lib.ZoneError[source]

Bases: roster_config_manager.zone_exporter_lib.Error

zone_importer_lib Module

This module contains all of the logic for the zone importer.

It should be only called by the importer.

exception roster_config_manager.zone_importer_lib.Error[source]

Bases: exceptions.Exception

class roster_config_manager.zone_importer_lib.ZoneImport(zone_file_name, config_file_name, user_name, view, zone_name)[source]

Bases: object

This class will only import one zone per init. It will load the zone from a file using dns.zone and then use the core API to put it in the database.

MakeRecordsFromZone()[source]

Makes records in the database from dns.zone class.

Outputs:
int: Amount of records added to db.
ReverseZoneToCIDRBlock()[source]

Creates CIDR block from reverse zone name.

Outputs:
string of cidr block