ia64/xen-unstable
changeset 707:c336be9fa2b2
bitkeeper revision 1.418.1.1 (3f5f3d862n2oSqg-bvcUtq4TeyrP1g)
Many files:
Attempt at new xenctl
Many files:
Attempt at new xenctl
line diff
1.1 --- a/tools/control/src/org/xenoserver/cmdline/Main.java Tue Sep 09 21:51:39 2003 +0000 1.2 +++ b/tools/control/src/org/xenoserver/cmdline/Main.java Wed Sep 10 15:04:38 2003 +0000 1.3 @@ -43,12 +43,23 @@ public class Main { 1.4 new ParseGroup( "domain", domaincommands ), 1.5 new ParseGroup( "partitions", partitioncommands ), 1.6 new ParseGroup( "physical", physicalcommands ), 1.7 + new ParseScript(), 1.8 new ParseGroup( "vd", vdcommands ), 1.9 new ParseGroup( "vbd", vbdcommands ) 1.10 }; 1.11 /** The top-level parser. */ 1.12 static final CommandParser parser = new ParseGroup( null, commands ); 1.13 1.14 + public static void executeArgList (Defaults d, LinkedList arglist) 1.15 + throws ParseFailedException, CommandFailedException 1.16 + { 1.17 + if (arglist.size() == 0) { 1.18 + help.parse(null, null); 1.19 + } else { 1.20 + parser.parse(d, arglist); 1.21 + } 1.22 + } 1.23 + 1.24 public static void main(String[] args) { 1.25 Defaults d = new Defaults(); 1.26 int ec = -1; 1.27 @@ -57,20 +68,15 @@ public class Main { 1.28 arglist.add( args[i] ); 1.29 } 1.30 1.31 - if (args.length == 0) { 1.32 + try { 1.33 + executeArgList (d, arglist); 1.34 + ec = 0; 1.35 + } catch (NoSuchElementException e) { 1.36 help.parse(null, null); 1.37 - } else { 1.38 - try 1.39 - { 1.40 - parser.parse(d, arglist); 1.41 - ec = 0; 1.42 - } catch (NoSuchElementException e) { 1.43 - help.parse(null, null); 1.44 - } catch (ParseFailedException e) { 1.45 - System.err.println( e.getMessage() ); 1.46 - } catch (CommandFailedException e) { 1.47 - System.err.println( e.getMessage() ); 1.48 - } 1.49 + } catch (ParseFailedException e) { 1.50 + System.err.println( e.getMessage() ); 1.51 + } catch (CommandFailedException e) { 1.52 + System.err.println( e.getMessage() ); 1.53 } 1.54 1.55 System.exit(ec);
2.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java Tue Sep 09 21:51:39 2003 +0000 2.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java Wed Sep 10 15:04:38 2003 +0000 2.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults; 2.4 public class ParseDomainDestroy extends CommandParser { 2.5 public void parse(Defaults d, LinkedList args) 2.6 throws ParseFailedException, CommandFailedException { 2.7 - int domain_id = getIntParameter(args, 'n', 0); 2.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 2.9 boolean force = getFlagParameter(args, 'f'); 2.10 2.11 if (domain_id == 0) { 2.12 @@ -27,7 +27,7 @@ public class ParseDomainDestroy extends 2.13 } 2.14 2.15 public String getUsage() { 2.16 - return "-n<domain_id> [-f]"; 2.17 + return "[-n<domain_id>] [-f]"; 2.18 } 2.19 2.20 public String getHelpText() {
3.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java Tue Sep 09 21:51:39 2003 +0000 3.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java Wed Sep 10 15:04:38 2003 +0000 3.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults; 3.4 public class ParseDomainStart extends CommandParser { 3.5 public void parse(Defaults d, LinkedList args) 3.6 throws ParseFailedException, CommandFailedException { 3.7 - int domain_id = getIntParameter(args, 'n', 0); 3.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 3.9 3.10 if (domain_id == 0) { 3.11 throw new ParseFailedException("Expected -n<domain_id>"); 3.12 @@ -25,7 +25,7 @@ public class ParseDomainStart extends Co 3.13 } 3.14 3.15 public String getUsage() { 3.16 - return "-n<domain_id>"; 3.17 + return "[-n<domain_id>]"; 3.18 } 3.19 3.20 public String getHelpText() {
4.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java Tue Sep 09 21:51:39 2003 +0000 4.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java Wed Sep 10 15:04:38 2003 +0000 4.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults; 4.4 public class ParseDomainStop extends CommandParser { 4.5 public void parse(Defaults d, LinkedList args) 4.6 throws ParseFailedException, CommandFailedException { 4.7 - int domain_id = getIntParameter(args, 'n', 0); 4.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 4.9 4.10 if (domain_id == 0) { 4.11 throw new ParseFailedException("Expected -n<domain_id>"); 4.12 @@ -25,7 +25,7 @@ public class ParseDomainStop extends Com 4.13 } 4.14 4.15 public String getUsage() { 4.16 - return "-n<domain_id>"; 4.17 + return "[-n<domain_id>]"; 4.18 } 4.19 4.20 public String getHelpText() {
5.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java Tue Sep 09 21:51:39 2003 +0000 5.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java Wed Sep 10 15:04:38 2003 +0000 5.3 @@ -10,7 +10,7 @@ import org.xenoserver.control.Mode; 5.4 public class ParsePhysicalGrant extends CommandParser { 5.5 public void parse(Defaults d, LinkedList args) 5.6 throws ParseFailedException, CommandFailedException { 5.7 - int domain_id = getIntParameter(args, 'n', 0); 5.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 5.9 boolean force = getFlagParameter(args, 'f'); 5.10 String partition_name = getStringParameter(args, 'p', ""); 5.11 boolean write = getFlagParameter(args, 'w'); 5.12 @@ -44,7 +44,7 @@ public class ParsePhysicalGrant extends 5.13 } 5.14 5.15 public String getUsage() { 5.16 - return "-n<domain_id> -p<partition_name> [-f] [-w]"; 5.17 + return "-p<partition_name> [-n<domain_id>] [-f] [-w]"; 5.18 } 5.19 5.20 public String getHelpText() {
6.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java Tue Sep 09 21:51:39 2003 +0000 6.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java Wed Sep 10 15:04:38 2003 +0000 6.3 @@ -15,7 +15,7 @@ import org.xenoserver.control.PartitionM 6.4 public class ParsePhysicalList extends CommandParser { 6.5 public void parse(Defaults d, LinkedList args) 6.6 throws ParseFailedException, CommandFailedException { 6.7 - int domain_id = getIntParameter(args, 'n', 0); 6.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 6.9 if (domain_id == 0) { 6.10 throw new ParseFailedException("Expected -n<domain_id>"); 6.11 }
7.1 --- a/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java Tue Sep 09 21:51:39 2003 +0000 7.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java Wed Sep 10 15:04:38 2003 +0000 7.3 @@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults; 7.4 public class ParsePhysicalRevoke extends CommandParser { 7.5 public void parse(Defaults d, LinkedList args) 7.6 throws ParseFailedException, CommandFailedException { 7.7 - int domain_id = getIntParameter(args, 'n', 0); 7.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 7.9 String partition_name = getStringParameter(args, 'p', ""); 7.10 7.11 if (domain_id == 0) { 7.12 @@ -32,7 +32,7 @@ public class ParsePhysicalRevoke extends 7.13 } 7.14 7.15 public String getUsage() { 7.16 - return "-n<domain_id> -p<partition_name>"; 7.17 + return "-p<partition_name> [-n<domain_id>]"; 7.18 } 7.19 7.20 public String getHelpText() {
8.1 --- a/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java Tue Sep 09 21:51:39 2003 +0000 8.2 +++ b/tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java Wed Sep 10 15:04:38 2003 +0000 8.3 @@ -13,7 +13,7 @@ public class ParseVbdCreate extends Comm 8.4 throws ParseFailedException, CommandFailedException { 8.5 String vd_key = getStringParameter(args, 'k', ""); 8.6 String partition_name = getStringParameter(args, 'p', ""); 8.7 - int domain_id = getIntParameter(args, 'n', 0); 8.8 + int domain_id = getIntParameter(args, 'n', d.domainNumber); 8.9 int vbd_num = getIntParameter(args, 'v', -1); 8.10 boolean write = getFlagParameter(args, 'w'); 8.11 8.12 @@ -53,7 +53,7 @@ public class ParseVbdCreate extends Comm 8.13 } 8.14 8.15 public String getUsage() { 8.16 - return "-n<domain_id> {-k<key>|-p<partition} -v<vbd_num> [-w]"; 8.17 + return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w]"; 8.18 } 8.19 8.20 public String getHelpText() {
9.1 --- a/tools/control/src/org/xenoserver/control/CommandDomainNew.java Tue Sep 09 21:51:39 2003 +0000 9.2 +++ b/tools/control/src/org/xenoserver/control/CommandDomainNew.java Wed Sep 10 15:04:38 2003 +0000 9.3 @@ -185,6 +185,7 @@ public class CommandDomainNew extends Co 9.4 domain_id = Integer.parseInt(br.readLine()); 9.5 create_rc = create_p.waitFor(); 9.6 } 9.7 + d.domainNumber = domain_id; 9.8 9.9 if (create_rc != 0) { 9.10 throw CommandFailedException.xiCommandFailed(
10.1 --- a/tools/control/src/org/xenoserver/control/Defaults.java Tue Sep 09 21:51:39 2003 +0000 10.2 +++ b/tools/control/src/org/xenoserver/control/Defaults.java Wed Sep 10 15:04:38 2003 +0000 10.3 @@ -49,6 +49,8 @@ public class Defaults { 10.4 public String args = ""; 10.5 /** Directory to find XI tools. */ 10.6 public String xiToolsDir = ""; 10.7 + /** Domain number */ 10.8 + public int domainNumber; 10.9 10.10 10.11 /** 10.12 @@ -143,6 +145,8 @@ public class Defaults { 10.13 domainImage = s; 10.14 } else if (lastName.equals("domain_name")) { 10.15 domainName = s; 10.16 + } else if (lastName.equals("domain_number")) { 10.17 + domainNumber = Integer.parseInt(s); 10.18 } else if (lastName.equals("domain_init_rd")) { 10.19 domainInitRD = s; 10.20 } else if (lastName.equals("domain_vifs")) {
11.1 --- a/tools/control/src/org/xenoserver/control/Settings.java Tue Sep 09 21:51:39 2003 +0000 11.2 +++ b/tools/control/src/org/xenoserver/control/Settings.java Wed Sep 10 15:04:38 2003 +0000 11.3 @@ -14,12 +14,6 @@ public final class Settings { 11.4 /** Path to search for the defaults file. */ 11.5 public static final String DEFAULTS_PATH = 11.6 System.getProperty("DEFAULTS_PATH", ".:/etc:/var/lib/xen"); 11.7 - /** IP address of domain 0. */ 11.8 - public static final String LOCAL_IP = System.getProperty("LOCAL_IP"); 11.9 - /** Network mask of domain 0. */ 11.10 - public static final String LOCAL_MASK = System.getProperty("LOCAL_MASK"); 11.11 - /** Gateway of domain 0. */ 11.12 - public static final String LOCAL_GW = System.getProperty("LOCAL_ROUTE"); 11.13 /** If set, do not call any xi_ commands, just print their command lines. */ 11.14 public static final boolean TEST = (System.getProperty("TEST") != null); 11.15 /** Name of xi_helper utility. */
12.1 --- a/tools/control/xenctl Tue Sep 09 21:51:39 2003 +0000 12.2 +++ b/tools/control/xenctl Wed Sep 10 15:04:38 2003 +0000 12.3 @@ -7,27 +7,7 @@ if [ -z "$IFCONFIG" ] ; then IFCONFIG=/s 12.4 if [ -z "$ROUTE" ] ; then ROUTE=/sbin/route ; fi 12.5 if [ -z "$JAVA" ] ; then JAVA=java ; fi 12.6 12.7 -if [ "$1" = "domain" -a "$2" = "new" ] ; then 12.8 - if [ ! -x "$IFCONFIG" ]; then 12.9 - echo Could not find executable $IFCONFIG 12.10 - exit 1 12.11 - fi 12.12 - 12.13 - if [ ! -x "$ROUTE" ]; then 12.14 - echo Could not find executable $ROUTE 12.15 - exit 1 12.16 - fi 12.17 12.18 - # Try to determine dom0 network settings to avoid hard-coding 12.19 - # particular machines in the defaults file 12.20 - LOCAL_IP=$(/sbin/ifconfig $QUERY_DEV | grep 'inet addr' | tr ':' '\t' | awk '{print $3}') 12.21 - LOCAL_MASK=$(/sbin/ifconfig $QUERY_DEV | grep 'Mask' | tr ':' '\t' | awk '{print $7}') 12.22 - LOCAL_ROUTE=$(/sbin/route -n | grep $QUERY_DEV | grep 'G' | awk '{print $2}') 12.23 -fi 12.24 - 12.25 - 12.26 -#ARGS="-DTEST -DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE" 12.27 -ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE" 12.28 - 12.29 +ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH" 12.30 12.31 $JAVA $ARGS -jar $(dirname $0)/xenctl-cmdline.jar $*