direct-io.hg

changeset 556:bd3c746eb8ca

bitkeeper revision 1.304.1.2 (3f0bdd80mrpM9InfprcL835uydvRVA)

Small bug fix for Extent constructor parameter ordering
Reformatting, cleanups, adjust the usage/help messages for Parse* to make more sense
Make ParseHelp throw slightly less exceptions =)
author rac61@labyrinth.cl.cam.ac.uk
date Wed Jul 09 09:16:48 2003 +0000 (2003-07-09)
parents 9b6ba16a7e32
children d2e63f4ee02e
files tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java tools/control/src/org/xenoserver/cmdline/ParseDomainList.java tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java tools/control/src/org/xenoserver/cmdline/ParseFailedException.java tools/control/src/org/xenoserver/cmdline/ParseHelp.java tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java tools/control/src/org/xenoserver/cmdline/ParsePartitionsList.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java tools/control/src/org/xenoserver/cmdline/ParseVdFree.java tools/control/src/org/xenoserver/cmdline/ParseVdRefresh.java tools/control/src/org/xenoserver/cmdline/ParseVdShow.java tools/control/src/org/xenoserver/control/CommandPhysicalList.java tools/control/src/org/xenoserver/control/VirtualDisk.java tools/control/src/org/xenoserver/control/XMLHelper.java
line diff
     1.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java	Tue Jul 08 14:50:37 2003 +0000
     1.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java	Wed Jul 09 09:16:48 2003 +0000
     1.3 @@ -7,32 +7,30 @@ import org.xenoserver.control.CommandFai
     1.4  import org.xenoserver.control.Defaults;
     1.5  
     1.6  public class ParseDomainDestroy extends CommandParser {
     1.7 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
     1.8 -    int domain_id = getIntParameter(args, 'n', 0);
     1.9 -    boolean force = getFlagParameter(args, 'f');
    1.10 +    public void parse(Defaults d, LinkedList args)
    1.11 +        throws ParseFailedException, CommandFailedException {
    1.12 +        int domain_id = getIntParameter(args, 'n', 0);
    1.13 +        boolean force = getFlagParameter(args, 'f');
    1.14  
    1.15 -    if (domain_id == 0) {
    1.16 -      throw new ParseFailedException("Expected -n<domain_id>");
    1.17 +        if (domain_id == 0) {
    1.18 +            throw new ParseFailedException("Expected -n<domain_id>");
    1.19 +        }
    1.20 +
    1.21 +        String output = new CommandDomainDestroy(d, domain_id, force).execute();
    1.22 +        if (output != null) {
    1.23 +            System.out.println(output);
    1.24 +        }
    1.25      }
    1.26  
    1.27 -    String output = new CommandDomainDestroy(d, domain_id, force).execute();
    1.28 -    if ( output != null )
    1.29 -      System.out.println( output );
    1.30 -  }
    1.31 -  
    1.32 -  public String getName()
    1.33 -  {
    1.34 -    return "destroy";
    1.35 -  }
    1.36 +    public String getName() {
    1.37 +        return "destroy";
    1.38 +    }
    1.39  
    1.40 -  public String getUsage()
    1.41 -  {
    1.42 -    return "[-f] [-n<domain_id>]";
    1.43 -  }
    1.44 +    public String getUsage() {
    1.45 +        return "-n<domain_id> [-f]";
    1.46 +    }
    1.47  
    1.48 -  public String getHelpText()
    1.49 -  {
    1.50 -    return
    1.51 -      "Destory the specified domain.  -f forcibly destroys it.";
    1.52 -  }
    1.53 +    public String getHelpText() {
    1.54 +        return "Destroy the specified domain.  -f forcibly destroys it.";
    1.55 +    }
    1.56  }
     2.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainList.java	Tue Jul 08 14:50:37 2003 +0000
     2.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainList.java	Wed Jul 09 09:16:48 2003 +0000
     2.3 @@ -8,40 +8,37 @@ import org.xenoserver.control.Defaults;
     2.4  import org.xenoserver.control.Domain;
     2.5  
     2.6  public class ParseDomainList extends CommandParser {
     2.7 +    public void parse(Defaults d, LinkedList args)
     2.8 +        throws ParseFailedException, CommandFailedException {
     2.9 +        CommandDomainList list = new CommandDomainList(d);
    2.10 +        String output = list.execute();
    2.11 +        if (output != null) {
    2.12 +            System.out.println(output);
    2.13 +        }
    2.14  
    2.15 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    2.16 -    CommandDomainList list = new CommandDomainList(d);
    2.17 -    String output = list.execute();
    2.18 -    if ( output != null )
    2.19 -      System.out.println( output );
    2.20 -    Domain[] domains = list.domains();
    2.21 +        Domain[] domains = list.domains();
    2.22  
    2.23 -    for (int loop = 0; loop < domains.length; loop++)
    2.24 -    {
    2.25 -      System.out.println ("id: " + domains[loop].id + 
    2.26 -        " (" + domains[loop].name+ ")");
    2.27 -      System.out.println ("  processor: " + domains[loop].processor);
    2.28 -      System.out.println ("  has cpu: " + domains[loop].cpu);
    2.29 -      System.out.println ("  state: " + domains[loop].nstate + " " +
    2.30 -        domains[loop].state);
    2.31 -      System.out.println ("  mcu advance: " + domains[loop].mcu);
    2.32 -      System.out.println ("  total pages: " + domains[loop].pages);
    2.33 +        for (int loop = 0; loop < domains.length; loop++) {
    2.34 +            System.out.println(
    2.35 +                "id: " + domains[loop].id + " (" + domains[loop].name + ")");
    2.36 +            System.out.println("  processor: " + domains[loop].processor);
    2.37 +            System.out.println("  has cpu: " + domains[loop].cpu);
    2.38 +            System.out.println(
    2.39 +                "  state: " + domains[loop].nstate + " " + domains[loop].state);
    2.40 +            System.out.println("  mcu advance: " + domains[loop].mcu);
    2.41 +            System.out.println("  total pages: " + domains[loop].pages);
    2.42 +        }
    2.43      }
    2.44 -  }
    2.45  
    2.46 -  public String getName()
    2.47 -  {
    2.48 -    return "list";
    2.49 -  }
    2.50 +    public String getName() {
    2.51 +        return "list";
    2.52 +    }
    2.53  
    2.54 -  public String getUsage()
    2.55 -  {
    2.56 -    return "";
    2.57 -  }
    2.58 +    public String getUsage() {
    2.59 +        return "";
    2.60 +    }
    2.61  
    2.62 -  public String getHelpText()
    2.63 -  {
    2.64 -    return
    2.65 -      "List domain information";
    2.66 -  }
    2.67 +    public String getHelpText() {
    2.68 +        return "List domain information and status.";
    2.69 +    }
    2.70  }
     3.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java	Tue Jul 08 14:50:37 2003 +0000
     3.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java	Wed Jul 09 09:16:48 2003 +0000
     3.3 @@ -7,76 +7,86 @@ import org.xenoserver.control.CommandFai
     3.4  import org.xenoserver.control.Defaults;
     3.5  
     3.6  public class ParseDomainNew extends CommandParser {
     3.7 +    public void parse(Defaults d, LinkedList args)
     3.8 +        throws ParseFailedException, CommandFailedException {
     3.9 +        String name = getStringParameter(args, 'n', d.domainName);
    3.10 +        int size = getIntParameter(args, 'k', d.domainSizeKB);
    3.11 +        String image = getStringParameter(args, 'i', d.domainImage);
    3.12 +        String initrd = getStringParameter(args, 'r', d.domainInitRD);
    3.13 +        int vifs = getIntParameter(args, 'v', d.domainVIFs);
    3.14 +        String bargs = getStringParameter(args, 'a', d.args) + " ";
    3.15 +        String root_dev = getStringParameter(args, 'd', d.rootDevice);
    3.16 +        String nfs_root_path = getStringParameter(args, 'f', d.nwNFSRoot);
    3.17 +        String nw_ip = getStringParameter(args, '4', d.nwIP);
    3.18 +        String nw_gw = getStringParameter(args, 'g', d.nwGateway);
    3.19 +        String nw_mask = getStringParameter(args, 'm', d.nwMask);
    3.20 +        String nw_nfs_server = getStringParameter(args, 's', d.nwNFSServer);
    3.21 +        String nw_host = getStringParameter(args, 'h', d.nwHost);
    3.22  
    3.23 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    3.24 -    String name = getStringParameter(args, 'n', d.domainName);
    3.25 -    int size = getIntParameter(args, 'k', d.domainSizeKB);
    3.26 -    String image = getStringParameter(args, 'i', d.domainImage);
    3.27 -    String initrd = getStringParameter (args, 'r', d.domainInitRD);
    3.28 -    int vifs = getIntParameter(args, 'v', d.domainVIFs);
    3.29 -    String bargs = getStringParameter (args, 'a', d.args) + " ";
    3.30 -    String root_dev = getStringParameter (args, 'd', d.rootDevice);
    3.31 -    String nfs_root_path = getStringParameter (args, 'f', d.nwNFSRoot);
    3.32 -    String nw_ip = getStringParameter (args, '4', d.nwIP);
    3.33 -    String nw_gw = getStringParameter (args, 'g', d.nwGateway);
    3.34 -    String nw_mask = getStringParameter (args, 'm', d.nwMask);
    3.35 -    String nw_nfs_server = getStringParameter (args, 's', d.nwNFSServer);
    3.36 -    String nw_host = getStringParameter (args, 'h', d.nwHost);
    3.37 -
    3.38 -    d.describe();
    3.39 +        d.describe();
    3.40  
    3.41 -    CommandDomainNew c = new CommandDomainNew(d, name, size, image, initrd, vifs,
    3.42 -                                  bargs, root_dev, nfs_root_path,
    3.43 -                                  nw_ip, nw_gw, nw_mask, nw_nfs_server, nw_host);
    3.44 -    c.execute();
    3.45 -    String[] output = c.output();
    3.46 -    for ( int i = 0; i < output.length; i++ )
    3.47 -      System.out.println( output[i] ); 
    3.48 -  }
    3.49 -
    3.50 -  public String getName()
    3.51 -  {
    3.52 -    return "new";
    3.53 -  }
    3.54 -
    3.55 -  public String getUsage()
    3.56 -  {
    3.57 -    return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>]";
    3.58 -  }
    3.59 +        CommandDomainNew c =
    3.60 +            new CommandDomainNew(
    3.61 +                d,
    3.62 +                name,
    3.63 +                size,
    3.64 +                image,
    3.65 +                initrd,
    3.66 +                vifs,
    3.67 +                bargs,
    3.68 +                root_dev,
    3.69 +                nfs_root_path,
    3.70 +                nw_ip,
    3.71 +                nw_gw,
    3.72 +                nw_mask,
    3.73 +                nw_nfs_server,
    3.74 +                nw_host);
    3.75 +        c.execute();
    3.76 +        String[] output = c.output();
    3.77 +        for (int i = 0; i < output.length; i++) {
    3.78 +            System.out.println(output[i]);
    3.79 +        }
    3.80 +    }
    3.81  
    3.82 -  public String getHelpText()
    3.83 -  {
    3.84 -    return
    3.85 -      "Create a new domain.  Note that most of the parameters will assume\n" +
    3.86 -      "default values: it should not be necessary to specify them all. See\n" +
    3.87 -      "domctl.xml for the current default settings.\n" +
    3.88 -      "\n" +
    3.89 -      "General command line options:\n" +
    3.90 -      "  -n  Domain name                              domain_name\n" +
    3.91 -      "  -k  Domain size (kb)                         domain_size_kb\n" +
    3.92 -      "  -i  Domain image name                        domain_image\n" +
    3.93 -      "  -v  Number of VIFs                           domain_vifs\n" +
    3.94 -      "  -r  InitRD (if required)                     domain_init_rd\n" +
    3.95 -      "  -d  Root device (e.g /dev/nfs, /dev/hda3)    root_device\n" +
    3.96 -      "  -a  Additional boot parameters\n" +
    3.97 -      "\n" +
    3.98 -      "Networking options:\n" +
    3.99 -      "  -f  NFS root (if /dev/nfs specified)         nw_nfs_root\n" +
   3.100 -      "  -s  NFS server                               nw_nfs_server\n" +
   3.101 -      "  -4  Domain IPv4 address                      nw_ip\n" +
   3.102 -      "  -g  Domain gateway                           nw_gw\n" +
   3.103 -      "  -m  Domain net mask                          nw_mask\n" +
   3.104 -      "  -h  Domain hostname                          nw_host\n" +
   3.105 -      "\n" +
   3.106 -      "Parameters to -d, -f, -4, -g, -h can be specified as patterns into\n" +
   3.107 -      "which the allocated domain ID will be incorporated.  e.g.  for\n" +
   3.108 -      "domain 1 patterns would expand as follows:\n" +
   3.109 -      "\n" +
   3.110 -      "  /dev/hda+       /dev/hda1\n" +
   3.111 -      "  /dev/hda7+      /dev/hda8\n" +
   3.112 -      "  128.232.8.50+   128.232.8.51\n" +
   3.113 -      "\n" +
   3.114 -      "Additionally, patterns for -4 -g -m can include an = which is\n" + 
   3.115 -      "expanded to the corresponding setting from the calling domain.\n";
   3.116 -  }
   3.117 +    public String getName() {
   3.118 +        return "new";
   3.119 +    }
   3.120 +
   3.121 +    public String getUsage() {
   3.122 +        return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>]";
   3.123 +    }
   3.124 +
   3.125 +    public String getHelpText() {
   3.126 +        return "Create a new domain.  Note that most of the parameters will assume\n"
   3.127 +            + "default values: it should not be necessary to specify them all. See\n"
   3.128 +            + "domctl.xml for the current default settings.\n"
   3.129 +            + "\n"
   3.130 +            + "General command line options:\n"
   3.131 +            + "  -n  Domain name                              domain_name\n"
   3.132 +            + "  -k  Domain size (kb)                         domain_size_kb\n"
   3.133 +            + "  -i  Domain image name                        domain_image\n"
   3.134 +            + "  -v  Number of VIFs                           domain_vifs\n"
   3.135 +            + "  -r  InitRD (if required)                     domain_init_rd\n"
   3.136 +            + "  -d  Root device (e.g /dev/nfs, /dev/hda3)    root_device\n"
   3.137 +            + "  -a  Additional boot parameters\n"
   3.138 +            + "\n"
   3.139 +            + "Networking options:\n"
   3.140 +            + "  -f  NFS root (if /dev/nfs specified)         nw_nfs_root\n"
   3.141 +            + "  -s  NFS server                               nw_nfs_server\n"
   3.142 +            + "  -4  Domain IPv4 address                      nw_ip\n"
   3.143 +            + "  -g  Domain gateway                           nw_gw\n"
   3.144 +            + "  -m  Domain net mask                          nw_mask\n"
   3.145 +            + "  -h  Domain hostname                          nw_host\n"
   3.146 +            + "\n"
   3.147 +            + "Parameters to -d, -f, -4, -g, -h can be specified as patterns into\n"
   3.148 +            + "which the allocated domain ID will be incorporated.  e.g.  for\n"
   3.149 +            + "domain 1 patterns would expand as follows:\n"
   3.150 +            + "\n"
   3.151 +            + "  /dev/hda+       /dev/hda1\n"
   3.152 +            + "  /dev/hda7+      /dev/hda8\n"
   3.153 +            + "  128.232.8.50+   128.232.8.51\n"
   3.154 +            + "\n"
   3.155 +            + "Additionally, patterns for -4 -g -m can include an = which is\n"
   3.156 +            + "expanded to the corresponding setting from the calling domain.\n";
   3.157 +    }
   3.158  }
     4.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java	Tue Jul 08 14:50:37 2003 +0000
     4.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java	Wed Jul 09 09:16:48 2003 +0000
     4.3 @@ -7,32 +7,28 @@ import org.xenoserver.control.CommandFai
     4.4  import org.xenoserver.control.Defaults;
     4.5  
     4.6  public class ParseDomainStart extends CommandParser {
     4.7 +    public void parse(Defaults d, LinkedList args)
     4.8 +        throws ParseFailedException, CommandFailedException {
     4.9 +        int domain_id = getIntParameter(args, 'n', 0);
    4.10  
    4.11 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    4.12 -    int domain_id = getIntParameter(args, 'n', 0);
    4.13 -    
    4.14 -    if (domain_id == 0) {
    4.15 -      throw new ParseFailedException("Expected -n<domain_id>");
    4.16 +        if (domain_id == 0) {
    4.17 +            throw new ParseFailedException("Expected -n<domain_id>");
    4.18 +        }
    4.19 +
    4.20 +        String output = new CommandDomainStart(d, domain_id).execute();
    4.21 +        if (output != null)
    4.22 +            System.out.println(output);
    4.23      }
    4.24  
    4.25 -    String output = new CommandDomainStart(d, domain_id).execute();
    4.26 -    if ( output != null )
    4.27 -      System.out.println( output );
    4.28 -  }
    4.29 -
    4.30 -  public String getName()
    4.31 -  {
    4.32 -    return "start";
    4.33 -  }
    4.34 +    public String getName() {
    4.35 +        return "start";
    4.36 +    }
    4.37  
    4.38 -  public String getUsage()
    4.39 -  {
    4.40 -    return "[-n<domain_id>]";
    4.41 -  }
    4.42 +    public String getUsage() {
    4.43 +        return "-n<domain_id>";
    4.44 +    }
    4.45  
    4.46 -  public String getHelpText()
    4.47 -  {
    4.48 -    return
    4.49 -      "Start the specified domain.";
    4.50 -  }
    4.51 +    public String getHelpText() {
    4.52 +        return "Start the specified domain.";
    4.53 +    }
    4.54  }
     5.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java	Tue Jul 08 14:50:37 2003 +0000
     5.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java	Wed Jul 09 09:16:48 2003 +0000
     5.3 @@ -7,32 +7,28 @@ import org.xenoserver.control.CommandFai
     5.4  import org.xenoserver.control.Defaults;
     5.5  
     5.6  public class ParseDomainStop extends CommandParser {
     5.7 +    public void parse(Defaults d, LinkedList args)
     5.8 +        throws ParseFailedException, CommandFailedException {
     5.9 +        int domain_id = getIntParameter(args, 'n', 0);
    5.10  
    5.11 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    5.12 -    int domain_id = getIntParameter(args, 'n', 0);
    5.13 -    
    5.14 -    if (domain_id == 0) {
    5.15 -      throw new ParseFailedException("Expected -n<domain_id>");
    5.16 +        if (domain_id == 0) {
    5.17 +            throw new ParseFailedException("Expected -n<domain_id>");
    5.18 +        }
    5.19 +
    5.20 +        String output = new CommandDomainStop(d, domain_id).execute();
    5.21 +        if (output != null)
    5.22 +            System.out.println(output);
    5.23      }
    5.24  
    5.25 -    String output = new CommandDomainStop(d, domain_id).execute();
    5.26 -    if ( output != null )
    5.27 -      System.out.println( output );
    5.28 -  }
    5.29 -
    5.30 -  public String getName()
    5.31 -  {
    5.32 -    return "stop";
    5.33 -  }
    5.34 +    public String getName() {
    5.35 +        return "stop";
    5.36 +    }
    5.37  
    5.38 -  public String getUsage()
    5.39 -  {
    5.40 -    return "[-n<domain_id>]";
    5.41 -  }
    5.42 +    public String getUsage() {
    5.43 +        return "-n<domain_id>";
    5.44 +    }
    5.45  
    5.46 -  public String getHelpText()
    5.47 -  {
    5.48 -    return
    5.49 -      "Stop the specified domain.";
    5.50 -  }
    5.51 +    public String getHelpText() {
    5.52 +        return "Stop the specified domain.";
    5.53 +    }
    5.54  }
     6.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseFailedException.java	Tue Jul 08 14:50:37 2003 +0000
     6.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseFailedException.java	Wed Jul 09 09:16:48 2003 +0000
     6.3 @@ -4,19 +4,11 @@ package org.xenoserver.cmdline;
     6.4   * Thrown when a command line could not be parsed.
     6.5   */
     6.6  public class ParseFailedException extends Exception {
     6.7 -  public ParseFailedException() {
     6.8 -    super();
     6.9 -  }
    6.10 -
    6.11 -  public ParseFailedException(String message) {
    6.12 -    super(message);
    6.13 -  }
    6.14 +    public ParseFailedException(String message) {
    6.15 +        super(message);
    6.16 +    }
    6.17  
    6.18 -  public ParseFailedException(String message, Throwable cause) {
    6.19 -    super(message, cause);
    6.20 -  }
    6.21 -
    6.22 -  public ParseFailedException(Throwable cause) {
    6.23 -    super(cause);
    6.24 -  }
    6.25 +    public ParseFailedException(String message, Throwable cause) {
    6.26 +        super(message, cause);
    6.27 +    }
    6.28  }
     7.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseHelp.java	Tue Jul 08 14:50:37 2003 +0000
     7.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseHelp.java	Wed Jul 09 09:16:48 2003 +0000
     7.3 @@ -5,31 +5,27 @@ import java.util.LinkedList;
     7.4  import org.xenoserver.control.Defaults;
     7.5  
     7.6  public class ParseHelp extends CommandParser {
     7.7 +    public void parse(Defaults d, LinkedList args) {
     7.8 +        if (args == null || args.isEmpty()) {
     7.9 +            System.out.println("Usage:");
    7.10 +            Main.parser.printUsage(null);
    7.11 +        } else {
    7.12 +            System.out.print("xenctl ");
    7.13 +            Main.parser.printHelpText(args);
    7.14 +        }
    7.15  
    7.16 -  public void parse(Defaults d, LinkedList args) {
    7.17 -    if (args.size() == 0) {
    7.18 -      System.out.println("Usage:");
    7.19 -      Main.parser.printUsage(null);
    7.20 -    } else {
    7.21 -      System.out.print("xenctl ");
    7.22 -      Main.parser.printHelpText(args);
    7.23 +        System.out.println("");
    7.24      }
    7.25  
    7.26 -    System.out.println("");
    7.27 -  }
    7.28 -  
    7.29 -  public String getName()
    7.30 -  {
    7.31 -    return "help";
    7.32 -  }
    7.33 +    public String getName() {
    7.34 +        return "help";
    7.35 +    }
    7.36  
    7.37 -  public String getUsage()
    7.38 -  {
    7.39 -    return "";
    7.40 -  }
    7.41 +    public String getUsage() {
    7.42 +        return "[<any command>]";
    7.43 +    }
    7.44  
    7.45 -  public String getHelpText()
    7.46 -  {
    7.47 -    return "This message";
    7.48 -  }  
    7.49 +    public String getHelpText() {
    7.50 +        return "This message, or if a command is specified, help for that command.";
    7.51 +    }
    7.52  }
     8.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java	Tue Jul 08 14:50:37 2003 +0000
     8.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePartitionsAdd.java	Wed Jul 09 09:16:48 2003 +0000
     8.3 @@ -14,30 +14,34 @@ public class ParsePartitionsAdd extends 
     8.4    public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
     8.5      boolean force = getFlagParameter(args, 'f');
     8.6      String partition_name = getStringParameter(args, 'p', "");
     8.7 -    String size = getStringParameter(args, 'c', "100M");
     8.8 +    String size = getStringParameter(args, 'c', "128M");
     8.9      
    8.10 -    if (partition_name.equals(""))
    8.11 +    if (partition_name.equals("")) {
    8.12        throw new ParseFailedException("Expected -p<partition_name>");
    8.13 +    }
    8.14        
    8.15      long chunksize = Library.parseSize( size ) / Settings.SECTOR_SIZE;
    8.16 -    if ( chunksize <= 0 )
    8.17 +    if ( chunksize <= 0 ) {
    8.18        throw new CommandFailedException("Chunk size " + size + " is smaller than sector size.");
    8.19 +    }
    8.20      
    8.21      // Initialise the partition manager and look up the partition
    8.22      loadState();
    8.23      Partition p = PartitionManager.IT.getPartition(partition_name);
    8.24      
    8.25 -    if ( p == null )
    8.26 +    if ( p == null ) {
    8.27        throw new CommandFailedException("Partition " + partition_name + " does not exist.");
    8.28 +    }
    8.29      
    8.30      // Check if this partition belongs to the VDM
    8.31 -    if (p.isXeno() && !force)
    8.32 +    if (p.isXeno() && !force) {
    8.33        throw new CommandFailedException("Refusing to add partition as it is already allocated to the virtual disk manager. Use -f if you are sure.");
    8.34 +    }
    8.35      
    8.36      String output = new CommandPartitionAdd( p, chunksize ).execute();
    8.37 -    if ( output != null )
    8.38 +    if ( output != null ) {
    8.39        System.out.println( output );
    8.40 -      
    8.41 +    }
    8.42      saveState();
    8.43    }
    8.44  
    8.45 @@ -46,7 +50,7 @@ public class ParsePartitionsAdd extends 
    8.46    }
    8.47  
    8.48    public String getUsage() {
    8.49 -    return "[-f] [-p<partition_name>] [-c<chunk_size>]";
    8.50 +    return "-p<partition_name> [-f] [-c<chunk_size>]";
    8.51    }
    8.52  
    8.53    public String getHelpText() {
     9.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePartitionsList.java	Tue Jul 08 14:50:37 2003 +0000
     9.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePartitionsList.java	Wed Jul 09 09:16:48 2003 +0000
     9.3 @@ -10,45 +10,56 @@ import org.xenoserver.control.Partition;
     9.4  import org.xenoserver.control.PartitionManager;
     9.5  
     9.6  public class ParsePartitionsList extends CommandParser {
     9.7 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
     9.8 -    loadState();
     9.9 -    Iterator i = PartitionManager.IT.iterator();
    9.10 -    int idx = 1;
    9.11 -    System.out.println( "     maj:min " + "    blocks " + "start sect " +
    9.12 -                        " num sects " + "name" );
    9.13 -    while (i.hasNext()) {
    9.14 -      Partition p = (Partition) i.next();
    9.15 +    public void parse(Defaults d, LinkedList args)
    9.16 +        throws ParseFailedException, CommandFailedException {
    9.17 +        loadState();
    9.18 +        Iterator i = PartitionManager.IT.iterator();
    9.19 +        int idx = 1;
    9.20 +        System.out.println(
    9.21 +            "     maj:min "
    9.22 +                + "    blocks "
    9.23 +                + "start sect "
    9.24 +                + " num sects "
    9.25 +                + "name");
    9.26 +        while (i.hasNext()) {
    9.27 +            Partition p = (Partition) i.next();
    9.28  
    9.29 -      if (p.isXeno()) {
    9.30 -        System.out.print("[ ");
    9.31 -      } else {
    9.32 -        System.out.print("  ");
    9.33 -      }
    9.34 -      System.out.print(Library.format(idx++, 2, false) + " ");
    9.35 -      System.out.print(Library.format(p.getMajor(),3,false) + ":" + 
    9.36 -          Library.format(p.getMinor(),3,true) + " " +
    9.37 -          Library.format(p.getBlocks(),10,false) + " " +
    9.38 -          Library.format(p.getStartSect(),10,false) + " " +
    9.39 -          Library.format(p.getNumSects(),10,false) + " " +
    9.40 -          Library.format(p.getName(),7,true));   
    9.41 -      if (p.isXeno()) {
    9.42 -        System.out.println("]");
    9.43 -      } else {
    9.44 -        System.out.println();
    9.45 -      }
    9.46 +            if (p.isXeno()) {
    9.47 +                System.out.print("[ ");
    9.48 +            } else {
    9.49 +                System.out.print("  ");
    9.50 +            }
    9.51 +            System.out.print(Library.format(idx++, 2, false) + " ");
    9.52 +            System.out.print(
    9.53 +                Library.format(p.getMajor(), 3, false)
    9.54 +                    + ":"
    9.55 +                    + Library.format(p.getMinor(), 3, true)
    9.56 +                    + " "
    9.57 +                    + Library.format(p.getBlocks(), 10, false)
    9.58 +                    + " "
    9.59 +                    + Library.format(p.getStartSect(), 10, false)
    9.60 +                    + " "
    9.61 +                    + Library.format(p.getNumSects(), 10, false)
    9.62 +                    + " "
    9.63 +                    + Library.format(p.getName(), 7, true));
    9.64 +            if (p.isXeno()) {
    9.65 +                System.out.println("]");
    9.66 +            } else {
    9.67 +                System.out.println();
    9.68 +            }
    9.69 +        }
    9.70      }
    9.71 -  }
    9.72  
    9.73 -  public String getName() {
    9.74 -    return "list";
    9.75 -  }
    9.76 +    public String getName() {
    9.77 +        return "list";
    9.78 +    }
    9.79  
    9.80 -  public String getUsage() {
    9.81 -    return "";
    9.82 -  }
    9.83 +    public String getUsage() {
    9.84 +        return "";
    9.85 +    }
    9.86  
    9.87 -  public String getHelpText() {
    9.88 -    return "List real partition information";
    9.89 -  }
    9.90 +    public String getHelpText() {
    9.91 +        return "List physical partition information. Partitions surrounded by [] are XenoPartitions.";
    9.92 +    }
    9.93  
    9.94  }
    10.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Tue Jul 08 14:50:37 2003 +0000
    10.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Wed Jul 09 09:16:48 2003 +0000
    10.3 @@ -16,31 +16,37 @@ public class ParsePhysicalGrant extends 
    10.4      String partition_name = getStringParameter(args, 'p', "");
    10.5      boolean write = getFlagParameter(args, 'w');
    10.6      
    10.7 -    if (domain_id == 0)
    10.8 +    if (domain_id == 0) {
    10.9        throw new ParseFailedException("Expected -n<domain_id>");
   10.10 -    if (partition_name.equals(""))
   10.11 +    }
   10.12 +    if (partition_name.equals("")) {
   10.13        throw new ParseFailedException("Expected -p<partition_name>");
   10.14 +    }
   10.15        
   10.16      Mode mode;
   10.17 -    if (write)
   10.18 +    if (write) {
   10.19        mode = Mode.READ_WRITE;
   10.20 -    else
   10.21 +    } else {
   10.22        mode = Mode.READ_ONLY;
   10.23 +    }
   10.24        
   10.25      // Initialise the partition manager and look up the partition
   10.26      loadState();
   10.27      Partition p = PartitionManager.IT.getPartition(partition_name);
   10.28      
   10.29 -    if ( p == null )
   10.30 +    if ( p == null ) {
   10.31        throw new CommandFailedException("Partition " + partition_name + " does not exist.");
   10.32 +    }
   10.33      
   10.34      // Check if this partition belongs to the VDM
   10.35 -    if (p.isXeno() && !force)
   10.36 +    if (p.isXeno() && !force) {
   10.37        throw new CommandFailedException("Refusing to grant physical access as the given partition is allocated to the virtual disk manager. Use -f if you are sure.");
   10.38 -     
   10.39 +    }
   10.40 +         
   10.41      String output = new CommandPhysicalGrant( d, domain_id, p, mode ).execute();
   10.42 -    if ( output != null )
   10.43 +    if ( output != null ) {
   10.44        System.out.println( output );
   10.45 +    }
   10.46    }
   10.47  
   10.48    public String getName() {
   10.49 @@ -48,7 +54,7 @@ public class ParsePhysicalGrant extends 
   10.50    }
   10.51  
   10.52    public String getUsage() {
   10.53 -    return "[-f] [-w] [-n<domain_id>] [-p<partition_name>]";
   10.54 +    return "-n<domain_id> -p<partition_name> [-f] [-w]";
   10.55    }
   10.56  
   10.57    public String getHelpText() {
    11.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java	Tue Jul 08 14:50:37 2003 +0000
    11.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java	Wed Jul 09 09:16:48 2003 +0000
    11.3 @@ -13,59 +13,82 @@ import org.xenoserver.control.Partition;
    11.4  import org.xenoserver.control.PartitionManager;
    11.5  
    11.6  public class ParsePhysicalList extends CommandParser {
    11.7 +    public void parse(Defaults d, LinkedList args)
    11.8 +        throws ParseFailedException, CommandFailedException {
    11.9 +        int domain_id = getIntParameter(args, 'n', 0);
   11.10 +        if (domain_id == 0) {
   11.11 +            throw new ParseFailedException("Expected -n<domain_id>");
   11.12 +        }
   11.13  
   11.14 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
   11.15 -    int domain_id = getIntParameter(args, 'n', 0);
   11.16 -    if (domain_id == 0)
   11.17 -      throw new ParseFailedException("Expected -n<domain_id>");
   11.18 +        // Initialise the partition manager
   11.19 +        loadState();
   11.20 +
   11.21 +        CommandPhysicalList list = new CommandPhysicalList(d, domain_id);
   11.22 +        String output = list.execute();
   11.23 +        if (output != null) {
   11.24 +            System.out.println(output);
   11.25 +        }
   11.26  
   11.27 -    // Initialise the partition manager
   11.28 -    loadState();
   11.29 -    
   11.30 -    CommandPhysicalList list = new CommandPhysicalList( d, domain_id );
   11.31 -    String output = list.execute();
   11.32 -    if ( output != null )
   11.33 -      System.out.println( output );
   11.34 -      
   11.35 -    System.out.println( "maj:min " + "    blocks " + "start sect " +
   11.36 -                        " num sects " + "name    " + "access" );
   11.37 -    Iterator i = list.extents().entrySet().iterator();
   11.38 -    while ( i.hasNext() )
   11.39 -    {
   11.40 -      Entry entry = (Entry) i.next(); 
   11.41 -      Extent e = (Extent) entry.getKey();
   11.42 -      String mode = entry.getValue().toString();
   11.43 -      Partition p = PartitionManager.IT.getPartition( e );
   11.44 -      if ( p != null ) {
   11.45 -        System.out.println(Library.format(p.getMajor(),3,false) + ":" + 
   11.46 -          Library.format(p.getMinor(),3,true) + " " +
   11.47 -          Library.format(p.getBlocks(),10,false) + " " +
   11.48 -          Library.format(p.getStartSect(),10,false) + " " +
   11.49 -          Library.format(p.getNumSects(),10,false) + " " +
   11.50 -          Library.format(p.getName(),7,true) + " " +
   11.51 -          Library.format(mode,2,true));   
   11.52 -      } else {
   11.53 -        System.out.println(Library.format(e.getMajor(),3,false) + ":" +
   11.54 -          Library.format(e.getMinor(),3,true) + " " +
   11.55 -          "          " + " " +
   11.56 -          Library.format(e.getOffset(),10,false) + " " +
   11.57 -          Library.format(e.getSize(),10,false) + " " +
   11.58 -          "       " + " " +
   11.59 -          Library.format(mode,2,true));
   11.60 -      }
   11.61 +        System.out.println(
   11.62 +            "maj:min "
   11.63 +                + "    blocks "
   11.64 +                + "start sect "
   11.65 +                + " num sects "
   11.66 +                + "name    "
   11.67 +                + "access");
   11.68 +        Iterator i = list.extents().entrySet().iterator();
   11.69 +        while (i.hasNext()) {
   11.70 +            Entry entry = (Entry) i.next();
   11.71 +            Extent e = (Extent) entry.getKey();
   11.72 +            String mode = entry.getValue().toString();
   11.73 +            Partition p = PartitionManager.IT.getPartition(e);
   11.74 +            if (p != null) {
   11.75 +                System.out.println(
   11.76 +                    Library.format(p.getMajor(), 3, false)
   11.77 +                        + ":"
   11.78 +                        + Library.format(p.getMinor(), 3, true)
   11.79 +                        + " "
   11.80 +                        + Library.format(p.getBlocks(), 10, false)
   11.81 +                        + " "
   11.82 +                        + Library.format(p.getStartSect(), 10, false)
   11.83 +                        + " "
   11.84 +                        + Library.format(p.getNumSects(), 10, false)
   11.85 +                        + " "
   11.86 +                        + Library.format(p.getName(), 7, true)
   11.87 +                        + " "
   11.88 +                        + Library.format(mode, 2, true));
   11.89 +            } else {
   11.90 +                System.out.println(
   11.91 +                    Library.format(e.getMajor(), 3, false)
   11.92 +                        + ":"
   11.93 +                        + Library.format(
   11.94 +                            e.getMinor() | e.getPartitionNo(),
   11.95 +                            3,
   11.96 +                            true)
   11.97 +                        + " "
   11.98 +                        + "          "
   11.99 +                        + " "
  11.100 +                        + Library.format(e.getOffset(), 10, false)
  11.101 +                        + " "
  11.102 +                        + Library.format(e.getSize(), 10, false)
  11.103 +                        + " "
  11.104 +                        + "       "
  11.105 +                        + " "
  11.106 +                        + Library.format(mode, 2, true));
  11.107 +            }
  11.108 +        }
  11.109      }
  11.110 -  }
  11.111  
  11.112 -  public String getName() {
  11.113 -    return "list";
  11.114 -  }
  11.115 +    public String getName() {
  11.116 +        return "list";
  11.117 +    }
  11.118  
  11.119 -  public String getUsage() {
  11.120 -    return "[-n<domain_id>]";
  11.121 -  }
  11.122 +    public String getUsage() {
  11.123 +        return "-n<domain_id>";
  11.124 +    }
  11.125  
  11.126 -  public String getHelpText() {
  11.127 -    return "List all physical access which the given domain has been granted.";
  11.128 -  }
  11.129 +    public String getHelpText() {
  11.130 +        return "List all physical access which the given domain has been granted.";
  11.131 +    }
  11.132  
  11.133  }
    12.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Tue Jul 08 14:50:37 2003 +0000
    12.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Wed Jul 09 09:16:48 2003 +0000
    12.3 @@ -9,37 +9,43 @@ import org.xenoserver.control.Partition;
    12.4  import org.xenoserver.control.PartitionManager;
    12.5  
    12.6  public class ParsePhysicalRevoke extends CommandParser {
    12.7 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    12.8 -    int domain_id = getIntParameter(args, 'n', 0);
    12.9 -    String partition_name = getStringParameter(args, 'p', "");
   12.10 -    
   12.11 -    if (domain_id == 0)
   12.12 -      throw new ParseFailedException("Expected -n<domain_id>");
   12.13 -    if (partition_name.equals(""))
   12.14 -      throw new ParseFailedException("Expected -p<partition_name>");
   12.15 -      
   12.16 -    // Initialise the partition manager and look up the partition
   12.17 -    loadState();
   12.18 -    Partition p = PartitionManager.IT.getPartition(partition_name);
   12.19 -    
   12.20 -    if ( p == null )
   12.21 -      throw new CommandFailedException("Partition " + partition_name + " does not exist.");
   12.22 +    public void parse(Defaults d, LinkedList args)
   12.23 +        throws ParseFailedException, CommandFailedException {
   12.24 +        int domain_id = getIntParameter(args, 'n', 0);
   12.25 +        String partition_name = getStringParameter(args, 'p', "");
   12.26 +
   12.27 +        if (domain_id == 0) {
   12.28 +            throw new ParseFailedException("Expected -n<domain_id>");
   12.29 +        }
   12.30 +        if (partition_name.equals("")) {
   12.31 +            throw new ParseFailedException("Expected -p<partition_name>");
   12.32 +        }
   12.33 +
   12.34 +        // Initialise the partition manager and look up the partition
   12.35 +        loadState();
   12.36 +        Partition p = PartitionManager.IT.getPartition(partition_name);
   12.37  
   12.38 -    String output = new CommandPhysicalRevoke( d, domain_id, p ).execute();
   12.39 -    if ( output != null )
   12.40 -      System.out.println( output );
   12.41 -  }
   12.42 +        if (p == null) {
   12.43 +            throw new CommandFailedException(
   12.44 +                "Partition " + partition_name + " does not exist.");
   12.45 +        }
   12.46 +
   12.47 +        String output = new CommandPhysicalRevoke(d, domain_id, p).execute();
   12.48 +        if (output != null) {
   12.49 +            System.out.println(output);
   12.50 +        }
   12.51 +    }
   12.52  
   12.53 -  public String getName() {
   12.54 -    return "revoke";
   12.55 -  }
   12.56 +    public String getName() {
   12.57 +        return "revoke";
   12.58 +    }
   12.59  
   12.60 -  public String getUsage() {
   12.61 -    return "[-n<domain_id>] [-p<partition_name>]";
   12.62 -  }
   12.63 +    public String getUsage() {
   12.64 +        return "-n<domain_id> -p<partition_name>";
   12.65 +    }
   12.66  
   12.67 -  public String getHelpText() {
   12.68 -    return "Revoke access to the given partition from the specified domain.";
   12.69 -  }
   12.70 +    public String getHelpText() {
   12.71 +        return "Revoke access to the given partition from the specified domain.";
   12.72 +    }
   12.73  
   12.74  }
    13.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java	Tue Jul 08 14:50:37 2003 +0000
    13.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdCreate.java	Wed Jul 09 09:16:48 2003 +0000
    13.3 @@ -1,5 +1,7 @@
    13.4  package org.xenoserver.cmdline;
    13.5  
    13.6 +import java.text.DateFormat;
    13.7 +import java.text.ParseException;
    13.8  import java.util.Date;
    13.9  import java.util.LinkedList;
   13.10  
   13.11 @@ -10,40 +12,52 @@ import org.xenoserver.control.Library;
   13.12  import org.xenoserver.control.Settings;
   13.13  
   13.14  public class ParseVdCreate extends CommandParser {
   13.15 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
   13.16 -    String name = getStringParameter(args,'n',"");
   13.17 -    String size_s = getStringParameter(args,'s',"");
   13.18 -    String expiry_s = getStringParameter(args,'e',"");
   13.19 -    Date expiry;
   13.20 -    
   13.21 -    if ( name.equals("") )
   13.22 -      throw new ParseFailedException("Expected -n<name>");
   13.23 -    if ( size_s.equals("") )
   13.24 -      throw new ParseFailedException("Expected -s<size>");
   13.25 -    if ( expiry_s.equals("") )
   13.26 -      expiry = null;
   13.27 -    else
   13.28 -      expiry = new Date(Date.parse(expiry_s));
   13.29 -      
   13.30 -    long size = Library.parseSize(size_s);
   13.31 -    
   13.32 -    loadState();
   13.33 -    String output = new CommandVdCreate(name,size/Settings.SECTOR_SIZE,expiry).execute();
   13.34 -    if ( output != null )
   13.35 -      System.out.println( output );
   13.36 -    saveState();
   13.37 -  }
   13.38 +    public void parse(Defaults d, LinkedList args)
   13.39 +        throws ParseFailedException, CommandFailedException {
   13.40 +        String name = getStringParameter(args, 'n', "");
   13.41 +        String size_s = getStringParameter(args, 's', "");
   13.42 +        String expiry_s = getStringParameter(args, 'e', "");
   13.43 +        Date expiry;
   13.44 +
   13.45 +        if (name.equals("")) {
   13.46 +            throw new ParseFailedException("Expected -n<name>");
   13.47 +        }
   13.48 +        if (size_s.equals("")) {
   13.49 +            throw new ParseFailedException("Expected -s<size>");
   13.50 +        }
   13.51 +        if (expiry_s.equals("")) {
   13.52 +            expiry = null;
   13.53 +        } else {
   13.54 +            DateFormat format = DateFormat.getDateTimeInstance();
   13.55 +            try {
   13.56 +                expiry = format.parse(expiry_s);
   13.57 +            } catch (ParseException e) {
   13.58 +                throw new ParseFailedException("Could not parse date");
   13.59 +            }
   13.60 +        }
   13.61  
   13.62 -  public String getName() {
   13.63 -    return "create";
   13.64 -  }
   13.65 +        long size = Library.parseSize(size_s);
   13.66 +
   13.67 +        loadState();
   13.68 +        String output =
   13.69 +            new CommandVdCreate(name, size / Settings.SECTOR_SIZE, expiry)
   13.70 +                .execute();
   13.71 +        if (output != null) {
   13.72 +            System.out.println(output);
   13.73 +        }
   13.74 +        saveState();
   13.75 +    }
   13.76  
   13.77 -  public String getUsage() {
   13.78 -    return "[-n<name>] [-s<size>] [-e<expiry>]";
   13.79 -  }
   13.80 +    public String getName() {
   13.81 +        return "create";
   13.82 +    }
   13.83  
   13.84 -  public String getHelpText() {
   13.85 -    return "Create a new virtual disk with the specified parameters";
   13.86 -  }
   13.87 +    public String getUsage() {
   13.88 +        return "-n<name> -s<size> [-e<expiry>]";
   13.89 +    }
   13.90 +
   13.91 +    public String getHelpText() {
   13.92 +        return "Create a new virtual disk with the specified parameters";
   13.93 +    }
   13.94  
   13.95  }
    14.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java	Tue Jul 08 14:50:37 2003 +0000
    14.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdDelete.java	Wed Jul 09 09:16:48 2003 +0000
    14.3 @@ -8,33 +8,38 @@ import org.xenoserver.control.Defaults;
    14.4  import org.xenoserver.control.VirtualDiskManager;
    14.5  
    14.6  public class ParseVdDelete extends CommandParser {
    14.7 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    14.8 -    String vd_key = getStringParameter(args,'k',"");
    14.9 -    
   14.10 -    if ( vd_key.equals("") )
   14.11 -      throw new ParseFailedException("Expected -k<key>");
   14.12 -    
   14.13 -    loadState();
   14.14 -    if ( VirtualDiskManager.IT.getVirtualDisk(vd_key) == null )
   14.15 -      throw new CommandFailedException("Virtual disk " + vd_key + " does not exist");
   14.16 -      
   14.17 -    String output = new CommandVdDelete(vd_key).execute();
   14.18 -    if ( output != null )
   14.19 -      System.out.println( output );
   14.20 -      
   14.21 -    saveState();
   14.22 -  }
   14.23 +    public void parse(Defaults d, LinkedList args)
   14.24 +        throws ParseFailedException, CommandFailedException {
   14.25 +        String vd_key = getStringParameter(args, 'k', "");
   14.26 +
   14.27 +        if (vd_key.equals("")) {
   14.28 +            throw new ParseFailedException("Expected -k<key>");
   14.29 +        }
   14.30 +
   14.31 +        loadState();
   14.32 +        if (VirtualDiskManager.IT.getVirtualDisk(vd_key) == null) {
   14.33 +            throw new CommandFailedException(
   14.34 +                "Virtual disk " + vd_key + " does not exist");
   14.35 +        }
   14.36  
   14.37 -  public String getName() {
   14.38 -    return "delete";
   14.39 -  }
   14.40 +        String output = new CommandVdDelete(vd_key).execute();
   14.41 +        if (output != null) {
   14.42 +            System.out.println(output);
   14.43 +        }
   14.44 +
   14.45 +        saveState();
   14.46 +    }
   14.47  
   14.48 -  public String getUsage() {
   14.49 -    return "[-k<key>]";
   14.50 -  }
   14.51 +    public String getName() {
   14.52 +        return "delete";
   14.53 +    }
   14.54  
   14.55 -  public String getHelpText() {
   14.56 -    return "Deletes the virtual disk with the specified key.";
   14.57 -  }
   14.58 +    public String getUsage() {
   14.59 +        return "-k<key>";
   14.60 +    }
   14.61 +
   14.62 +    public String getHelpText() {
   14.63 +        return "Deletes the virtual disk with the specified key.";
   14.64 +    }
   14.65  
   14.66  }
    15.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdFree.java	Tue Jul 08 14:50:37 2003 +0000
    15.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdFree.java	Wed Jul 09 09:16:48 2003 +0000
    15.3 @@ -12,34 +12,44 @@ import org.xenoserver.control.VirtualDis
    15.4  import org.xenoserver.control.VirtualDiskManager;
    15.5  
    15.6  public class ParseVdFree extends CommandParser {
    15.7 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
    15.8 -    boolean verbose = getFlagParameter(args, 'v');
    15.9 -    
   15.10 -    loadState();
   15.11 -    VirtualDisk free = VirtualDiskManager.IT.getFreeDisk();
   15.12 -    System.out.println( "Free disk has " + free.getExtentCount() + " extents totalling "
   15.13 -                      + Library.formatSize(free.getSize()*Settings.SECTOR_SIZE,8,true) );
   15.14 -    if ( verbose ) {
   15.15 -      Iterator i = free.extents();
   15.16 -      System.out.println("  disk       offset         size");
   15.17 -      while (i.hasNext()) {
   15.18 -        Extent e = (Extent) i.next();
   15.19 -        System.out.println( Library.format(e.getDisk(), 6, false) + " "
   15.20 -                          + Library.format(e.getOffset(), 12, false) + " "
   15.21 -                          + Library.format(e.getSize(), 12, false) );
   15.22 -      }
   15.23 +    public void parse(Defaults d, LinkedList args)
   15.24 +        throws ParseFailedException, CommandFailedException {
   15.25 +        boolean verbose = getFlagParameter(args, 'v');
   15.26 +
   15.27 +        loadState();
   15.28 +        VirtualDisk free = VirtualDiskManager.IT.getFreeDisk();
   15.29 +        System.out.println(
   15.30 +            "Free disk has "
   15.31 +                + free.getExtentCount()
   15.32 +                + " extents totalling "
   15.33 +                + Library.formatSize(
   15.34 +                    free.getSize() * Settings.SECTOR_SIZE,
   15.35 +                    8,
   15.36 +                    true));
   15.37 +        if (verbose) {
   15.38 +            Iterator i = free.extents();
   15.39 +            System.out.println("  disk       offset         size");
   15.40 +            while (i.hasNext()) {
   15.41 +                Extent e = (Extent) i.next();
   15.42 +                System.out.println(
   15.43 +                    Library.format(e.getDisk(), 6, false)
   15.44 +                        + " "
   15.45 +                        + Library.format(e.getOffset(), 12, false)
   15.46 +                        + " "
   15.47 +                        + Library.format(e.getSize(), 12, false));
   15.48 +            }
   15.49 +        }
   15.50      }
   15.51 -  }
   15.52  
   15.53 -  public String getName() {
   15.54 -    return "free";
   15.55 -  }
   15.56 +    public String getName() {
   15.57 +        return "free";
   15.58 +    }
   15.59  
   15.60 -  public String getUsage() {
   15.61 -    return "[-v]";
   15.62 -  }
   15.63 +    public String getUsage() {
   15.64 +        return "[-v]";
   15.65 +    }
   15.66  
   15.67 -  public String getHelpText() {
   15.68 -    return "Show free space allocated to virtual disk manager. -v enables verbose output.";
   15.69 -  }
   15.70 +    public String getHelpText() {
   15.71 +        return "Show free space allocated to virtual disk manager. -v enables verbose output.";
   15.72 +    }
   15.73  }
    16.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdRefresh.java	Tue Jul 08 14:50:37 2003 +0000
    16.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdRefresh.java	Wed Jul 09 09:16:48 2003 +0000
    16.3 @@ -1,5 +1,7 @@
    16.4  package org.xenoserver.cmdline;
    16.5  
    16.6 +import java.text.DateFormat;
    16.7 +import java.text.ParseException;
    16.8  import java.util.Date;
    16.9  import java.util.LinkedList;
   16.10  
   16.11 @@ -8,35 +10,44 @@ import org.xenoserver.control.CommandVdR
   16.12  import org.xenoserver.control.Defaults;
   16.13  
   16.14  public class ParseVdRefresh extends CommandParser {
   16.15 -  public void parse(Defaults d, LinkedList args) throws ParseFailedException, CommandFailedException {
   16.16 -    String vd_key = getStringParameter(args,'k',"");
   16.17 -    String expiry_s = getStringParameter(args,'e',"");
   16.18 -    Date expiry;
   16.19 -    
   16.20 -    if ( vd_key.equals("") )
   16.21 -      throw new ParseFailedException("Expected -k<key>");
   16.22 -    if ( expiry_s.equals("") )
   16.23 -      expiry = null;
   16.24 -    else
   16.25 -      expiry = new Date(Date.parse(expiry_s));
   16.26 -      
   16.27 -    loadState();
   16.28 -    String output = new CommandVdRefresh(vd_key,expiry).execute();
   16.29 -    if ( output != null )
   16.30 -      System.out.println(output);
   16.31 -    saveState();
   16.32 -  }
   16.33 +    public void parse(Defaults d, LinkedList args)
   16.34 +        throws ParseFailedException, CommandFailedException {
   16.35 +        String vd_key = getStringParameter(args, 'k', "");
   16.36 +        String expiry_s = getStringParameter(args, 'e', "");
   16.37 +        Date expiry;
   16.38 +
   16.39 +        if (vd_key.equals("")) {
   16.40 +            throw new ParseFailedException("Expected -k<key>");
   16.41 +        }
   16.42 +        if (expiry_s.equals("")) {
   16.43 +            expiry = null;
   16.44 +        } else {
   16.45 +            DateFormat format = DateFormat.getDateTimeInstance();
   16.46 +            try {
   16.47 +                expiry = format.parse(expiry_s);
   16.48 +            } catch (ParseException e) {
   16.49 +                throw new ParseFailedException("Could not parse date");
   16.50 +            }
   16.51 +        }
   16.52  
   16.53 -  public String getName() {
   16.54 -    return "refresh";
   16.55 -  }
   16.56 +        loadState();
   16.57 +        String output = new CommandVdRefresh(vd_key, expiry).execute();
   16.58 +        if (output != null) {
   16.59 +            System.out.println(output);
   16.60 +        }
   16.61 +        saveState();
   16.62 +    }
   16.63  
   16.64 -  public String getUsage() {
   16.65 -    return "-k<key> [-e<expiry>]";
   16.66 -  }
   16.67 +    public String getName() {
   16.68 +        return "refresh";
   16.69 +    }
   16.70  
   16.71 -  public String getHelpText() {
   16.72 -    return "Refresh the expiry for the specified virtual disk. Omitting -e will cause the disk to never expire.";
   16.73 -  }
   16.74 +    public String getUsage() {
   16.75 +        return "-k<key> [-e<expiry>]";
   16.76 +    }
   16.77 +
   16.78 +    public String getHelpText() {
   16.79 +        return "Refresh the expiry for the specified virtual disk. Omitting -e will cause the disk to never expire.";
   16.80 +    }
   16.81  
   16.82  }
    17.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVdShow.java	Tue Jul 08 14:50:37 2003 +0000
    17.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVdShow.java	Wed Jul 09 09:16:48 2003 +0000
    17.3 @@ -23,23 +23,26 @@ public class ParseVdShow extends Command
    17.4        while ( i.hasNext() ) {
    17.5          VirtualDisk vd = (VirtualDisk) i.next();
    17.6          System.out.print( vd.getKey() + " " );
    17.7 -        if ( vd.getExpiry() != null )
    17.8 +        if ( vd.getExpiry() != null ) {
    17.9            System.out.print( vd.getExpiry().toString() );
   17.10 -        else
   17.11 +        } else {
   17.12            System.out.print( "                            " );
   17.13 +        }
   17.14          System.out.println( " " + Library.format(vd.getName(),16,true) + " "
   17.15                            + Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,false) );
   17.16        }
   17.17      } else {
   17.18        VirtualDisk vd = VirtualDiskManager.IT.getVirtualDisk(key);
   17.19 -      if ( vd == null )
   17.20 +      if ( vd == null ) {
   17.21          throw new CommandFailedException("There is no virtual disk " + key );
   17.22 +      }
   17.23          
   17.24        System.out.println("  name: " + vd.getName());
   17.25        System.out.println("   key: " + vd.getKey());
   17.26        System.out.println("  size: " + Library.formatSize(vd.getSize()*Settings.SECTOR_SIZE,8,true));
   17.27 -      if ( vd.getExpiry() != null )
   17.28 +      if ( vd.getExpiry() != null ) {
   17.29          System.out.println("expiry: " + vd.getExpiry());
   17.30 +      }
   17.31        System.out.println();
   17.32   
   17.33        Iterator i = vd.extents();
   17.34 @@ -58,10 +61,10 @@ public class ParseVdShow extends Command
   17.35    }
   17.36  
   17.37    public String getUsage() {
   17.38 -    return "[-n<diskno>]";
   17.39 +    return "[-k<key>]";
   17.40    }
   17.41  
   17.42    public String getHelpText() {
   17.43 -    return "Show a summary of all virtual disks, or details of one disk if -n is given";
   17.44 +    return "Show a summary of all virtual disks, or details of one disk if -k is given";
   17.45    }
   17.46  }
    18.1 --- a/tools/control/src/org/xenoserver/control/CommandPhysicalList.java	Tue Jul 08 14:50:37 2003 +0000
    18.2 +++ b/tools/control/src/org/xenoserver/control/CommandPhysicalList.java	Wed Jul 09 09:16:48 2003 +0000
    18.3 @@ -65,12 +65,16 @@ public class CommandPhysicalList extends
    18.4                  outline = in.readLine();
    18.5                  while (outline != null) {
    18.6                      int disk = -1;
    18.7 +                    int partition_no = -1;
    18.8                      long offset = -1;
    18.9                      long size = -1;
   18.10  
   18.11                      StringTokenizer st = new StringTokenizer(outline);
   18.12                      if (st.hasMoreTokens()) {
   18.13 -                        disk = Short.parseShort(st.nextToken(), 16);
   18.14 +                        disk = Integer.parseInt(st.nextToken(), 16);
   18.15 +                    }
   18.16 +                    if (st.hasMoreTokens()) {
   18.17 +                        partition_no = Integer.parseInt(st.nextToken(), 16);
   18.18                      }
   18.19                      if (st.hasMoreTokens()) {
   18.20                          offset = Long.parseLong(st.nextToken(), 16);
   18.21 @@ -80,7 +84,7 @@ public class CommandPhysicalList extends
   18.22                      }
   18.23                      if (st.hasMoreTokens()) {
   18.24                          String mode = st.nextToken();
   18.25 -                        Extent extent = new Extent(disk, offset, size);
   18.26 +                        Extent extent = new Extent(disk, offset, size, partition_no);
   18.27                          if (mode.equals("rw")) {
   18.28                              map.put(extent, Mode.READ_WRITE);
   18.29                          } else if (mode.equals("r")) {
    19.1 --- a/tools/control/src/org/xenoserver/control/VirtualDisk.java	Tue Jul 08 14:50:37 2003 +0000
    19.2 +++ b/tools/control/src/org/xenoserver/control/VirtualDisk.java	Wed Jul 09 09:16:48 2003 +0000
    19.3 @@ -169,8 +169,8 @@ public class VirtualDisk {
    19.4              Extent extent =
    19.5                  new Extent(
    19.6                      partition.getDisk(),
    19.7 -                    extentSize,
    19.8 -                    partition.getStartSect() + (extentSize * loop));
    19.9 +                    partition.getStartSect() + (extentSize * loop),
   19.10 +                    extentSize);
   19.11  
   19.12              addExtent(extent);
   19.13          }
    20.1 --- a/tools/control/src/org/xenoserver/control/XMLHelper.java	Tue Jul 08 14:50:37 2003 +0000
    20.2 +++ b/tools/control/src/org/xenoserver/control/XMLHelper.java	Wed Jul 09 09:16:48 2003 +0000
    20.3 @@ -146,10 +146,11 @@ class XMLHelper {
    20.4                                  XMLHelper.getSubNode("disk", enode))),
    20.5                          Long.parseLong(
    20.6                              XMLHelper.getText(
    20.7 -                                XMLHelper.getSubNode("size", enode))),
    20.8 -                        Long.parseLong(
    20.9 -                            XMLHelper.getText(
   20.10 -                                XMLHelper.getSubNode("offset", enode))));
   20.11 +                                XMLHelper.getSubNode("offset", enode))),
   20.12 +                    Long.parseLong(
   20.13 +                        XMLHelper.getText(
   20.14 +                            XMLHelper.getSubNode("size", enode))));
   20.15 +
   20.16                  vd.addExtent(extent);
   20.17              }
   20.18          }