nornir.core.inventory
class nornir.core.inventory.BaseAttributes
(hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None)
dict
() → Dict[str, Any]hostname
password
platform
port
classmethod
schema
() → Dict[str, Any]username
class nornir.core.inventory.ConnectionOptions
(hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None, extras: Optional[Dict[str, Any]] = None)
dict
() → Dict[str, Any]extras
classmethod
schema
() → Dict[str, Any]
class nornir.core.inventory.Defaults
(hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None, data: Optional[Dict[str, Any]] = None, connection_options: Optional[Dict[str, nornir.core.inventory.ConnectionOptions]] = None)
connection_options
data
dict
() → Dict[str, Any]classmethod
schema
() → Dict[str, Any]
class nornir.core.inventory.Group
(name: str, hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None, groups: Optional[nornir.core.inventory.ParentGroups] = None, data: Optional[Dict[str, Any]] = None, connection_options: Optional[Dict[str, nornir.core.inventory.ConnectionOptions]] = None, defaults: Optional[nornir.core.inventory.Defaults] = None)
class nornir.core.inventory.Groups
class nornir.core.inventory.Host
(name: str, hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None, groups: Optional[nornir.core.inventory.ParentGroups] = None, data: Optional[Dict[str, Any]] = None, connection_options: Optional[Dict[str, nornir.core.inventory.ConnectionOptions]] = None, defaults: Optional[nornir.core.inventory.Defaults] = None)
close_connection
(connection: str) → NoneClose the connection
close_connections
() → Noneconnections
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) → AnyReturns 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) → AnyThe 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.ConnectionOptionshas_parent_group
(group: Union[str, Group]) → boolReturns 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: 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.plugins.connections.ConnectionPluginOpen 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 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: nornir.core.inventory.Hosts, groups: Optional[nornir.core.inventory.Groups] = None, defaults: Optional[nornir.core.inventory.Defaults] = None, transform_function: Callable[[nornir.core.inventory.Host, Any], None] = None, transform_function_options: Optional[Dict[str, Any]] = None)
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
defaults
dict
() → Dict[str, Any]Return serialized dictionary of inventory
filter
(filter_obj: Callable[[nornir.core.inventory.Host, Any], bool] = None, filter_func: Callable[[nornir.core.inventory.Host, Any], bool] = None, \*kwargs*) → nornir.core.inventory.Inventorygroups
hosts
classmethod
schema
() → Dict[str, Any]Return serialized dictionary of inventory
class nornir.core.inventory.InventoryElement
(hostname: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, platform: Optional[str] = None, groups: Optional[nornir.core.inventory.ParentGroups] = None, data: Optional[Dict[str, Any]] = None, connection_options: Optional[Dict[str, nornir.core.inventory.ConnectionOptions]] = None)
connection_options
data
dict
() → Dict[str, Any]extended_groups
() → List[nornir.core.inventory.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
add
(group: nornir.core.inventory.Group) → NoneAdd the ParentGroup. The group will only be appended if it does not exist.
Parameters: group – Parent Group object to add Returns: None