fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] non standard ssh


From: Ben Abrams
Subject: Re: [Fab-user] non standard ssh
Date: Tue, 25 Nov 2014 20:45:13 -0800

Beryl,

On your first question: Can you explain your use case more? What does this application do? Why are you looking at Fabric? Fabric is basically an SSH library for python so I am not really sure how to tackle this.

On the second can you provide a sample scrubbed output and what you want to parse? What are you expecting to do with this? Are you doing to use this to trigger something? 

I think you are over complicating things though I am not really sure what you are even parsing for. Without knowing what you want to do all I can do is replicate functionality of proposed solution. 


import re

def someRandomParsing(cmd, phrase):
out=run(cmd)
list_of_out=out.split('\n')
for i in range(0, len(list_of_out)-1):
if re.search(phrase,str(list_of_out[i])):
print str(list_of_out[i])

$ fab -H localhost someRandomParsing:cmd='ifconfig',phrase='inet'
[localhost] Executing task 'someRandomParsing'
[localhost] run: ifconfig
[localhost] out: lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
[localhost] out: options=3<RXCSUM,TXCSUM>
[localhost] out: inet6 ::1 prefixlen 128
[localhost] out: inet 127.0.0.1 netmask 0xff000000
[localhost] out: inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
[localhost] out: inet 127.94.0.2 netmask 0xff000000
[localhost] out: inet 127.94.0.1 netmask 0xff000000
[localhost] out: nd6 options=1<PERFORMNUD>
[localhost] out: gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
[localhost] out: stf0: flags=0<> mtu 1280
[localhost] out: en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[localhost] out: ether 3c:15:c2:c8:5e:48
[localhost] out: inet6 fe80::3e15:c2ff:fec8:5e48%en0 prefixlen 64 scopeid 0x4
[localhost] out: inet 10.41.0.95 netmask 0xffff0000 broadcast 10.41.255.255
[localhost] out: nd6 options=1<PERFORMNUD>
[localhost] out: media: autoselect
[localhost] out: status: active
[localhost] out: en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
[localhost] out: options=60<TSO4,TSO6>
[localhost] out: ether 72:00:03:57:4b:40
[localhost] out: media: autoselect <full-duplex>
[localhost] out: status: inactive
[localhost] out: en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
[localhost] out: options=60<TSO4,TSO6>
[localhost] out: ether 72:00:03:57:4b:41
[localhost] out: media: autoselect <full-duplex>
[localhost] out: status: inactive
[localhost] out: p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
[localhost] out: ether 0e:15:c2:c8:5e:48
[localhost] out: media: autoselect
[localhost] out: status: inactive
[localhost] out: awdl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1452
[localhost] out: ether 12:1b:f7:01:2d:46
[localhost] out: inet6 fe80::101b:f7ff:fe01:2d46%awdl0 prefixlen 64 scopeid 0x8
[localhost] out: nd6 options=1<PERFORMNUD>
[localhost] out: media: autoselect
[localhost] out: status: active
[localhost] out: bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[localhost] out: options=63<RXCSUM,TXCSUM,TSO4,TSO6>
[localhost] out: ether 3e:15:c2:8c:ad:00
[localhost] out: Configuration:
[localhost] out: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
[localhost] out: maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
[localhost] out: root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
[localhost] out: ipfilter disabled flags 0x2
[localhost] out: member: en1 flags=3<LEARNING,DISCOVER>
[localhost] out:        ifmaxaddr 0 port 5 priority 0 path cost 0
[localhost] out: member: en2 flags=3<LEARNING,DISCOVER>
[localhost] out:        ifmaxaddr 0 port 6 priority 0 path cost 0
[localhost] out: nd6 options=1<PERFORMNUD>
[localhost] out: media: <unknown type>
[localhost] out: status: inactive
[localhost] out: utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
[localhost] out: inet 10.106.0.86 --> 10.106.0.85 netmask 0xffffffff
[localhost] out: vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[localhost] out: ether 0a:00:27:00:00:00
[localhost] out: inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
[localhost] out:

inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.94.0.2 netmask 0xff000000
inet 127.94.0.1 netmask 0xff000000
inet6 fe80::3e15:c2ff:fec8:5e48%en0 prefixlen 64 scopeid 0x4
inet 10.41.0.95 netmask 0xffff0000 broadcast 10.41.255.255
inet6 fe80::101b:f7ff:fe01:2d46%awdl0 prefixlen 64 scopeid 0x8
inet 10.106.0.86 --> 10.106.0.85 netmask 0xffffffff

Done.
Disconnecting from localhost... done.

Thanks,

On Mon, Nov 24, 2014 at 4:19 PM, Beryl Snyder <address@hidden> wrote:
Is there any way for me to change the command that fabric uses?  I don't want it to run ssh I've got another application that I want it to run that works with ssh.  

ex: have fabric connect via foo address@hidden and not have fabric open ssh address@hidden? or better yet tell fabric what one to use? 

Secondly, 

when I do something like out = run('omreport storage controller controller=0')
I get a wall of text, I'd like to filter the text, what's the best way to pars it? 

I'm doing this currently but am getting in to trouble with list of lists.
 If run 

    list_of_items = [i.split() for i in items]
    sizes = len(list_of_items)
    count = 0
    while count != sizes:
    print list_of_items[count]
    count += 1
    pass
I get a bunch of lists,

But if I run this I don't get anything printed,

    list_of_items = [i.split() for i in items]
    sizes = len(list_of_items)
    count = 0
    while count != sizes:
     if any('string') in list_of_items[count]:
     print list_of_items[count]
     count += 1
     pass

 I Don't know what I'm doing wrong, Think it's less of a Fabric issue and more of a Coding issue. 


_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user




--
Ben Abrams
Computer Consultant
702-900-7926
benabrams.it
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]