a little nicer wrt pep8
[sfa.git] / clientbin / sfiListLinks.py
1 #!/usr/bin/env python3
2
3 import sys
4 from sfa.client.sfi_commands import Commands
5 from sfa.rspecs.rspec import RSpec
6 from sfa.util.xrn import Xrn
7
8 command = Commands(usage="%prog [options]",
9                    description="List all links in the RSpec. " +
10                    "Use this to display the list of available links. ")
11 command.prep()
12
13 if command.opts.infile:
14     rspec = RSpec(command.opts.infile)
15     links = rspec.version.get_links()
16     if command.opts.outfile:
17         sys.stdout = open(command.opts.outfile, 'w')
18
19     for link in links:
20         ifname1 = Xrn(link['interface1']['component_id']).get_leaf()
21         ifname2 = Xrn(link['interface2']['component_id']).get_leaf()
22         print("%s %s" % (ifname1, ifname2))