nornir.core.inventory
- class nornir.core.inventory.BaseAttributes(hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None)
- dict() Dict[str, Any]
- hostname
- password
- platform
- port
- classmethod schema() Dict[str, Any]
- username
- class nornir.core.inventory.ConnectionOptions(hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None, extras: Dict[str, Any] | None = None)
- dict() Dict[str, Any]
- extras
- classmethod schema() Dict[str, Any]
- class nornir.core.inventory.Defaults(hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None, data: Dict[str, Any] | None = None, connection_options: Dict[str, ConnectionOptions] | None = None)
- connection_options
- data
- dict() Dict[str, Any]
- classmethod schema() Dict[str, Any]
- class nornir.core.inventory.FilterObj(*args, **kwargs)
- class nornir.core.inventory.Group(name: str, hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None, groups: ParentGroups | None = None, data: Dict[str, Any] | None = None, connection_options: Dict[str, ConnectionOptions] | None = None, defaults: Defaults | None = None)
- connections: Dict[str, ConnectionPlugin]
- defaults
- name
- class nornir.core.inventory.Groups
- class nornir.core.inventory.Host(name: str, hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None, groups: ParentGroups | None = None, data: Dict[str, Any] | None = None, connection_options: Dict[str, ConnectionOptions] | None = None, defaults: Defaults | None = None)
- close_connection(connection: str) None
Close the connection
- close_connections() None
- connections: Dict[str, ConnectionPlugin]
- defaults
- dict() Dict[str, Any]
- extended_data() Dict[str, Any]
Returns the data associated with the object including inherited data
- get(item: str, default: Any = None) Any
Returns the value
item
from the host or hosts group variables.- Parameters:
item (
str
) – The variable to getdefault (
any
) – Return value if item not found
- get_connection(connection: str, 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 type
- Parameters:
connection – Name of the connection, for instance, netmiko, paramiko, napalm…
- Returns:
An already established connection
- get_connection_parameters(connection: str | None = None) ConnectionOptions
- has_parent_group(group: str | Group) bool
Returns whether the object is a child of the
Group
group
- items() ItemsView[str, Any]
Returns all the data accessible from a device, including the one inherited from parent groups
- keys() KeysView[str]
Returns the keys of the attribute
data
and of the parent(s) groups.
- name
- open_connection(connection: str, configuration: Config, hostname: str | None = None, username: str | None = None, password: str | None = None, port: int | None = None, platform: str | None = None, extras: Dict[str, Any] | None = None, default_to_host_attributes: bool = True) 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 type
- Returns:
An already established connection
- classmethod schema() Dict[str, Any]
- values() ValuesView[Any]
Returns the values of the attribute
data
and of the parent(s) groups.
- class nornir.core.inventory.Hosts
- class nornir.core.inventory.Inventory(hosts: Hosts, groups: Groups | None = None, defaults: Defaults | None = None, transform_function: TransformFunction | None = None, transform_function_options: Dict[str, Any] | None = None)
- children_of_group(group: str | Group) Set[Host]
Returns set of hosts that belongs to a group including those that belong indirectly via inheritance
- defaults
- dict() Dict[str, Any]
Return serialized dictionary of inventory
- filter(filter_obj: FilterObj | None = None, filter_func: FilterObj | None = None, **kwargs: Any) Inventory
- groups
- hosts
- classmethod schema() Dict[str, Any]
Return serialized dictionary of inventory
- class nornir.core.inventory.InventoryElement(hostname: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, platform: str | None = None, groups: ParentGroups | None = None, data: Dict[str, Any] | None = None, connection_options: Dict[str, ConnectionOptions] | None = None)
- connection_options
- data
- dict() Dict[str, Any]
- extended_groups() List[Group]
Returns the groups this host belongs to by virtue of inheritance.
This list is ordered based on the inheritance rules and groups are not duplicated. For instance, given a host with the following groups:
- hostA:
- groups:
group_a
group_b
- group_a:
- groups:
group_1
group_2
- group_b:
- groups:
group_2
group_3
- group_1:
- groups:
group_X
this will return [group_a, group_1, group_X, group_2, group_b, group_3]
- groups
- classmethod schema() Dict[str, Any]
- class nornir.core.inventory.ParentGroups(iterable=(), /)
- class nornir.core.inventory.TransformFunction(*args, **kwargs)