Revision 60d49723
b/lib/cli.py | ||
---|---|---|
43 | 43 |
"ARGS_NONE", "ARGS_FIXED", "ARGS_ATLEAST", "ARGS_ANY", "ARGS_ONE", |
44 | 44 |
"USEUNITS_OPT", "FIELDS_OPT", "FORCE_OPT", |
45 | 45 |
"ListTags", "AddTags", "RemoveTags", "TAG_SRC_OPT", |
46 |
"FormatError", |
|
46 |
"FormatError", "SplitNodeOption"
|
|
47 | 47 |
] |
48 | 48 |
|
49 | 49 |
|
... | ... | |
179 | 179 |
TAG_SRC_OPT = make_option("--from", dest="tags_source", |
180 | 180 |
default=None, help="File with tag names") |
181 | 181 |
|
182 |
|
|
182 | 183 |
def ARGS_FIXED(val): |
183 | 184 |
"""Macro-like function denoting a fixed number of arguments""" |
184 | 185 |
return -val |
... | ... | |
286 | 287 |
return func, options, args |
287 | 288 |
|
288 | 289 |
|
290 |
def SplitNodeOption(value): |
|
291 |
"""Splits the value of a --node option. |
|
292 |
|
|
293 |
""" |
|
294 |
if value and ':' in value: |
|
295 |
return value.split(':', 1) |
|
296 |
else: |
|
297 |
return (value, None) |
|
298 |
|
|
299 |
|
|
289 | 300 |
def AskUser(text, choices=None): |
290 | 301 |
"""Ask the user a question. |
291 | 302 |
|
b/scripts/gnt-backup | ||
---|---|---|
64 | 64 |
|
65 | 65 |
SubmitOpCode(op) |
66 | 66 |
|
67 |
|
|
67 | 68 |
def ImportInstance(opts, args): |
68 | 69 |
"""Add an instance to the cluster. |
69 | 70 |
|
... | ... | |
84 | 85 |
""" |
85 | 86 |
instance = args[0] |
86 | 87 |
|
88 |
(pnode, snode) = SplitNodeOption(opts.node) |
|
89 |
|
|
87 | 90 |
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem, |
88 | 91 |
disk_size=opts.size, swap_size=opts.swap, |
89 | 92 |
disk_template=opts.disk_template, |
90 | 93 |
mode=constants.INSTANCE_IMPORT, |
91 |
pnode=opts.node, snode=opts.snode,
|
|
94 |
pnode=pnode, snode=snode,
|
|
92 | 95 |
vcpus=opts.vcpus, ip_check=opts.ip_check, |
93 | 96 |
ip=opts.ip, bridge=opts.bridge, start=False, |
94 | 97 |
src_node=opts.src_node, src_path=opts.src_dir, |
... | ... | |
97 | 100 |
return 0 |
98 | 101 |
|
99 | 102 |
|
100 |
# options used in more than one cmd |
|
101 |
node_opt = make_option("-n", "--node", dest="node", help="Target node", |
|
102 |
metavar="<node>") |
|
103 |
|
|
104 | 103 |
# this is defined separately due to readability only |
105 | 104 |
import_opts = [ |
106 | 105 |
DEBUG_OPT, |
107 |
node_opt, |
|
106 |
make_option("-n", "--node", dest="node", |
|
107 |
help="Target node and optional secondary node", |
|
108 |
metavar="<pnode>[:<snode>]"), |
|
108 | 109 |
cli_option("-s", "--os-size", dest="size", help="Disk size", |
109 | 110 |
default=20 * 1024, type="unit", metavar="<size>"), |
110 | 111 |
cli_option("--swap-size", dest="swap", help="Swap size", |
... | ... | |
121 | 122 |
default='none', type="string", metavar="<ADDRESS>"), |
122 | 123 |
make_option("--no-wait-for-sync", dest="wait_for_sync", default=True, |
123 | 124 |
action="store_false", help="Don't wait for sync (DANGEROUS!)"), |
124 |
make_option("--secondary-node", dest="snode", |
|
125 |
help="Secondary node for remote_raid1 disk layout", |
|
126 |
metavar="<node>"), |
|
127 | 125 |
make_option("-b", "--bridge", dest="bridge", |
128 | 126 |
help="Bridge to connect this instance to", |
129 | 127 |
default=None, metavar="<bridge>"), |
... | ... | |
144 | 142 |
], |
145 | 143 |
"", "Lists instance exports available in the ganeti cluster"), |
146 | 144 |
'export': (ExportInstance, ARGS_ONE, |
147 |
[node_opt, DEBUG_OPT, FORCE_OPT, |
|
145 |
[DEBUG_OPT, FORCE_OPT, |
|
146 |
make_option("-n", "--node", dest="node", help="Target node", |
|
147 |
metavar="<node>"), |
|
148 | 148 |
make_option("","--noshutdown", dest="shutdown", |
149 | 149 |
action="store_false", default=True, |
150 | 150 |
help="Don't shutdown the instance (unsafe)"), ], |
b/scripts/gnt-instance | ||
---|---|---|
216 | 216 |
""" |
217 | 217 |
instance = args[0] |
218 | 218 |
|
219 |
(pnode, snode) = SplitNodeOption(opts.node) |
|
220 |
|
|
219 | 221 |
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem, |
220 | 222 |
disk_size=opts.size, swap_size=opts.swap, |
221 | 223 |
disk_template=opts.disk_template, |
222 | 224 |
mode=constants.INSTANCE_CREATE, |
223 |
os_type=opts.os, pnode=opts.node,
|
|
224 |
snode=opts.snode, vcpus=opts.vcpus,
|
|
225 |
os_type=opts.os, pnode=pnode,
|
|
226 |
snode=snode, vcpus=opts.vcpus, |
|
225 | 227 |
ip=opts.ip, bridge=opts.bridge, |
226 | 228 |
start=opts.start, ip_check=opts.ip_check, |
227 | 229 |
wait_for_sync=opts.wait_for_sync) |
... | ... | |
674 | 676 |
# this is defined separately due to readability only |
675 | 677 |
add_opts = [ |
676 | 678 |
DEBUG_OPT, |
677 |
node_opt, |
|
679 |
make_option("-n", "--node", dest="node", |
|
680 |
help="Target node and optional secondary node", |
|
681 |
metavar="<pnode>[:<snode>]"), |
|
678 | 682 |
cli_option("-s", "--os-size", dest="size", help="Disk size, in MiB unless" |
679 | 683 |
" a suffix is used", |
680 | 684 |
default=20 * 1024, type="unit", metavar="<size>"), |
... | ... | |
694 | 698 |
default='none', type="string", metavar="<ADDRESS>"), |
695 | 699 |
make_option("--no-wait-for-sync", dest="wait_for_sync", default=True, |
696 | 700 |
action="store_false", help="Don't wait for sync (DANGEROUS!)"), |
697 |
make_option("--secondary-node", dest="snode", |
|
698 |
help="Secondary node for remote_raid1 disk layout", |
|
699 |
metavar="<node>"), |
|
700 | 701 |
make_option("-b", "--bridge", dest="bridge", |
701 | 702 |
help="Bridge to connect this instance to", |
702 | 703 |
default=None, metavar="<bridge>"), |
Also available in: Unified diff