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