Merge branch 'upstreammaster'
[sfa.git] / sfa / client / sfiListSlivers.py
index 685521c..c869f61 100755 (executable)
@@ -1,7 +1,9 @@
 #! /usr/bin/env python
 
 import sys
-from sfa.util.rspecHelper import RSpec, Commands
+from sfa.client.sfi_commands import Commands
+from sfa.rspecs.rspec import RSpec
+from sfa.util.plxrn import xrn_to_hostname
 
 command = Commands(usage="%prog [options]",
                    description="List all slivers in the RSpec. " + 
@@ -10,19 +12,26 @@ command = Commands(usage="%prog [options]",
 command.add_show_attributes_option()
 command.prep()
 
-nodes = command.rspec.get_sliver_list()
-if command.opts.showatt:
-    defaults = command.rspec.get_default_sliver_attributes()
-    if defaults:
-        print "ALL NODES"
-        for (name, value) in defaults:
-            print "  %s: %s" % (name, value)
-
-for node in nodes:
-    print node
+if command.opts.infile:
+    rspec = RSpec(command.opts.infile)
+    nodes = rspec.version.get_nodes_with_slivers()
+    
     if command.opts.showatt:
-        atts = command.rspec.get_sliver_attributes(node)
-        for (name, value) in atts:
-            print "  %s: %s" % (name, value)
+        defaults = rspec.version.get_default_sliver_attributes()
+        if defaults:
+            print "ALL NODES"
+            for (name, value) in defaults:
+                print "  %s: %s" % (name, value)        
+
+    for node in nodes:
+        hostname = None
+        if node.get('component_id'):
+            hostname = xrn_to_hostname(node['component_id'])
+        if hostname:
+            print hostname
+            if command.opts.showatt:
+                atts = rspec.version.get_sliver_attributes(hostname)
+                for (name, value) in atts:
+                    print "  %s: %s" % (name, value)