X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fsfi_commands.py;h=a8724b1ca060bc55e69df28113af979c71c40da9;hb=713d58df0baa1f9739eec9bfa30ceb41d7149e23;hp=bdcc16d496526c74c0ae22ef82eb1921404a44e7;hpb=ccd6b8232b5cf18d28e3a7e3a87b87d7aaa9970b;p=sfa.git diff --git a/sfa/client/sfi_commands.py b/sfa/client/sfi_commands.py index bdcc16d4..a8724b1c 100755 --- a/sfa/client/sfi_commands.py +++ b/sfa/client/sfi_commands.py @@ -3,7 +3,9 @@ import sys from optparse import OptionParser + class Commands: + def __init__(self, usage, description, epilog=None): self.parser = OptionParser(usage=usage, description=description, epilog=epilog) @@ -12,17 +14,24 @@ class Commands: self.parser.add_option("-o", "", dest="outfile", metavar="FILE", help="write output to FILE (default is stdout)") self.nodefile = False + self.linkfile = False self.attributes = {} def add_nodefile_option(self): self.nodefile = True - self.parser.add_option("-n", "", dest="nodefile", + self.parser.add_option("-n", "", dest="nodefile", metavar="FILE", help="read node list from FILE"), + def add_linkfile_option(self): + self.linkfile = True + self.parser.add_option("-l", "", dest="linkfile", + metavar="FILE", + help="read link list from FILE") + def add_show_attributes_option(self): - self.parser.add_option("-s", "--show-attributes", action="store_true", - dest="showatt", default=False, + self.parser.add_option("-s", "--show-attributes", action="store_true", + dest="showatt", default=False, help="show sliver attributes") def add_attribute_options(self): @@ -34,73 +43,73 @@ class Commands: help="Demux HTTP between slices using " + "localhost ports") self.parser.add_option("", "--cpu-pct", action="append", - metavar="", + metavar="", help="Reserved CPU percent (e.g., 25)") self.parser.add_option("", "--cpu-share", action="append", - metavar="", + metavar="", help="Number of CPU shares (e.g., 5)") - self.parser.add_option("", "--delegations", + self.parser.add_option("", "--delegations", metavar="", action="append", help="List of slices with delegation authority") - self.parser.add_option("", "--disk-max", + self.parser.add_option("", "--disk-max", metavar="", action="append", help="Disk quota (1k disk blocks)") - self.parser.add_option("", "--initscript", + self.parser.add_option("", "--initscript", metavar="", action="append", help="Slice initialization script (e.g., stork)") self.parser.add_option("", "--ip-addresses", action="append", - metavar="", + metavar="", help="Add an IP address to a sliver") - self.parser.add_option("", "--net-i2-max-kbyte", + self.parser.add_option("", "--net-i2-max-kbyte", metavar="", action="append", help="Maximum daily network Tx limit " + "to I2 hosts.") - self.parser.add_option("", "--net-i2-max-rate", + self.parser.add_option("", "--net-i2-max-rate", metavar="", action="append", help="Maximum bandwidth over I2 routes") - self.parser.add_option("", "--net-i2-min-rate", + self.parser.add_option("", "--net-i2-min-rate", metavar="", action="append", help="Minimum bandwidth over I2 routes") - self.parser.add_option("", "--net-i2-share", + self.parser.add_option("", "--net-i2-share", metavar="", action="append", help="Number of bandwidth shares over I2 routes") - self.parser.add_option("", "--net-i2-thresh-kbyte", + self.parser.add_option("", "--net-i2-thresh-kbyte", metavar="", action="append", help="Limit sent to I2 hosts before warning, " + "throttling") - self.parser.add_option("", "--net-max-kbyte", + self.parser.add_option("", "--net-max-kbyte", metavar="", action="append", help="Maximum daily network Tx limit " + "to non-I2 hosts.") - self.parser.add_option("", "--net-max-rate", + self.parser.add_option("", "--net-max-rate", metavar="", action="append", help="Maximum bandwidth over non-I2 routes") - self.parser.add_option("", "--net-min-rate", + self.parser.add_option("", "--net-min-rate", metavar="", action="append", help="Minimum bandwidth over non-I2 routes") - self.parser.add_option("", "--net-share", + self.parser.add_option("", "--net-share", metavar="", action="append", help="Number of bandwidth shares over non-I2 " + "routes") - self.parser.add_option("", "--net-thresh-kbyte", + self.parser.add_option("", "--net-thresh-kbyte", metavar="", action="append", help="Limit sent to non-I2 hosts before " + "warning, throttling") - self.parser.add_option("", "--vsys", + self.parser.add_option("", "--vsys", metavar="", action="append", help="Vsys script (e.g., fd_fusemount)") - self.parser.add_option("", "--vsys-vnet", + self.parser.add_option("", "--vsys-vnet", metavar="", action="append", help="Allocate a virtual private network") def get_attribute_dict(self): - attrlist = ['capabilities','codemux','cpu_pct','cpu_share', - 'delegations','disk_max','initscript','ip_addresses', - 'net_i2_max_kbyte','net_i2_max_rate','net_i2_min_rate', - 'net_i2_share','net_i2_thresh_kbyte', - 'net_max_kbyte','net_max_rate','net_min_rate', - 'net_share','net_thresh_kbyte', - 'vsys','vsys_vnet'] + attrlist = ['capabilities', 'codemux', 'cpu_pct', 'cpu_share', + 'delegations', 'disk_max', 'initscript', 'ip_addresses', + 'net_i2_max_kbyte', 'net_i2_max_rate', 'net_i2_min_rate', + 'net_i2_share', 'net_i2_thresh_kbyte', + 'net_max_kbyte', 'net_max_rate', 'net_min_rate', + 'net_share', 'net_thresh_kbyte', + 'vsys', 'vsys_vnet'] attrdict = {} for attr in attrlist: value = getattr(self.opts, attr, None) @@ -111,12 +120,12 @@ class Commands: def prep(self): (self.opts, self.args) = self.parser.parse_args() - #if self.opts.infile: + # if self.opts.infile: # sys.stdin = open(self.opts.infile, "r") #xml = sys.stdin.read() #self.rspec = RSpec(xml) - # - #if self.nodefile: + # + # if self.nodefile: # if self.opts.nodefile: # f = open(self.opts.nodefile, "r") # self.nodes = f.read().split() @@ -124,12 +133,5 @@ class Commands: # else: # self.nodes = self.args # - #if self.opts.outfile: + # if self.opts.outfile: # sys.stdout = open(self.opts.outfile, "w") - - - - - - -