debuggers.hg
changeset 595:d2e63f4ee02e
bitkeeper revision 1.304.1.3 (3f0bddb6Ch28VohngLcKCCbcXEwq2Q)
Prune unneeded bits of old vdmanager code; main and parser. All their functionality has been liberated. =)
Prune unneeded bits of old vdmanager code; main and parser. All their functionality has been liberated. =)
author | rac61@labyrinth.cl.cam.ac.uk |
---|---|
date | Wed Jul 09 09:17:42 2003 +0000 (2003-07-09) |
parents | bd3c746eb8ca |
children | 4fb0fd9f744b |
files | .rootkeys tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java |
line diff
1.1 --- a/.rootkeys Wed Jul 09 09:16:48 2003 +0000 1.2 +++ b/.rootkeys Wed Jul 09 09:17:42 2003 +0000 1.3 @@ -64,8 +64,6 @@ 3ec41f7dVFBlviwXPQ06BlU3UybziA tools/con 1.4 3ec41f7dKX9YpwrfH7BZ7BogyWqqLA tools/control/src/org/xenoserver/control/VirtualDiskManager.java 1.5 3ec41f7dUPpYTwYL5QVpRBv6PLKPrg tools/control/src/org/xenoserver/control/XML.java 1.6 3ec41f7d7Try-2zmfnpaALwJjY0GCA tools/control/src/org/xenoserver/control/XMLHelper.java 1.7 -3ec41f7civcv4mQiYK0DeX9Zvsxhrw tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig 1.8 -3ec41f7d3-xTeoVJBJqWqxVfU-ANoQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java 1.9 3ec41f7dOVZgjP4sQS6vjuBnExdlMQ tools/control/src/uk/ac/cam/cl/xeno/xenctl/RootBean.java 1.10 3ec41f7dvPdszb0frNEkMnEdJUBVjA tools/control/src/uk/ac/cam/cl/xeno/xenctl/SystemConfigurationBean.java 1.11 3ec41f7dO6IuKGGLG4VRUhMDmkTn5g tools/control/web/WEB-INF/web.xml
2.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Main.java.orig Wed Jul 09 09:16:48 2003 +0000 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,35 +0,0 @@ 2.4 -/* 2.5 - * Main.java 2.6 - * 03.03.26 aho creation 2.7 - */ 2.8 - 2.9 -package uk.ac.cam.cl.xeno.vdmanager; 2.10 - 2.11 -import java.util.Date; 2.12 - 2.13 -public class 2.14 -Main 2.15 -{ 2.16 - static String state_filename_in = "/var/lib/xen/vdstate.xml"; 2.17 - static String state_filename_out = "/var/lib/xen/vdstate.xml"; 2.18 - static String partition_filename = "/proc/partitions"; 2.19 - 2.20 - void 2.21 - go (String[] argv) 2.22 - { 2.23 - PartitionManager pm = new PartitionManager(partition_filename); 2.24 - VirtualDiskManager vdm = new VirtualDiskManager();; 2.25 - Parser parser = new Parser(pm, vdm); 2.26 - 2.27 - XML.load_state(pm, vdm, state_filename_in); 2.28 - parser.parse_main(argv); 2.29 - XML.dump_state(pm, vdm, state_filename_out); 2.30 - } 2.31 - 2.32 - public static void 2.33 - main (String[] argv) 2.34 - { 2.35 - Main foo = new Main(); 2.36 - foo.go(argv); 2.37 - } 2.38 -}
3.1 --- a/tools/control/src/uk/ac/cam/cl/xeno/xenctl/Parser.java Wed Jul 09 09:16:48 2003 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,446 +0,0 @@ 3.4 -/* 3.5 - * Parser.java 3.6 - * 03.03.27 aho creation 3.7 - */ 3.8 - 3.9 -package uk.ac.cam.cl.xeno.xenctl; 3.10 - 3.11 -import java.io.BufferedReader; 3.12 -import java.io.FileReader; 3.13 -import java.io.InputStreamReader; 3.14 -import java.io.FileNotFoundException; 3.15 -import java.io.IOException; 3.16 -import java.util.StringTokenizer; 3.17 -import java.util.Vector; 3.18 -import java.util.Date; 3.19 - 3.20 -public class 3.21 -Parser 3.22 -{ 3.23 - static String prompt = "vdmanager> "; 3.24 - static String default_addpartition_chunksize = "104857600"; /* 100M */ 3.25 - static int default_sector_size = 512; 3.26 - 3.27 - PartitionManager pm; 3.28 - VirtualDiskManager vdm; 3.29 - 3.30 - Parser (PartitionManager pm, VirtualDiskManager vdm) 3.31 - { 3.32 - this.pm = pm; 3.33 - this.vdm = vdm; 3.34 - } 3.35 - 3.36 - void 3.37 - parse_main (String[] argv) 3.38 - { 3.39 - if (argv.length == 0) 3.40 - { 3.41 - parse_input(null); 3.42 - } 3.43 - else 3.44 - { 3.45 - parse_commandline(argv); 3.46 - } 3.47 - } 3.48 - 3.49 - void 3.50 - parse_input (String filename) 3.51 - { 3.52 - String line; 3.53 - BufferedReader in; 3.54 - 3.55 - if (filename != null) 3.56 - { 3.57 - try 3.58 - { 3.59 - in = new BufferedReader(new FileReader(filename)); 3.60 - } 3.61 - catch (FileNotFoundException fnfe) 3.62 - { 3.63 - System.err.println (fnfe); 3.64 - return; 3.65 - } 3.66 - } 3.67 - else 3.68 - { 3.69 - in = new BufferedReader(new InputStreamReader(System.in)); 3.70 - } 3.71 - 3.72 - try 3.73 - { 3.74 - if (filename == null) 3.75 - { 3.76 - System.out.print (prompt); 3.77 - } 3.78 - line = in.readLine(); 3.79 - while (line != null) 3.80 - { 3.81 - StringTokenizer st = new StringTokenizer(line); 3.82 - Vector v = new Vector(); 3.83 - 3.84 - while (st.hasMoreTokens()) 3.85 - { 3.86 - v.add(st.nextToken()); 3.87 - } 3.88 - 3.89 - if (parse_commandline((String[]) v.toArray(new String[v.size()]))) 3.90 - { 3.91 - return; 3.92 - } 3.93 - 3.94 - if (filename == null) 3.95 - { 3.96 - System.out.print (prompt); 3.97 - } 3.98 - line = in.readLine(); 3.99 - } 3.100 - } 3.101 - catch (IOException ioe) 3.102 - { 3.103 - System.err.println(ioe); 3.104 - } 3.105 - 3.106 - if (filename == null) 3.107 - { 3.108 - System.out.println (""); 3.109 - } 3.110 - return; 3.111 - } 3.112 - 3.113 - boolean 3.114 - parse_commandline (String[] commands) 3.115 - { 3.116 - if (commands.length == 0) 3.117 - { 3.118 - return false; 3.119 - } 3.120 - 3.121 - String keyword = commands[0].toLowerCase(); 3.122 - if (keyword.equals("file")) 3.123 - { 3.124 - if (commands.length < 2) 3.125 - { 3.126 - System.out.println ("file [filename]"); 3.127 - return false; 3.128 - } 3.129 - for (int i = 1; i < commands.length; i++) 3.130 - { 3.131 - System.out.println ("file " + commands[i]); 3.132 - parse_input(commands[i]); 3.133 - } 3.134 - } 3.135 - else if (keyword.equals("show")) 3.136 - { 3.137 - parse_show(commands); 3.138 - } 3.139 - else if (keyword.equals("addpartition")) 3.140 - { 3.141 - parse_addpartition(commands); 3.142 - } 3.143 - else if (keyword.equals("vdcreate")) 3.144 - { 3.145 - parse_vdcreate(commands); 3.146 - } 3.147 - else if (keyword.equals("vddelete")) 3.148 - { 3.149 - parse_vddelete(commands); 3.150 - } 3.151 - else if (keyword.equals("vdrefresh")) 3.152 - { 3.153 - parse_vdrefresh(commands); 3.154 - } 3.155 - else if (keyword.equals("vbdcreate")) 3.156 - { 3.157 - parse_vbdcreate(commands); 3.158 - } 3.159 - else if (keyword.equals("vbddelete")) 3.160 - { 3.161 - parse_vbddelete(commands); 3.162 - } 3.163 - else if (keyword.equals("vbdflush")) 3.164 - { 3.165 - vdm.flush_virtual_block_devices(); 3.166 - } 3.167 - else if (keyword.equals("load")) 3.168 - { 3.169 - if (commands.length < 2) 3.170 - { 3.171 - System.out.println ("load <filename>"); 3.172 - return false; 3.173 - } 3.174 - XML.load_state (pm, vdm, commands[1]); 3.175 - } 3.176 - else if (keyword.equals("save")) 3.177 - { 3.178 - if (commands.length < 2) 3.179 - { 3.180 - System.out.println ("save <filename>"); 3.181 - return false; 3.182 - } 3.183 - XML.dump_state (pm, vdm, commands[1]); 3.184 - } 3.185 - else if (keyword.equals("help") || 3.186 - keyword.equals("?")) 3.187 - { 3.188 - parse_help(); 3.189 - } 3.190 - else if (keyword.equals("exit") || 3.191 - keyword.equals("quit")) 3.192 - { 3.193 - return true; 3.194 - } 3.195 - else 3.196 - { 3.197 - System.out.println ("unknown command [" + commands[0] + "]. " + 3.198 - "try \"help\""); 3.199 - } 3.200 - return false; 3.201 - } 3.202 - 3.203 - void 3.204 - parse_vdcreate (String[] commands) 3.205 - { 3.206 - VirtualDisk vd; 3.207 - 3.208 - if (commands.length < 4) 3.209 - { 3.210 - System.out.println ("vdcreate name size expiry"); 3.211 - return; 3.212 - } 3.213 - 3.214 - vd = vdm.create_virtual_disk(commands[1], 3.215 - Library.parse_size(commands[2]) / default_sector_size, 3.216 - new Date()); 3.217 - 3.218 - System.out.println ("Virtual Disk created with key: " + vd.get_key()); 3.219 - } 3.220 - 3.221 - void 3.222 - parse_vddelete (String[] commands) 3.223 - { 3.224 - if (commands.length < 2) 3.225 - { 3.226 - System.out.println ("vddelete key"); 3.227 - return; 3.228 - } 3.229 - 3.230 - vdm.delete_virtual_disk(commands[1]); 3.231 - } 3.232 - 3.233 - void 3.234 - parse_vdrefresh (String[] commands) 3.235 - { 3.236 - if (commands.length < 3) 3.237 - { 3.238 - System.out.println ("vdrefresh key expiry"); 3.239 - return; 3.240 - } 3.241 - 3.242 - vdm.refresh_virtual_disk(commands[1], 3.243 - new Date()); 3.244 - } 3.245 - 3.246 - void 3.247 - parse_vbdcreate (String[] commands) 3.248 - { 3.249 - VirtualDisk vd; 3.250 - VirtualBlockDevice vbd; 3.251 - 3.252 - if (commands.length < 4) 3.253 - { 3.254 - System.out.println ("vbdcreate <key> <domain number> <vbd number>"); 3.255 - return; 3.256 - } 3.257 - 3.258 - if (commands[1].startsWith("sd") || 3.259 - commands[1].startsWith("hd")) 3.260 - { 3.261 - /* 3.262 - * this is a gross hack to allow you to create a virtual block 3.263 - * device that maps directly to a physical partition 3.264 - */ 3.265 - 3.266 - /* find the appropriate partition */ 3.267 - Partition partition = pm.get_partition(commands[1]); 3.268 - if (partition == null) 3.269 - { 3.270 - System.out.println ("vbdcreate error: couldn't find partition \"" + 3.271 - commands[1] + "\""); 3.272 - return; 3.273 - } 3.274 - 3.275 - /* create a virtual disk */ 3.276 - vd = new VirtualDisk("vbd:" + commands[1]); 3.277 - vd.add_new_partition(partition, partition.nr_sects); 3.278 - 3.279 - 3.280 - /* display result */ 3.281 - System.out.print("domain:" + commands[2] + " "); 3.282 - if (commands.length == 4) 3.283 - { 3.284 - System.out.print ("rw "); 3.285 - } 3.286 - else 3.287 - { 3.288 - System.out.print(commands[4] + " "); 3.289 - } 3.290 - System.out.print("segment:" + commands[3] + " "); 3.291 - System.out.print(vd.dump_xen()); 3.292 - System.out.println(""); 3.293 - 3.294 - return; 3.295 - } 3.296 - 3.297 - if (commands.length == 4) 3.298 - { 3.299 - vbd = 3.300 - vdm.create_virtual_block_device(commands[1], 3.301 - Integer.decode(commands[2]).intValue(), 3.302 - Integer.decode(commands[3]).intValue(), 3.303 - "rw"); 3.304 - } 3.305 - else 3.306 - { 3.307 - vbd = 3.308 - vdm.create_virtual_block_device(commands[1], 3.309 - Integer.decode(commands[2]).intValue(), 3.310 - Integer.decode(commands[3]).intValue(), 3.311 - commands[4]); 3.312 - } 3.313 - 3.314 - /* display commandline to user */ 3.315 - { 3.316 - vd = vdm.get_virtual_disk_key(commands[1]); 3.317 - System.out.println ("\n" + vd.dump_xen(vbd) + "\n"); 3.318 - } 3.319 - } 3.320 - 3.321 - void 3.322 - parse_vbddelete (String[] commands) 3.323 - { 3.324 - if (commands.length < 3) 3.325 - { 3.326 - System.out.println ("vbddelete <domain number> <vbd number>"); 3.327 - return; 3.328 - } 3.329 - 3.330 - vdm.delete_virtual_block_device(Integer.decode(commands[1]).intValue(), 3.331 - Integer.decode(commands[2]).intValue()); 3.332 - } 3.333 - 3.334 - static String show_helptxt = "show <partitions | free | vd [vd number] | vbd>"; 3.335 - void 3.336 - parse_show (String[] commands) 3.337 - { 3.338 - String subword; 3.339 - 3.340 - if (commands.length < 2) 3.341 - { 3.342 - System.out.println (show_helptxt); 3.343 - return; 3.344 - } 3.345 - 3.346 - subword = commands[1].toLowerCase(); 3.347 - if (subword.equals("partition") || 3.348 - subword.equals("partitions")) 3.349 - { 3.350 - System.out.println(pm.dump(true)); 3.351 - } 3.352 - else if (subword.equals("vd")) 3.353 - { 3.354 - String text; 3.355 - 3.356 - if (commands.length < 3) 3.357 - { 3.358 - System.out.println(vdm.dump_virtualdisks()); 3.359 - return; 3.360 - } 3.361 - text = vdm.dump_virtualdisk(Integer.decode(commands[2]).intValue()); 3.362 - if (text == null) 3.363 - { 3.364 - System.out.println("show vd error: invalid virtual disk number"); 3.365 - } 3.366 - else 3.367 - { 3.368 - System.out.println(text); 3.369 - } 3.370 - } 3.371 - else if (subword.equals("vbd")) 3.372 - { 3.373 - System.out.println(vdm.dump_virtualblockdevices()); 3.374 - } 3.375 - else if (subword.equals("free")) 3.376 - { 3.377 - System.out.println(vdm.dump_free()); 3.378 - } 3.379 - else 3.380 - { 3.381 - System.out.println (show_helptxt); 3.382 - return; 3.383 - } 3.384 - } 3.385 - 3.386 - void 3.387 - parse_addpartition(String[] commands) 3.388 - { 3.389 - String chunksize = default_addpartition_chunksize; 3.390 - 3.391 - if (commands.length > 3 || commands.length < 2) 3.392 - { 3.393 - System.out.println ("addpartition <partition number> [chunksize]"); 3.394 - return; 3.395 - } 3.396 - if (commands.length == 3) 3.397 - { 3.398 - chunksize = commands[2]; 3.399 - } 3.400 - 3.401 - System.out.println ("add partition " + commands[1] + " " + chunksize); 3.402 - 3.403 - vdm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1])), 3.404 - Library.parse_size(chunksize)/default_sector_size); 3.405 - pm.add_xeno_partition(pm.get_partition(Integer.parseInt(commands[1]))); 3.406 - } 3.407 - 3.408 - void 3.409 - parse_help() 3.410 - { 3.411 - System.out.println ("file <filename> " + 3.412 - "read the contents of a file as input to vdmanager"); 3.413 - System.out.println ("addpartition <partition number> [chunksize]"); 3.414 - System.out.println (" " + 3.415 - "add a partition as a xeno partition"); 3.416 - System.out.println ("vdcreate <name> <size> <expiry>"); 3.417 - System.out.println (" " + 3.418 - "create a new virtual disk"); 3.419 - System.out.println ("vddelete <key> " + 3.420 - "delete a virtual disk"); 3.421 - System.out.println ("vdrefresh <key> <expiry>"); 3.422 - System.out.println (" " + 3.423 - "reset virtual disk expiry"); 3.424 - System.out.println ("vbdcreate <key> <domain number> <vbd number> [rw|ro]"); 3.425 - System.out.println (" " + 3.426 - "create a new virtual block device"); 3.427 - System.out.println ("vbddelete <domain number> <vbd number>"); 3.428 - System.out.println (" " + 3.429 - "delete a new virtual block device"); 3.430 - System.out.println ("vbdflush " + 3.431 - "remove all virtual block devices"); 3.432 - System.out.println ("show partitions " + 3.433 - "display a complete list of disk partitions"); 3.434 - System.out.println ("show vd <vd number> " + 3.435 - "display virtual disk information"); 3.436 - System.out.println ("show vbd " + 3.437 - "display virtual virtual block device list"); 3.438 - System.out.println ("show free " + 3.439 - "display details about unallocated space"); 3.440 - System.out.println ("load <filename> " + 3.441 - "load new state from file"); 3.442 - System.out.println ("save <filename> " + 3.443 - "save state to file"); 3.444 - System.out.println ("help " + 3.445 - "display this help message"); 3.446 - System.out.println ("quit " + 3.447 - "exit"); 3.448 - } 3.449 -}