#! /usr/bin/env python import sys from sfa.util.sfalogging import logger from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec logger.enable_console() command = Commands(usage="%prog [options] node1 node2...", description="Delete slivers from the RSpec. " + "This command reads in an RSpec and outputs a modified " + "RSpec. Use this to remove nodes from your slice.") command.add_nodefile_option() command.prep() if command.opts.infile: rspec = RSpec(command.opts.infile) nodes = [] if command.opts.nodefile: f = open(command.opts.nodefile, "r") nodes = f.read().split() f.close() try: slivers = [{'hostname': node} for node in nodes] rspec.version.remove_slivers(slivers) print rspec.toxml() except: logger.log_exc("sfiDeleteSliver FAILED with nodes %s" % nodes)
#! /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
#! /usr/bin/env python import sys from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec command = Commands( usage="%prog [options]", description="List all slivers in the RSpec. " + "Use this to display the list of nodes belonging to " + "the slice.", ) command.add_show_attributes_option() command.prep() if command.opts.infile: rspec = RSpec(command.opts.infile) nodes = rspec.version.get_nodes_with_slivers() if command.opts.showatt: 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: print node if command.opts.showatt: atts = rspec.version.get_sliver_attributes(node) for (name, value) in atts:
#! /usr/bin/env python import sys from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec from sfa.util.xrn import Xrn command = Commands(usage="%prog [options]", description="List all links in the RSpec. " + "Use this to display the list of available links. ") command.prep() if command.opts.infile: rspec = RSpec(command.opts.infile) links = rspec.version.get_links() if command.opts.outfile: sys.stdout = open(command.opts.outfile, 'w') for link in links: ifname1 = Xrn(link['interface1']['component_id']).get_leaf() ifname2 = Xrn(link['interface2']['component_id']).get_leaf() print "%s %s" % (ifname1, ifname2)
#! /usr/bin/env python import sys from sfa.util.sfalogging import logger from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec from sfa.rspecs.version_manager import VersionManager logger.enable_console() command = Commands(usage="%prog [options] node1 node2...", description="Add links to the RSpec. " + "This command reads in an RSpec and outputs a modified " + "RSpec. Use this to add links to your slivers") command.add_linkfile_option() command.prep() if not command.opts.linkfile: print "Missing link list -- exiting" command.parser.print_help() sys.exit(1) if command.opts.infile: infile=file(command.opts.infile) else: infile=sys.stdin if command.opts.outfile: outfile=file(command.opts.outfile,"w") else: outfile=sys.stdout ad_rspec = RSpec(infile)
#! /usr/bin/env python import sys from sfa.util.sfalogging import logger from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec logger.enable_console() command = Commands(usage="%prog [options] [node1 node2...]", description="Delete sliver attributes from the RSpec. " + "This command reads in an RSpec and outputs a modified " + "RSpec. Use this to remove attributes from nodes " + "in your slice. If no nodes are specified, the " + "attributes will be removed from ALL nodes.", epilog="NOTE: Only admins can actually set these " + "attributes, with the exception of --delegations") command.add_nodefile_option() command.add_attribute_options() command.prep() if command.opts.infile: attrs = command.get_attribute_dict() rspec = RSpec(command.opts.infile) nodes = [] if command.opts.nodefile: f = open(command.opts.nodefile, "r") nodes = f.read().split() f.close() for name in attrs:
#! /usr/bin/env python import sys from sfa.util.sfalogging import logger from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec from sfa.rspecs.version_manager import VersionManager logger.enable_console() command = Commands(usage="%prog [options] node1 node2...", description="Add links to the RSpec. " + "This command reads in an RSpec and outputs a modified " + "RSpec. Use this to add links to your slivers") command.add_linkfile_option() command.prep() if not command.opts.linkfile: print "Missing link list -- exiting" command.parser.print_help() sys.exit(1) if command.opts.infile: infile = file(command.opts.infile) else: infile = sys.stdin if command.opts.outfile: outfile = file(command.opts.outfile, "w") else: outfile = sys.stdout ad_rspec = RSpec(infile)
#! /usr/bin/env python import sys from sfa.util.sfalogging import logger from sfa.client.sfi_commands import Commands from sfa.rspecs.rspec import RSpec logger.enable_console() command = Commands(usage="%prog [options] [node1 node2...]", description="Add sliver attributes to the RSpec. " + "This command reads in an RSpec and outputs a modified " + "RSpec. Use this to add attributes to individual nodes " + "in your slice. If no nodes are specified, the " + "attributes will be added to ALL nodes.", epilog="NOTE: Only admins can actually set these " + "attributes, with the exception of --delegations") command.add_nodefile_option() command.add_attribute_options() command.prep() if command.opts.infile: attrs = command.get_attribute_dict() rspec = RSpec(command.opts.infile) nodes = [] if command.opts.nodefile: f = open(command.opts.nodefile, "r") nodes = f.read().split() f.close()
#! /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 slivers in the RSpec. " + "Use this to display the list of nodes belonging to " + "the slice.") command.add_show_attributes_option() command.prep() if command.opts.infile: rspec = RSpec(command.opts.infile) nodes = rspec.version.get_nodes_with_slivers() if command.opts.showatt: 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'])