class nornir.core.inventory.Inventory(hosts: nornir.core.inventory.Hosts, groups: Optional[nornir.core.inventory.Groups] = None, defaults: Optional[nornir.core.inventory.Defaults] = None, transform_function=None, transform_function_options=None)
add_group(name: str, **kwargs) → None

Add a group to the inventory after initialization

add_host(name: str, **kwargs) → None

Add a host to the inventory after initialization

children_of_group(group: Union[str, nornir.core.inventory.Group]) → Set[nornir.core.inventory.Host]

Returns set of hosts that belongs to a group including those that belong indirectly via inheritance

filter(filter_obj=None, filter_func=None, *args, **kwargs)
get_defaults_dict() → Dict

Returns serialized dictionary of defaults from inventory

get_groups_dict() → Dict

Returns serialized dictionary of groups from inventory

get_hosts_dict() → Dict

Returns serialized dictionary of hosts from inventory

get_inventory_dict() → Dict

Return serialized dictionary of inventory


class nornir.core.inventory.Host(name: str, defaults: Optional[nornir.core.inventory.Defaults] = None, **kwargs)
close_connection(connection: str) → None

Close the connection

close_connections() → None
get(item, default=None)

Returns the value item from the host or hosts group variables.

  • item (str) – The variable to get
  • default (any) – Return value if item not found
get_connection(connection: str, configuration: nornir.core.configuration.Config) → Any

The function of this method is twofold:

  1. If an existing connection is already established for the given type return it
  2. If none exists, establish a new connection of that type with default parameters and return it
Raises:AttributeError – if it’s unknown how to establish a connection for the given type
Parameters:connection – Name of the connection, for instance, netmiko, paramiko, napalm…
Returns:An already established connection
get_connection_parameters(connection: Optional[str] = None) → nornir.core.inventory.ConnectionOptions
get_connection_state(connection: str) → Dict[str, Any]

For an already established connection return its state.


Retuns whether the object is a child of the Group group


Returns all the data accessible from a device, including the one inherited from parent groups


Returns the keys of the attribute data and of the parent(s) groups.

open_connection(connection: str, configuration: nornir.core.configuration.Config, hostname: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, port: Optional[int] = None, platform: Optional[str] = None, extras: Optional[Dict[str, Any]] = None, default_to_host_attributes: bool = True) → nornir.core.connections.ConnectionPlugin

Open a new connection.

If default_to_host_attributes is set to True arguments will default to host attributes if not specified.

Raises:AttributeError – if it’s unknown how to establish a connection for the given type
Returns:An already established connection

Returns the values of the attribute data and of the parent(s) groups.


class nornir.core.inventory.Group(name: str, defaults: Optional[nornir.core.inventory.Defaults] = None, **kwargs)


class nornir.core.inventory.Defaults(data: Optional[Dict[str, Any]] = None, connection_options: Optional[Dict[str, nornir.core.inventory.ConnectionOptions]] = None, **kwargs)