The following code snippet gives me an error, but with other objects that works fine.
>>> from pyroute2 import NDB
>>> ndb = NDB()
>>> ndb.sources
AttributeError: type object 'Source' has no attribute '_count'
list(ndb.sources)
AttributeError: type object 'Source' has no attribute '_count'
With this patchset applied I got the following output:
>>> ndb.sources
NDB view for sources
Number of objects: 2
to list objects use .summary() or .dump()
-> RecordSet (generator)
-> Record
key: Union[Record, dict, spec]
to get objects use ...[key] / .__getitem__(key)
-> RTNL_Object
>>> list(ndb.sources)
['localhost', 'localhost/nsmanager']
The reason behind the absence of this method is that Source subclasses dict, and there is no real interface in terms of typing that is common to Source and other NDB objects (which subclass RTNL_object). Therefore, with this PR, I am addressing only the consequence, not the root cause.
Also sources documentation has usage of an inexistent method .details(), so I gave some love to the docs too.
The the one thing I'm not sure, is the following statement:
By default NDB starts with one local RTNL source names localhost
It seems I have 2 sources on my pretty default setup. So waiting for your guidance here :)
The two sources are the default RTNL source and the network namespaces manager, you can run ndb.sources.summary(), or even ndb.sources.dump().format("json")
The following code snippet gives me an error, but with other objects that works fine.
With this patchset applied I got the following output:
The reason behind the absence of this method is that
Source
subclassesdict
, and there is no real interface in terms of typing that is common toSource
and other NDB objects (which subclassRTNL_object
). Therefore, with this PR, I am addressing only the consequence, not the root cause.Also sources documentation has usage of an inexistent method
.details()
, so I gave some love to the docs too. The the one thing I'm not sure, is the following statement:It seems I have 2 sources on my pretty default setup. So waiting for your guidance here :)