Inventory class¶
nornir_sql.plugins.inventory.sql
-
class
nornir_sql.plugins.inventory.sql.SQLInventory(sql_connection, hosts_query, groups_query='', groups_file=None, groups=None, defaults=None)[source]¶ Bases:
objectSQLInventory implements SQL inventory plugin for Nornir
-
__init__(sql_connection, hosts_query, groups_query='', groups_file=None, groups=None, defaults=None)[source]¶ Setup SQLInventory parameters
The SQL queries’ fields must stick to the naming convention as follows:
name: The device name in the inventoryhostname: Device’s hostname/fqdn/ip which is accessibleport: Port on the device is accessibleusername: Username on the devicepassword: Password on the deviceplatform: Platform to use with the connectiondata.extra1: Will be put todatawith the name ofextra1groups: Coma separated group names for this hostconnection_options: JSON formatted connection_options string
- Parameters
sql_connection (str) – SQL connection string. E.g.: ‘mssql+pymssql://@SERVERNAME/DBNAME’
hosts_query (str) – Query string for getting hosts. All fields must be named as above!
groups_query (str) – Query string for getting groups. All fields must be named as above!
groups_file (str) – YAML file path to group definition file. Ignored when groups_query or groups are specified!
groups (dict) – group definition as dict. Ignored when groups_query is specified!
defaults (dict) – dict of default values.
-