[Nodeshot] Latest changes thanks to your feedback

Nemesis nemesis at ninux.org
Sun Nov 24 16:21:42 CET 2013


On 11/20/2013 09:25 PM, Clauz wrote:
> On 11/20/2013 06:22 PM, Nemesis wrote:
>> Hi,
>>
>> First of all, thankyou all for the feedback you are sending.
>>
>> I've done most of thechanges that I needed to do after receiving your
>> answers to my latest technical questions.
>> This is surely the way to go, after receiving yourfeedback I feel much
>> more secure, so please keep to do so!
>>
>> And good news, hey Clauz, look at this code:
>>
>> *>>> device = Device.objects.get(name='RM5PomeziaSNode')**
>> *(0.015) SELECT "net_device"."id", "net_device"."added",
>> "net_device"."updated", "net_device"."access_level",
>> "net_device"."name", "net_device"."node_id", "net_
>> device"."type", "net_device"."status", "net_device"."location",
>> "net_device"."elev", "net_device"."os", "net_device"."os_version",
>> "net_device"."first_seen", "
>> net_device"."last_seen", "net_device"."description",
>> "net_device"."notes", "net_device"."data", "net_device"."shortcuts" FROM
>> "net_device" WHERE "net_device"."
>> name" = 'RM5PomeziaSNode' ; args=('RM5PomeziaSNode',)
>> *>>> device.connector.connect()**
>> *True
>> *>>> device.connector.get_os()**
>> *('AirOS', 'XM.ar7240.v5.3.3.sdk.9634.111221.2238')
>> *>>> device.connector.get_wireless_output_power()*
>> 27
>> *>>> device.connector.get_wireless_channel()**
>> *'5765'
>>>>> *device.connector.disconnect()*
>> I'm slowly getting the syntactic sugar I desire! And it's self
>> explanatory! :)
> Very sweet! :)
>
>> It willbe super cool to have a connector_class that uses SNMP or any
>> other lighter protocol instead of SSH.
>> This would save us the need of having to call "connect()" and
>> "disconnect()".
> Perhaps you can connect on the __init__ of the connector object and
> disconnect on __del__ ?
>

Hey clauz,

I found a solution:
if the instance has to execute a command but is not yet connected it
will connects automatically before proceeding.
The connection should be closed automatically by the __del__ method as
you suggested, although the python docs say this method is not
guaranteed to be called, for that reason in the internals I'm still
using connect() and disconnect(), just to be sure.

Updated example:
*>>> pomezia = Device.objects.get(name='RM5PomeziaSNode')*
(0.016) SELECT "net_device"."id", "net_device"."added",
"net_device"."updated", "net_device"."access_level",
"net_device"."name", "net_device"."node_id", "net_
device"."type", "net_device"."status", "net_device"."location",
"net_device"."elev", "net_device"."os", "net_device"."os_version",
"net_device"."first_seen", "
net_device"."last_seen", "net_device"."description",
"net_device"."notes", "net_device"."data", "net_device"."shortcuts" FROM
"net_device" WHERE "net_device"."
name" = 'RM5PomeziaSNode' ; args=('RM5PomeziaSNode',)
*>>> pomezia.connector.get_os()**
**('AirOS', 'XM.ar7240.v5.3.3.sdk.9634.111221.2238')*
>>>
*>>> pomezia.connector.get_wireless_dbm()**
**'-74'**
*>>>
*>>> pomezia.connector.get_wireless_mode()**
**'ap'**
*

I also moved the connector classes into the "ssh" folder, so it's
explicit that for other protocols the other classes will need to be in
an "snmp" folder.
It would be cool to experiment with an snmp connector prototype.. if we
lay it down together I should be able to go ahead alone.
Shall we organize an evening somewhen in the next month (before
christmas)? Like a Monday, Tuesday or Friday for me it's ok

Fed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ml.ninux.org/pipermail/nodeshot/attachments/20131124/b0ff9e09/attachment-0001.html>


More information about the Nodeshot mailing list