bitkeeper revision 1.433 (3f699687J_HgoywKoa1018zIpJGRrQ)
authortlh20@labyrinth.cl.cam.ac.uk <tlh20@labyrinth.cl.cam.ac.uk>
Thu, 18 Sep 2003 11:27:03 +0000 (11:27 +0000)
committertlh20@labyrinth.cl.cam.ac.uk <tlh20@labyrinth.cl.cam.ac.uk>
Thu, 18 Sep 2003 11:27:03 +0000 (11:27 +0000)
CommandDomainNew.java, ParseDomainNew.java, Main.java, CommandParser.java:
  Expand + in -a and -t, allow spaces

tools/control/src/org/xenoserver/cmdline/CommandParser.java
tools/control/src/org/xenoserver/cmdline/Main.java
tools/control/src/org/xenoserver/cmdline/ParseDomainNew.java
tools/control/src/org/xenoserver/control/CommandDomainNew.java

index 1f558c36059738535b90641232e16a5122d26bdb..af8adfe268d58cd85431850d9eb0efb7cee41f7f 100644 (file)
@@ -84,7 +84,7 @@ public abstract class CommandParser {
      */
     public int getIntParameter(List args, char key, int def) {
         String r = getParameter(args, key);
-        return (r == null) ? def : (Integer.parseInt(r));
+        return (r == null) ? def : (Integer.parseInt(r.trim()));
     }
 
     /**
index fe7c6a2c258ecf935604c2279ca88ce8dfc75b96..cada1a10b86fc578ad3eb2b9f06f25daf5084699 100644 (file)
@@ -64,8 +64,27 @@ public class Main {
     Defaults d = new Defaults();
     int ec = -1;
     LinkedList arglist = new LinkedList();
+    boolean seen_arg = false;
+    String collected = null;
     for ( int i=0; i<args.length; i++ ) {
-      arglist.add( args[i] );
+      if (!(args[i].startsWith("-"))) {
+       if (seen_arg) {
+         collected += " " + args[i];
+       } else {
+         arglist.add(args[i]);
+       }
+      }
+      if (args[i].startsWith("-")) {
+       if (collected != null) {
+         arglist.add ( collected );
+         collected = null;
+       }
+       collected = args[i];
+       seen_arg = true;
+      }
+    }
+    if (collected != null) {
+      arglist.add( collected );
     }
 
     try {
index 9a353875422fb4c875806c8827ad85aca687003d..132c9eff3b09a3e6fe3e66d74c9d984b254c0469 100644 (file)
@@ -17,7 +17,7 @@ public class ParseDomainNew extends CommandParser {
         String image = getStringParameter(args, 'i', d.domainImage);
         String initrd = getStringParameter(args, 'r', d.domainInitRD);
         int vifs = getIntParameter(args, 'v', d.domainVIFs);
-        String bargs = getStringParameter(args, 'a', d.args) + " ";
+        String bargs = getStringParameter(args, 'a', d.args);
         String root_dev = getStringParameter(args, 'd', d.rootDevice);
         String root_args = getStringParameter(args, 't', d.rootArgs);
         String usr_dev = getStringParameter(args, 'u', d.usrDevice);
index 1060df9c5993cb6c09e20a04f4d31efff40f27c6..a5d69c3d4adcdcb26141d0edef4fdd13df415f99 100644 (file)
@@ -212,6 +212,7 @@ public class CommandDomainNew extends Command {
                 }
 
                 /* Set up boot parameters to pass to xi_build. */
+               bargs = StringPattern.parse(bargs).resolve(domain_id) + " ";
                 if (root_dev.equals("/dev/nfs")) {
                     if (vifs == 0) {
                         throw new CommandFailedException("Cannot use NFS root without VIFs configured");
@@ -224,7 +225,7 @@ public class CommandDomainNew extends Command {
                     }
                     bargs =
                         (bargs
-                            + " root=/dev/nfs " + root_args + " " 
+                            + " root=/dev/nfs " + StringPattern.parse(root_args).resolve(domain_id) + " " 
                             + "nfsroot="
                             + StringPattern.parse(nfs_root_path).resolve(
                                 domain_id)
@@ -234,7 +235,7 @@ public class CommandDomainNew extends Command {
                         (bargs
                             + " root="
                             + StringPattern.parse(root_dev).resolve(domain_id)
-                            + " " + root_args + " ");
+                            + " " + StringPattern.parse(root_args).resolve(domain_id) + " ");
 
                 }
                 
@@ -258,19 +259,19 @@ public class CommandDomainNew extends Command {
                         ("ip="
                             + domain_ip
                             + ":"
-                            + ((nw_nfs_server == null)
+                            + ((nw_nfs_server == null || nw_nfs_server.equals(""))
                                 ? ""
                                 : (InetAddressPattern
                                     .parse(nw_nfs_server)
                                     .resolve(domain_id)))
                             + ":"
-                            + ((nw_gw == null)
+                            + ((nw_gw == null || nw_gw.equals(""))
                                 ? ""
                                 : (InetAddressPattern
                                     .parse(nw_gw)
                                     .resolve(domain_id)))
                             + ":"
-                            + ((nw_mask == null)
+                            + ((nw_mask == null || nw_mask.equals(""))
                                 ? ""
                                 : InetAddressPattern.parse(nw_mask).resolve(
                                     domain_id))
@@ -342,6 +343,7 @@ public class CommandDomainNew extends Command {
         } catch (CommandFailedException e) {
             throw e;
         } catch (Exception e) {
+                                            e.printStackTrace();
             throw new CommandFailedException(
                 "Could not create new domain (" + e + ")",
                 e);