move clientbin one step upwards
[sfa.git] / clientbin / sfiListNodes.py
diff --git a/clientbin/sfiListNodes.py b/clientbin/sfiListNodes.py
new file mode 100755 (executable)
index 0000000..17cb341
--- /dev/null
@@ -0,0 +1,32 @@
+#! /usr/bin/env python
+
+import sys
+
+from sfa.client.sfi_commands import Commands
+
+from sfa.rspecs.rspec import RSpec
+
+from sfa.planetlab.plxrn import xrn_to_hostname 
+
+command = Commands(usage="%prog [options]",
+                   description="List all nodes in the RSpec. " + 
+                   "Use this to display the list of nodes on which it is " + 
+                   "possible to create a slice.")
+command.prep()
+
+if command.opts.infile:
+    rspec = RSpec(command.opts.infile)
+    nodes = rspec.version.get_nodes()
+    if command.opts.outfile:
+        sys.stdout = open(command.opts.outfile, 'w')
+    
+    for node in nodes:
+        hostname = None
+        if node.get('component_id'):
+            hostname = xrn_to_hostname(node['component_id'])
+        if hostname:
+            print hostname 
+
+
+
+