1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package org.xenoserver.cmdline;
import java.util.LinkedList;
import org.xenoserver.control.CommandFailedException;
import org.xenoserver.control.CommandVbdCreate;
import org.xenoserver.control.CommandVbdCreatePhysical;
import org.xenoserver.control.Defaults;
import org.xenoserver.control.Mode;
public class ParseVbdCreate extends CommandParser {
public void parse(Defaults d, LinkedList args)
throws ParseFailedException, CommandFailedException {
String vd_key = getStringParameter(args, 'k', "");
String partition_name = getStringParameter(args, 'p', "");
int domain_id = getIntParameter(args, 'n', d.domainNumber);
int vbd_num = getIntParameter(args, 'v', -1);
boolean write = getFlagParameter(args, 'w');
if (vd_key.equals("") && partition_name.equals("")) {
throw new ParseFailedException("Expected -k<key> or -p<partition>");
}
if (domain_id == 0) {
throw new ParseFailedException("Expected -n<domain_id>");
}
if (vbd_num == -1) {
throw new ParseFailedException("Expected -v<vbd_num>");
}
Mode mode;
if (write) {
mode = Mode.READ_WRITE;
} else {
mode = Mode.READ_ONLY;
}
loadState();
String output;
if (vd_key.equals("")) {
output = new CommandVbdCreatePhysical(d, partition_name, domain_id, vbd_num, mode ).execute();
} else {
output =
new CommandVbdCreate(vd_key, domain_id, vbd_num, mode).execute();
}
if (output != null) {
System.out.println(output);
}
saveState();
}
public String getName() {
return "create";
}
public String getUsage() {
return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w]";
}
public String getHelpText() {
return "Create a new virtual block device binding the virtual disk with\n"
+ "the specified key to the domain and VBD number given. Add -w to\n"
+ "allow read-write access.";
}
}
|