FIT IoT-Lab requires organization of new users: generate one from the urn
[sfa.git] / clientbin / sfiDeleteSliver.py
1 #! /usr/bin/env python
2
3 import sys
4
5 from sfa.util.sfalogging import logger
6 from sfa.client.sfi_commands import Commands
7 from sfa.rspecs.rspec import RSpec
8
9 logger.enable_console()
10 command = Commands(usage="%prog [options] node1 node2...",
11                    description="Delete slivers from the RSpec. " +
12                    "This command reads in an RSpec and outputs a modified " +
13                    "RSpec. Use this to remove nodes from your slice.")
14 command.add_nodefile_option()
15 command.prep()
16
17 if command.opts.infile:
18     rspec = RSpec(command.opts.infile)
19     nodes = []
20     if command.opts.nodefile:
21         f = open(command.opts.nodefile, "r")
22         nodes = f.read().split()
23         f.close()
24
25     try:
26         slivers = [{'hostname': node} for node in nodes]
27         rspec.version.remove_slivers(slivers)
28         print rspec.toxml()
29     except:
30         logger.log_exc("sfiDeleteSliver FAILED with nodes %s" % nodes)