<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 11/20/2013 09:25 PM, Clauz wrote:<br>
    </div>
    <blockquote cite="mid:528D1AC8.1070608@ninux.org" type="cite">
      <pre wrap="">On 11/20/2013 06:22 PM, Nemesis wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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'
</pre>
        <blockquote type="cite">
          <blockquote type="cite">
            <blockquote type="cite">
              <pre wrap="">*device.connector.disconnect()*
</pre>
            </blockquote>
          </blockquote>
        </blockquote>
        <pre wrap="">
I'm slowly getting the syntactic sugar I desire! And it's self
explanatory! :)
</pre>
      </blockquote>
      <pre wrap="">
Very sweet! :)

</pre>
      <blockquote type="cite">
        <pre wrap="">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()".
</pre>
      </blockquote>
      <pre wrap="">
Perhaps you can connect on the __init__ of the connector object and
disconnect on __del__ ?

</pre>
    </blockquote>
    <br>
    Hey clauz,<br>
    <br>
    I found a solution:<br>
    if the instance has to execute a command but is not yet connected it
    will connects automatically before proceeding.<br>
    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.<br>
    <br>
    Updated example:<br>
    <b><tt>>>> pomezia =
        Device.objects.get(name='RM5PomeziaSNode')</tt></b><tt><br>
    </tt><tt>(0.016) SELECT "net_device"."id", "net_device"."added",
      "net_device"."updated", "net_device"."access_level",
      "net_device"."name", "net_device"."node_id", "net_</tt><tt><br>
    </tt><tt>device"."type", "net_device"."status",
      "net_device"."location", "net_device"."elev", "net_device"."os",
      "net_device"."os_version", "net_device"."first_seen", "</tt><tt><br>
    </tt><tt>net_device"."last_seen", "net_device"."description",
      "net_device"."notes", "net_device"."data",
      "net_device"."shortcuts" FROM "net_device" WHERE "net_device"."</tt><tt><br>
    </tt><tt>name" = 'RM5PomeziaSNode' ; args=('RM5PomeziaSNode',)</tt><tt><br>
    </tt><b><tt>>>> pomezia.connector.get_os()</tt></b><b><tt><br>
      </tt></b><b><tt>('AirOS', 'XM.ar7240.v5.3.3.sdk.9634.111221.2238')</tt></b><tt><br>
      >>><br>
    </tt><b><tt>>>> pomezia.connector.get_wireless_dbm()</tt></b><b><tt><br>
      </tt></b><tt><b>'-74'</b><b><br>
      </b>>>><br>
    </tt><b><tt>>>> pomezia.connector.get_wireless_mode()</tt></b><b><tt><br>
      </tt></b><b><tt>'ap'</tt></b><b><br>
    </b><br>
    <br>
    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.<br>
    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.<br>
    Shall we organize an evening somewhen in the next month (before
    christmas)? Like a Monday, Tuesday or Friday for me it's ok<br>
    <br>
    Fed<br>
  </body>
</html>