def __init__(self, packages=None, default=None): self.packages = tuple(symbol_by_name(maybe_path) for maybe_path in (packages or [devices])) self.default_device = symbol_by_name(default or devices.DefaultDevice) for cls in self.find_devices(): self.add(cls)
def get_device(host, **kwargs): """Return `Device` instance for specified host. Arguments for device (for write access use `write_` prefix): - **host** -- IP or hostname if snmp agent; - **port** -- agent UDP port, default 161; - **version** -- SNMP version, 1, 2 or 3; - **registry** -- custom registry class for class lookup; - **class_name** -- adapter class; - **community** -- SNMP community; - **sec_name** -- security name; - **sec_level** -- security level; - **auth_protocol** -- auth protocol; - **auth_passphrase** -- auth passphrase; - **priv_protocol** -- priv protocol; - **priv_passphrase** -- priv passphrase. Other arguments: - **manager** custom instance of manager class; - **device_cls** custom device class, will be used instead of autolookup. """ manager = symbol_by_name(kwargs.pop('manager', default_manager)) cls = symbol_by_name(kwargs.pop('device_cls', None)) cls = manager.get_class(host=host, **kwargs) if cls is None else cls return cls(host, **kwargs)