blob: b1990dadb23a0a5a863615a028838c19fdadcfc7 (
plain)
| 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
66
67
68
69
70
71
72
73
74
75
76
77
 | name=$(: | dmenu-unlinked -p "Enter the name for the new qube:") &&
	label=$(printf 'Red\nOrange\nYellow\nGreen\nGray\nBlue\nPurple\nBlack' | dmenu-unlinked -i -l 8 -p "Select label for $name:" | awk '{print tolower($0)}')
	if [ -n "$label" ]; then
		QUBEARGS="-l $label"
		class=$(printf 'AppVM\nStandaloneVM\nTemplateVM' | dmenu-unlinked -i -l 4 -p "Choose a class for $name:")
		QUBEARGS="$QUBEARGS -C $class"
		get_list template
		if [ "$class" = 'AppVM' ]; then
		
			template=$(printf "(Default)\n$list" | dmenu-unlinked -l 50 -p "Select template for $name:")
			[ "$template" = '(Default)' ] && unset template
		else
			template=$(printf "(None)\n$list" | dmenu-unlinked -l 50 -p "Select template that $name will be copied from:")
			[ "$template" = '(None)' ] && unset template
		fi
		[ -n "$template" ] && QUBEARGS="$QUBEARGS -t $template"
		get_list netvm
		netvm=$(printf "(Default)\n(None)\n$list" | dmenu-unlinked -l 50 -p "Select netvm for $name:")
		if [ "$netvm" = '(Default)' ]; then netvm=--default
		elif [ "$netvm" = '(None)' ]; then unset netvm
		fi
		QUBEARGS="$QUBEARGS --prop netvm=$netvm"
		provides_network=$(printf 'No\nYes' | dmenu-unlinked -i -p "Should $name provide networking for other qubes?")
		if [ "$provides_network" = Yes ]; then
			QUBEARGS="$QUBEARGS --prop provides_network=true"
		fi
		option=1
		while [ -n "$option" ]; do
			option=$(printf 'Create the new qube\nAdvanced options' | dmenu-unlinked -i -l 2 -p "dom0:" | cut -f1 -d\ )
			if [ "$option" = Advanced ]; then
				option_adv=$(printf Pool | dmenu-unlinked -l 1 -p "$name:")
				if [ "$option_adv" = Pool ]; then
					pool=$(qvm-pool --list | sed '1d' | dmenu-unlinked -i -l 10 -p "Select a pool for $name:" | cut -f1 -d\ )
					[ -n "$pool" ] && pool="-P $pool"
				fi
			elif [ "$option" = Create ]; then
				qvm-create $QUBEARGS $pool "$name"
				if [ "$class" = 'StandaloneVM' ] && [ -z "$template" ]; then
					qvm-prefs "$name" kernel ''
					qvm-prefs "$name" virt_mode hvm
					qvm-prefs "$name" maxmem 0
				fi
				unset option
			fi
		done
	fi
 |