another pass onf shebangs
[sfa.git] / clientbin / sfiListSlivers.py
1 #!/usr/bin/env python3
2
3 import sys
4 from sfa.client.sfi_commands import Commands
5
6 from sfa.rspecs.rspec import RSpec
7
8 from sfa.planetlab.plxrn import xrn_to_hostname
9
10 command = Commands(usage="%prog [options]",
11                    description="List all slivers in the RSpec. " +
12                    "Use this to display the list of nodes belonging to " +
13                    "the slice.")
14 command.add_show_attributes_option()
15 command.prep()
16
17 if command.opts.infile:
18     rspec = RSpec(command.opts.infile)
19     nodes = rspec.version.get_nodes_with_slivers()
20
21     if command.opts.showatt:
22         defaults = rspec.version.get_default_sliver_attributes()
23         if defaults:
24             print("ALL NODES")
25             for (name, value) in defaults:
26                 print("  %s: %s" % (name, value))
27
28     for node in nodes:
29         hostname = None
30         if node.get('component_id'):
31             hostname = xrn_to_hostname(node['component_id'])
32         if hostname:
33             print(hostname)
34             if command.opts.showatt:
35                 atts = rspec.version.get_sliver_attributes(hostname)
36                 for (name, value) in atts:
37                     print("  %s: %s" % (name, value))