extract/separate binary clients in sfa/clientbin
[sfa.git] / sfa / clientbin / sfiListNodes.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 nodes in the RSpec. " + 
10                    "Use this to display the list of nodes on which it is " + 
11                    "possible to create a slice.")
12 command.prep()
13
14 if command.opts.infile:
15     rspec = RSpec(command.opts.infile)
16     nodes = rspec.version.get_nodes()
17     if command.opts.outfile:
18         sys.stdout = open(command.opts.outfile, 'w')
19     
20     for node in nodes:
21         hostname = None
22         if node.get('component_id'):
23             hostname = xrn_to_hostname(node['component_id'])
24         if hostname:
25             print hostname 
26
27
28
29