pushcustdb module¶
-
class
pushcustdb.
DB
(db_path_name)¶ Bases:
object
Class DB with parameters used by all the methods to push DB info into Ansible and Salt.
-
static
ansible_push_inventory
(tinydb_log_file, ansible_hosts_path_name, ansible_backup_hosts_path_name, devices_to_push)¶ Backup of the
ansible/hosts
inventory file toansible/backup
directory.Generates a new
ansible/hosts
file based on the DB information (actual push of data).Parameters: - tinydb_log_file – log file to send the message after the operations are being completed
- ansible_hosts_path_name – full path name of the ansible hosts file
- ansible_backup_hosts_path_name – full path name of the ansible hosts file directory
- devices_to_push – list of devices to push
Returns: nothing
-
static
salt_push_inventory
(tinydb_log_file, salt_minion_path_name, salt_backup_directory, salt_pillar_directory, salt_backup_pillar_directory, salt_top_path_name, salt_states_directory, devices_to_push)¶ Backup
salt/config/minion
file tosalt/config/backup
directory.Generates a new minion file based on the actual minion file, but replacing the first lines (to be improved in order to review the content/update of the lines).
Generates the new
top.sls
file with the devices listed in the DB, and all the states only in the ‘*’ section.(To be improved to actually add the corresponding states to specific devices).
Backup
salt/config/pillar/\*.sls
files to/salt/config/backup/pillar directory
.Generates new
pillar/*device_name*.sls
files based on the content of the DB file, if the device has to be managed viasalt-proxy
according the DBsalt_proxy_required
field. With the following details:proxy: proxytype: napalm driver: ios host: dev_ip username: userid password: passwd optional_args: use_keys: True auto_rollback_on_error: True
Parameters: - tinydb_log_file – log file to send the message after the operations are being completed
- salt_minion_path_name – minion full path name
- salt_backup_directory – minion backup directory
- salt_pillar_directory – pillar .sls files directory
- salt_backup_pillar_directory – backup pillar *.sls directory
- salt_top_path_name – full path name of ‘’top.sls’’ file
- salt_states_directory – add all the states to the general
\'*'
section of thetop.sls
file - devices_to_push – list of devices to push to Ansible and Salt
Returns: nothing
-
select_devices_to_push
(filter_expression)¶ Provides a mechanism to filter the devices in the DB before pushing and replacing Ansible and Salt configuration.
Parameters: filter_expression – expression to use a the filter. Support RegEx. Returns: db_devices
with the filtered device list
-
static
-
pushcustdb.
_start_process
()¶ Checks if the
netor.conf
file exist according the local static variable_NETOR_HOME_DIRECTORY
.It supports passing as parameter the
_NETOR_HOME_DIRECTORY
in order to push to the DB specified in thenetor.conf
configuration file.Then execute the functions to push the DB content on Ansible ans Salt configuration files, according to the settings of the
netor.conf
configuration file.It supports filtering of the DB, with literal text or RegEx, in order to not import more devices than required. As an example, you could have several clients on a DB, and push only the clients with which you are working, or the same example applies to work per sites, per IP range, per device name, etc.
Restart of the Salt minion is required.
Returns: nothing