roster_user_tools Package

action_flags Module

Action flags lib, flags in all ls, mk, rm tools.

class roster_user_tools.action_flags.List(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line ls flags

SetActionFlags()[source]

Sets list flags for parser

class roster_user_tools.action_flags.Make(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line mk flags

SetActionFlags()[source]

Sets make flags for parser

class roster_user_tools.action_flags.Remove(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line rm flags

SetActionFlags()[source]

Sets remove flags for parser

class roster_user_tools.action_flags.Update(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line up flags

SetActionFlags()[source]

Sets update flags for parser

cli_common_lib Module

Common library for DNS management command line tools.

exception roster_user_tools.cli_common_lib.ArgumentError[source]

Bases: exceptions.Exception

class roster_user_tools.cli_common_lib.CliCommonLib(options)[source]

Command line common library

DisallowFlags(disallow_list, parser)[source]

Dissallows certain command line flags.

Inputs:
disallow_list: list of command line flags to block parser: parser object from optparse
roster_user_tools.cli_common_lib.DnsError(message, exit_status=0)[source]

Prints standardized client error message to screen.

Inputs:
message: string of message to be displayed on screen exit_status: integer of retrun code, assumed not exit if 0
roster_user_tools.cli_common_lib.DnsWarning(message)[source]

Prints standardized warning message to screen.

Inputs:
message: string of message to be displayed on screen
roster_user_tools.cli_common_lib.EditFile(fname)[source]

Opens a file in a text editor in the EDITOR env variable for editing

Inputs:
fname: string of filename
Outputs:
int: return code from editor
exception roster_user_tools.cli_common_lib.HostsError[source]

Bases: exceptions.Exception

roster_user_tools.cli_common_lib.PrintColumns(print_list, first_line_header=False)[source]

Prints a table with aligned columns.

Inputs:
print_list: list of lists of columns file: string of filename
roster_user_tools.cli_common_lib.PrintHosts(records_dictionary, ip_address_list, view_name=None)[source]

Prints hosts in an /etc/hosts format

Inputs:
records_dictionary: dictionary of records ip_address_list: list of ip_addresses view_name: string of view_name
roster_user_tools.cli_common_lib.PrintSortedHosts(hosts_dict, print_headers=True)[source]

Prints sorted hosts in a nice usable format

Inputs:
hosts_dict: A dictionary of sort host lists keyed by views.
roster_user_tools.cli_common_lib.ServerError(message, uuid_string, exit_status=0)[source]

Prints standardized server error message to screen.

Inputs:
message: string of message to be displayed on screen exit_status: integer of retrun code, assumed not exit if 0
roster_user_tools.cli_common_lib.SortRecordsDict(records_dictionary, view_name)[source]

Retries records from database and sorts them

Inputs:
records_dictionary: dictionary of records from core view_name: string of view name
Outputs:
dict: sorted dictionary of records
roster_user_tools.cli_common_lib.UnknownError(error_class, uuid_string, message, exit_status=0)[source]

Prints standardized unknown error message to screen.

Inputs:
message: string of message to be displayed on screen exit_status: integer of retrun code, assumed not exit if 0
roster_user_tools.cli_common_lib.UserError(message, exit_status=0)[source]

Prints standardized user error message to screen.

Inputs:
message: string of message to be displayed on screen exit_status: integer of retrun code, assumed not exit if 0

cli_record_lib Module

Make record library for command line tools.

class roster_user_tools.cli_record_lib.CliRecordLib(cli_common_lib_instance)[source]

Command line record library class

ListRecords(record_type, options, record_args_dict)[source]

Lists records given certain parameters

Inputs:
options: options object from optparse record_args_dict: record arguments dictionary
Outputs:
list or string depending on record type
MakeRecord(record_type, options, record_args_dict, allow_duplicate=False, quiet=False, raise_errors=False, fix_ptr_origin=True)[source]

Connects to server and makes a DNS record.

Inputs:
record_type: record type options: options object from optparse record_args_dict: dictionary varying according to record record_type allow_duplicate: allow duplicate entries without causing error quiet: whether or not function should be quiet raise_errors: raise errors rather than printing
RemoveRecord(record_type, options, record_args_dict, quiet=False, raise_errors=False, fix_ptr_origin=True)[source]

Connects to server and removes a DNS record.

Inputs:
record_type: record type options: options object from optparse record_args_dict: dictionary varying according to record record_type quiet: whether or not function should be quiet raise_errors: raise errors rather than printing
exception roster_user_tools.cli_record_lib.RecordNotFoundException[source]

Bases: exceptions.Exception

core_flags Module

Core flags lib, flags in all tools.

class roster_user_tools.core_flags.CoreFlags(command, commands, args, usage, bootstrapper=False)[source]

Bases: object

Command line common library

AddFlagRule(flag_name, command=None, required=True, flag_type='args')[source]

Adds a key to functions dict

Inputs:
flag_name: string of flag name command: string of command (defaults to self.command) required: boolean of required flag (defaults to true) flag_type: type of flag (defaults to ‘args’)
CheckDataFlags()[source]

Returns the action the tool should perform

Inputs:
function: string of function, must be in functions functions: dictionary of uses from tool
Outputs:
string: string from uses keys of correct action
SetAllFlagRule(flag_name, required=True, flag_type='args')[source]

Adds a key to all args portions of functions dicts

Inputs:
flag_name: string of optparse flag name required: boolean of required flag (defaults to True) flag_type: type of flag (defaults to ‘args’)
SetCommands(functions)[source]

Sets self.functions_dict according to functions list

Inputs:

functions: list of strings of functions

Sets the self.functions_dict ex:

{‘list’: {‘args’: {}, ‘forbidden_args’:{}, ‘independent_args’: [],
‘dependent_args’: []},
{‘remove’: {‘args’: {}, ‘forbidden_args’:{}, ‘independent_args’: [],
‘dependent_args’: []}}

The list portion of the dictionary may be populated as shown below:

{‘list’: {‘args’: {‘user’: True, ‘verbose’: False},

‘forbidden_args’: {‘make_all’: False}, ‘independent_args’: [{‘allow’: False, ‘deny’: False},

{‘quiet’: False, ‘verbose’: False}],

‘dependent_args’: [{‘allow’: False, ‘allow_level’: True}]}}

Where ‘user’ is a required argument. The value represents whether or not the argument is required: True/False. Note ‘user’ is the name given in optparse, NOT the flag ‘-u/–user’. Verbose is not a required argument, but is listed in args and should be in case of any code changes. All args should be represented in portions of this dictionary. If ‘user’ is not supplied, the function will exit with error. ‘make_all’ is a forbidden argument. If it is used in this certain portion of a function, the user is probably mistaking what is happening with the command and the function will exit with error. Independent args must not be given simultaneously otherwise the function will exit with error. If these args are required, it will exit with error if one or the other is not specified. Dependent args are arguments that depend on each other, the function will error out if both are not supplied simultaneously.

SetCoreFlags()[source]

Sets core flags for parser

SetDefaultFlags()[source]

Sets all availible default flags to not required

for use with one command functions such as list functions

exception roster_user_tools.core_flags.FlagsError[source]

Bases: exceptions.Exception

data_flags Module

Data flags lib, flags for each group of tools.

class roster_user_tools.data_flags.Acl(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line acl flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.AuditLog(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line audit log flags

SetActionFlags()[source]

Method to set action variable since credential has no action class

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Bootstrap(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line bootstrap flags

SetActionFlags()[source]

Method to set action variable since set maintenance has no action class

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.CNAME(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line CNAME flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Credential(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line credential flags

SetActionFlags()[source]

Method to set action variable since credential has no action class

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.DnsServer(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line dns_server flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.FormattedRecords(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line formattedrecords flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Group(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line group flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Host(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line view flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Hosts(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line uphost flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.MassAdd(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line uphost flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.NamedGlobals(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line named global flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Record(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line record flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.ReservedWord(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line reserved word flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.SetMaintenance(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line set maintenenace flags

SetActionFlags()[source]

Method to set action variable since set maintenance has no action class

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.User(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.data_flags.Group

Command line user flags
The User class inherits all of Group’s flags so dnsupusergroup has the option of not including flags it doesn’t need. So know that if you call User.SetDataFlags(), you’ll get both Users’ and Group’s
Used by:
dnsupusergroup
SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.View(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line view flags

SetDataFlags()[source]

Sets flags for self.parser

class roster_user_tools.data_flags.Zone(command, commands, args, usage, bootstrapper=False)[source]

Bases: roster_user_tools.core_flags.CoreFlags

Command line zone flags

SetDataFlags()[source]

Sets flags for self.parser

roster_client_lib Module

Client library for XML RPC.

Connects to XML RPC server and runs arbitrary functions.

roster_user_tools.roster_client_lib.CheckCredentials(username, credfile, server, password=None)[source]

Checks if credential file is valid.

Inputs:
username: string of username credfile: string of credential file location server: string of server URL password: string of password
Outputs:
string: string of valid credential
roster_user_tools.roster_client_lib.CheckServerVersionMatch(server_name)[source]

Does a version check between this client and server

Inputs:
server_name: string name of server to check
roster_user_tools.roster_client_lib.GetCredentials(user_name, password, credfile=None, server_name=None)[source]

Gets credential string from CredCache.

Inputs:
user_name: string of user name password: string of password (plain text) ldap_server_name: string of ldap server url credfile: full path of credential file server_name: string of xml rpc server url
Outputs:
string: credential string
example: u’be4d4ecf-d670-44a0-b957-770e118e2755’
exception roster_user_tools.roster_client_lib.InvalidCredentials[source]

Bases: exceptions.Exception

roster_user_tools.roster_client_lib.IsAuthenticated(user_name, credfile, server_name=None)[source]

Checks credential file if it is valid.

Inputs:
user_name: string of user name credfile: full path of credential file location server_name: string of server name
Outputs:
bool: whether or not credential file is valid
roster_user_tools.roster_client_lib.RunFunction(function, user_name, credfile=None, credstring=None, args=[], kwargs={}, server_name=None, raise_errors=False, password=None)[source]

Runs an arbitrary function for SERVER

Inputs:
function: name of the function to be run user_name: user running the function args: list of arguments to be passed to function kwargs: dictionary of keyword arguments to be passed to function server_name: a string of the server name to connect to raise_errors: raise errors rather than printing
Outputs:
return from function in core