Inventory¶
Inventory¶
-
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
-
dict
() → Dict¶ Return serialized dictionary of inventory
-
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
-
Host¶
-
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.Parameters: - item (
str
) – The variable to get - default (
any
) – Return value if item not found
- item (
-
get_connection
(connection: str, configuration: nornir.core.configuration.Config) → Any¶ The function of this method is twofold:
- If an existing connection is already established for the given type return it
- 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 typeParameters: 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.
-
items
()¶ Returns all the data accessible from a device, including the one inherited from parent groups
-
keys
()¶ 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 toTrue
arguments will default to host attributes if not specified.Raises: AttributeError
– if it’s unknown how to establish a connection for the given typeReturns: An already established connection
-
values
()¶ Returns the values of the attribute
data
and of the parent(s) groups.
-