Modified slab import script to create authorities only if it doesn't exist.
[sfa.git] / sfa / client / sfiDeleteSliver.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
7 command = Commands(usage="%prog [options] node1 node2...",
8                    description="Delete slivers from the RSpec. " +
9                    "This command reads in an RSpec and outputs a modified " +
10                    "RSpec. Use this to remove nodes from your slice.")
11 command.add_nodefile_option()
12 command.prep()
13
14 if command.opts.infile:
15     rspec = RSpec(command.opts.infile)
16     nodes = []
17     if command.opts.nodefile:
18         f = open(command.opts.nodefile, "r")
19         nodes = f.read().split()
20         f.close()
21        
22     try:
23         slivers = [{'hostname': node} for node in nodes]
24         rspec.version.remove_slivers(slivers)
25         print rspec.toxml()
26     except:
27         print >> sys.stderr, "FAILED: %s" % nodes 
28
29     
30
31