ia64/xen-unstable

changeset 769:507cc6057e73

bitkeeper revision 1.466 (3f74af20jRDu98OIOzjbFFgBNLz47g)

Many files:
Add -x option to xenctl to give number to subst for + in patterns
author tlh20@labyrinth.cl.cam.ac.uk
date Fri Sep 26 21:26:56 2003 +0000 (2003-09-26)
parents 2a619b827540
children 8128e1dc99aa
files tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java tools/control/src/org/xenoserver/control/CommandDomainNew.java tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java
line diff
     1.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java	Fri Sep 26 19:44:53 2003 +0000
     1.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java	Fri Sep 26 21:26:56 2003 +0000
     1.3 @@ -27,6 +27,7 @@ public class ParseDomainNew extends Comm
     1.4          String nw_mask = getStringParameter(args, 'm', d.nwMask);
     1.5          String nw_nfs_server = getStringParameter(args, 's', d.nwNFSServer);
     1.6          String nw_host = getStringParameter(args, 'h', d.nwHost);
     1.7 +	int subst = getIntParameter(args, 'x', -1);
     1.8  
     1.9          d.describe();
    1.10  
    1.11 @@ -47,7 +48,8 @@ public class ParseDomainNew extends Comm
    1.12                  nw_mask,
    1.13                  nw_nfs_server,
    1.14                  nw_host,
    1.15 -                usr_dev);
    1.16 +                usr_dev,
    1.17 +		subst);
    1.18          c.execute();
    1.19          String[] output = c.output();
    1.20          for (int i = 0; i < output.length; i++) {
    1.21 @@ -57,7 +59,7 @@ public class ParseDomainNew extends Comm
    1.22          if (root_dev.startsWith("/dev/sda") || root_dev.startsWith("/dev/hda")) {
    1.23              String real_root = StringPattern.parse(root_dev).resolve(c.domain_id());
    1.24              String device = real_root.substring(real_root.indexOf('/',1)+1);
    1.25 -            CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_WRITE,false);
    1.26 +            CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_WRITE,false,subst);
    1.27              String output2 = cg.execute();
    1.28              if ( output2 != null ) {
    1.29                  System.out.println(output2);
    1.30 @@ -67,7 +69,7 @@ public class ParseDomainNew extends Comm
    1.31          if (usr_dev != null && ((usr_dev.startsWith("/dev/sda")) || usr_dev.startsWith("/dev/hda"))) {
    1.32              String real_usr = StringPattern.parse(usr_dev).resolve(c.domain_id());
    1.33              String device = real_usr.substring(real_usr.indexOf('/',1)+1);
    1.34 -            CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_ONLY,false);
    1.35 +            CommandPhysicalGrant cg = new CommandPhysicalGrant(d,c.domain_id(),device,Mode.READ_ONLY,false,subst);
    1.36              String output2 = cg.execute();
    1.37              if ( output2 != null ) {
    1.38                  System.out.println(output2);
    1.39 @@ -80,7 +82,7 @@ public class ParseDomainNew extends Comm
    1.40      }
    1.41  
    1.42      public String getUsage() {
    1.43 -        return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-t<root_mount_args>] [-u<usr_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>]";
    1.44 +        return "[-n<domain_name>] [-k<size>] [-i<image>] [-v<num_vifs>] [-r<initrd>] [-d<root_device>] [-t<root_mount_args>] [-u<usr_device>] [-f<nfs_root>] [-s<nfs_boot_server>] [-4<ipv4_boot_address>] [-g<ipv4_boot_gateway>] [-m<ipv4_boot_netmask>] [-h<hostname>] [-a<args>] [-x<subst>]";
    1.45      }
    1.46  
    1.47      public String getHelpText() {
    1.48 @@ -98,6 +100,7 @@ public class ParseDomainNew extends Comm
    1.49              + "  -t  Root mount args (e.g ro)                 root_args\n"
    1.50              + "  -u  Usr dev/path (e.g /dev/hda3, server:path)usr_device\n"
    1.51              + "  -a  Additional boot parameters               args\n"
    1.52 +            + "  -x  Number to substitute for + if not domain id\n"
    1.53              + "\n"
    1.54              + "Networking options:\n"
    1.55              + "  -f  NFS root (if /dev/nfs specified)         nw_nfs_root\n"
     2.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Fri Sep 26 19:44:53 2003 +0000
     2.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java	Fri Sep 26 21:26:56 2003 +0000
     2.3 @@ -14,6 +14,7 @@ public class ParsePhysicalGrant extends 
     2.4          boolean force = getFlagParameter(args, 'f');
     2.5          String partition_name = getStringParameter(args, 'p', "");
     2.6          boolean write = getFlagParameter(args, 'w');
     2.7 +	int subst = getIntParameter(args, 'x', -1);
     2.8  
     2.9          if (domain_id == 0) {
    2.10              throw new ParseFailedException("Expected -n<domain_id>");
    2.11 @@ -32,7 +33,7 @@ public class ParsePhysicalGrant extends 
    2.12          // Initialise the partition manager and look up the partition
    2.13          loadState();
    2.14          String output =
    2.15 -            new CommandPhysicalGrant(d, domain_id, partition_name, mode, force)
    2.16 +            new CommandPhysicalGrant(d, domain_id, partition_name, mode, force,subst)
    2.17                  .execute();
    2.18          if (output != null) {
    2.19              System.out.println(output);
    2.20 @@ -44,7 +45,7 @@ public class ParsePhysicalGrant extends 
    2.21      }
    2.22  
    2.23      public String getUsage() {
    2.24 -        return "-p<partition_name> [-n<domain_id>] [-f] [-w]";
    2.25 +        return "-p<partition_name> [-n<domain_id>] [-f] [-w] [-x<subst>]";
    2.26      }
    2.27  
    2.28      public String getHelpText() {
     3.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Fri Sep 26 19:44:53 2003 +0000
     3.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java	Fri Sep 26 21:26:56 2003 +0000
     3.3 @@ -11,6 +11,7 @@ public class ParsePhysicalRevoke extends
     3.4          throws ParseFailedException, CommandFailedException {
     3.5          int domain_id = getIntParameter(args, 'n', d.domainNumber);
     3.6          String partition_name = getStringParameter(args, 'p', "");
     3.7 +	int subst = getIntParameter(args, 'x', -1);
     3.8  
     3.9          if (domain_id == 0) {
    3.10              throw new ParseFailedException("Expected -n<domain_id>");
    3.11 @@ -21,7 +22,7 @@ public class ParsePhysicalRevoke extends
    3.12  
    3.13          // Initialise the partition manager and look up the partition
    3.14          loadState();
    3.15 -        String output = new CommandPhysicalRevoke(d, domain_id, partition_name).execute();
    3.16 +        String output = new CommandPhysicalRevoke(d, domain_id, partition_name, subst).execute();
    3.17          if (output != null) {
    3.18              System.out.println(output);
    3.19          }
    3.20 @@ -32,7 +33,7 @@ public class ParsePhysicalRevoke extends
    3.21      }
    3.22  
    3.23      public String getUsage() {
    3.24 -        return "-p<partition_name> [-n<domain_id>]";
    3.25 +        return "-p<partition_name> [-n<domain_id>] [-x<subst>]";
    3.26      }
    3.27  
    3.28      public String getHelpText() {
     4.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java	Fri Sep 26 19:44:53 2003 +0000
     4.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java	Fri Sep 26 21:26:56 2003 +0000
     4.3 @@ -16,6 +16,7 @@ public class ParseVbdCreate extends Comm
     4.4          int domain_id = getIntParameter(args, 'n', d.domainNumber);
     4.5          int vbd_num = getIntParameter(args, 'v', -1);
     4.6          boolean write = getFlagParameter(args, 'w');
     4.7 +	int subst = getIntParameter(args, 'x', -1);
     4.8  
     4.9          if (vd_key.equals("") && partition_name.equals("")) {
    4.10              throw new ParseFailedException("Expected -k<key> or -p<partition>");
    4.11 @@ -37,7 +38,7 @@ public class ParseVbdCreate extends Comm
    4.12          loadState();
    4.13          String output;
    4.14          if (vd_key.equals("")) {
    4.15 -            output = new CommandVbdCreatePhysical(d,  partition_name, domain_id, vbd_num, mode ).execute();
    4.16 +            output = new CommandVbdCreatePhysical(d,  partition_name, domain_id, vbd_num, mode, subst ).execute();
    4.17          } else {
    4.18              output =
    4.19                  new CommandVbdCreate(vd_key, domain_id, vbd_num, mode).execute();
    4.20 @@ -53,7 +54,7 @@ public class ParseVbdCreate extends Comm
    4.21      }
    4.22  
    4.23      public String getUsage() {
    4.24 -        return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w]";
    4.25 +        return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w] [-x<subst>]";
    4.26      }
    4.27  
    4.28      public String getHelpText() {
     5.1 --- a/tools/control/src/org/xenoserver/control/CommandDomainNew.java	Fri Sep 26 19:44:53 2003 +0000
     5.2 +++ b/tools/control/src/org/xenoserver/control/CommandDomainNew.java	Fri Sep 26 21:26:56 2003 +0000
     5.3 @@ -52,6 +52,8 @@ public class CommandDomainNew extends Co
     5.4      private String[] output;
     5.5      /** Domain ID created. */
     5.6      private int domain_id;
     5.7 +    /** Number to substitute for + (-1 => use domain_id) */
     5.8 +    private int subst;
     5.9  
    5.10      /**
    5.11       * @return Output from domain creation.
    5.12 @@ -99,8 +101,9 @@ public class CommandDomainNew extends Co
    5.13          String nw_gw,
    5.14          String nw_mask,
    5.15          String nw_nfs_server,
    5.16 -        String nw_host) {
    5.17 -        this(d,name,size,image,initrd,vifs,bargs,root_dev,root_args,nfs_root_path,nw_ip,nw_gw,nw_mask,nw_nfs_server,nw_host,null);
    5.18 +        String nw_host,
    5.19 +	int subst) {
    5.20 +        this(d,name,size,image,initrd,vifs,bargs,root_dev,root_args,nfs_root_path,nw_ip,nw_gw,nw_mask,nw_nfs_server,nw_host,null,subst);
    5.21      }
    5.22      
    5.23      public CommandDomainNew(
    5.24 @@ -119,7 +122,8 @@ public class CommandDomainNew extends Co
    5.25          String nw_mask,
    5.26          String nw_nfs_server,
    5.27          String nw_host,
    5.28 -        String usr_dev) {
    5.29 +        String usr_dev,
    5.30 +	int subst) {
    5.31              this.d = d;
    5.32              this.name = name;
    5.33              this.size = size;
    5.34 @@ -136,6 +140,7 @@ public class CommandDomainNew extends Co
    5.35              this.nw_nfs_server = nw_nfs_server;
    5.36              this.nw_host = nw_host;
    5.37              this.usr_dev = usr_dev;
    5.38 +	    this.subst = subst;
    5.39      }
    5.40  
    5.41      /**
    5.42 @@ -211,8 +216,10 @@ public class CommandDomainNew extends Co
    5.43                              + " domains");
    5.44                  }
    5.45  
    5.46 +		if (subst == -1) subst = domain_id;
    5.47 +
    5.48                  /* Set up boot parameters to pass to xi_build. */
    5.49 -		bargs = StringPattern.parse(bargs).resolve(domain_id) + " ";
    5.50 +		bargs = StringPattern.parse(bargs).resolve(subst) + " ";
    5.51                  if (root_dev.equals("/dev/nfs")) {
    5.52                      if (vifs == 0) {
    5.53                          throw new CommandFailedException("Cannot use NFS root without VIFs configured");
    5.54 @@ -225,27 +232,27 @@ public class CommandDomainNew extends Co
    5.55                      }
    5.56                      bargs =
    5.57                          (bargs
    5.58 -                            + " root=/dev/nfs " + StringPattern.parse(root_args).resolve(domain_id) + " " 
    5.59 +                            + " root=/dev/nfs " + StringPattern.parse(root_args).resolve(subst) + " " 
    5.60                              + "nfsroot="
    5.61                              + StringPattern.parse(nfs_root_path).resolve(
    5.62 -                                domain_id)
    5.63 +                                subst)
    5.64                              + " ");
    5.65                  } else {
    5.66                      bargs =
    5.67                          (bargs
    5.68                              + " root="
    5.69 -                            + StringPattern.parse(root_dev).resolve(domain_id)
    5.70 -                            + " " + StringPattern.parse(root_args).resolve(domain_id) + " ");
    5.71 +                            + StringPattern.parse(root_dev).resolve(subst)
    5.72 +                            + " " + StringPattern.parse(root_args).resolve(subst) + " ");
    5.73  
    5.74                  }
    5.75                  
    5.76                  if (usr_dev != null && !usr_dev.equals("")) {
    5.77 -                    bargs = bargs + " usr=" + StringPattern.parse(usr_dev).resolve(domain_id) + " ";
    5.78 +                    bargs = bargs + " usr=" + StringPattern.parse(usr_dev).resolve(subst) + " ";
    5.79                  }
    5.80  
    5.81                  if (vifs > 0) {
    5.82                      domain_ip =
    5.83 -                        InetAddressPattern.parse(nw_ip).resolve(domain_id);
    5.84 +                        InetAddressPattern.parse(nw_ip).resolve(subst);
    5.85                   /*   if (nw_host == null) {
    5.86                          try {
    5.87                              nw_host =
    5.88 @@ -263,18 +270,18 @@ public class CommandDomainNew extends Co
    5.89                                  ? ""
    5.90                                  : (InetAddressPattern
    5.91                                      .parse(nw_nfs_server)
    5.92 -                                    .resolve(domain_id)))
    5.93 +                                    .resolve(subst)))
    5.94                              + ":"
    5.95                              + ((nw_gw == null || nw_gw.equals(""))
    5.96                                  ? ""
    5.97                                  : (InetAddressPattern
    5.98                                      .parse(nw_gw)
    5.99 -                                    .resolve(domain_id)))
   5.100 +                                    .resolve(subst)))
   5.101                              + ":"
   5.102                              + ((nw_mask == null || nw_mask.equals(""))
   5.103                                  ? ""
   5.104                                  : InetAddressPattern.parse(nw_mask).resolve(
   5.105 -                                    domain_id))
   5.106 +                                    subst))
   5.107                              + ":"
   5.108                              + ((nw_host == null) ? "" : nw_host)
   5.109                              + ":eth0:off "
     6.1 --- a/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java	Fri Sep 26 19:44:53 2003 +0000
     6.2 +++ b/tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java	Fri Sep 26 21:26:56 2003 +0000
     6.3 @@ -14,6 +14,8 @@ public class CommandPhysicalGrant extend
     6.4      private Mode mode;
     6.5      /** True to force grant */
     6.6      private boolean force;
     6.7 +    /** Number to substitute for + (-1 => use domain_id) */
     6.8 +    private int subst;
     6.9  
    6.10      /**
    6.11       * Constructor for CommandPhysicalGrant.
    6.12 @@ -28,12 +30,14 @@ public class CommandPhysicalGrant extend
    6.13          int domain_id,
    6.14          String partition,
    6.15          Mode mode,
    6.16 -        boolean force) {
    6.17 +        boolean force,
    6.18 +	int subst) {
    6.19          this.d = d;
    6.20          this.domain_id = domain_id;
    6.21          this.partition_name = partition;
    6.22          this.mode = mode;
    6.23          this.force = force;
    6.24 +	this.subst = subst;
    6.25      }
    6.26  
    6.27      /**
    6.28 @@ -42,7 +46,7 @@ public class CommandPhysicalGrant extend
    6.29      public String execute() throws CommandFailedException {
    6.30          Runtime r = Runtime.getRuntime();
    6.31          String output = null;
    6.32 -	String resolved = StringPattern.parse(partition_name).resolve(domain_id);
    6.33 +	String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
    6.34  	String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
    6.35          Partition partition = PartitionManager.IT.getPartition(resolved2);
    6.36      
     7.1 --- a/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java	Fri Sep 26 19:44:53 2003 +0000
     7.2 +++ b/tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java	Fri Sep 26 21:26:56 2003 +0000
     7.3 @@ -10,6 +10,8 @@ public class CommandPhysicalRevoke exten
     7.4      private int domain_id;
     7.5      /** Partition to revoke access to */
     7.6      private String partition_name;
     7.7 +    /** Number to substitute for + (-1 => use domain_id) */
     7.8 +    private int subst;
     7.9  
    7.10      /**
    7.11       * Constructor for CommandPhysicalRevoke.
    7.12 @@ -17,10 +19,11 @@ public class CommandPhysicalRevoke exten
    7.13       * @param domain_id Domain to revoke access from.
    7.14       * @param partition Partition to revoke access to.
    7.15       */
    7.16 -    public CommandPhysicalRevoke(Defaults d, int domain_id, String partition) {
    7.17 +    public CommandPhysicalRevoke(Defaults d, int domain_id, String partition, int subst) {
    7.18          this.d = d;
    7.19          this.domain_id = domain_id;
    7.20          this.partition_name = partition;
    7.21 +	this.subst = subst;
    7.22      }
    7.23  
    7.24      /**
    7.25 @@ -29,7 +32,7 @@ public class CommandPhysicalRevoke exten
    7.26      public String execute() throws CommandFailedException {
    7.27          Runtime r = Runtime.getRuntime();
    7.28          String output = null;
    7.29 -	String resolved = StringPattern.parse(partition_name).resolve(domain_id);
    7.30 +	String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
    7.31  	String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
    7.32          Partition partition = PartitionManager.IT.getPartition(resolved2);
    7.33  
     8.1 --- a/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java	Fri Sep 26 19:44:53 2003 +0000
     8.2 +++ b/tools/control/src/org/xenoserver/control/CommandVbdCreatePhysical.java	Fri Sep 26 21:26:56 2003 +0000
     8.3 @@ -17,6 +17,8 @@ public class CommandVbdCreatePhysical ex
     8.4      private int vbd_num;
     8.5      /** Access mode to grant. */
     8.6      private Mode mode;
     8.7 +    /** Number to substitute for + (-1 => use domain_id) */
     8.8 +    private int subst;
     8.9  
    8.10      /**
    8.11       * Constructor for CommandVbdCreate.
    8.12 @@ -30,19 +32,21 @@ public class CommandVbdCreatePhysical ex
    8.13  	String partition,
    8.14          int domain_id,
    8.15          int vbd_num,
    8.16 -        Mode mode) {
    8.17 +        Mode mode,
    8.18 +	int subst) {
    8.19          this.d = d;
    8.20          this.partition_name = partition;
    8.21          this.domain_id = domain_id;
    8.22          this.vbd_num = vbd_num;
    8.23          this.mode = mode;
    8.24 +	this.subst = subst;
    8.25      }
    8.26  
    8.27      /**
    8.28       * @see org.xenoserver.control.Command#execute()
    8.29       */
    8.30      public String execute() throws CommandFailedException {
    8.31 -        String resolved = StringPattern.parse(partition_name).resolve(domain_id);
    8.32 +        String resolved = StringPattern.parse(partition_name).resolve(subst == -1 ? domain_id : subst);
    8.33  	String resolved2 = d.runCommand(d.xiToolsDir + Settings.XI_HELPER + " expand " + resolved).trim();
    8.34          Partition partition = PartitionManager.IT.getPartition(resolved2);
    8.35          if (partition == null) {