Commit c0e4a2c3 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement the backward-compatible ‘-s’ disk option

This patch adds back to the instance creation command (gnt-instace add,
gnt-backup import) the ‘-s’ short form option for specifying a
single-disk instance.

Also a small bug in gnt-backup import is fixed.

Reviewed-by: ultrotter
parent d8dcf3c9
......@@ -151,10 +151,19 @@
</para>
<para>
The minimum disk specification is therefore <userinput>--disk
0:size=20G</userinput>, and a three-disk instance can be
specified as <userinput>--disk 0:size=20G --disk 1:size=4G
--disk 2:size=100G</userinput>.
Alternatively, a single-disk instance can be created via the
<option>-s</option> option which takes a single argument,
the size of the disk. This is similar to the Ganeti 1.2
version (but will only create one disk).
</para>
<para>
The minimum disk specification is therefore
<userinput>--disk 0:size=20G</userinput> (or <userinput>-s
20G</userinput> when using the <option>-s</option> option),
and a three-disk instance can be specified as
<userinput>--disk 0:size=20G --disk 1:size=4G --disk
2:size=100G</userinput>.
</para>
<para>
......
......@@ -65,7 +65,18 @@
<cmdsynopsis>
<command>add</command>
<sbr>
<arg rep="repeat">--disk=<replaceable>N</replaceable>:size=<replaceable>VAL</replaceable><arg>,mode=<replaceable>ro|rw</replaceable></arg></arg>
<arg choice="req">-t<group choice="req">
<arg>diskless</arg>
<arg>file</arg>
<arg>plain</arg>
<arg>drbd</arg>
</group></arg>
<sbr>
<group choice="req">
<arg rep="repeat">--disk=<replaceable>N</replaceable>:size=<replaceable>VAL</replaceable><arg>,mode=<replaceable>ro|rw</replaceable></arg></arg>
<arg>-s <replaceable>SIZE</replaceable></arg>
</group>
<sbr>
<group>
<arg rep="repeat">--net=<replaceable>N</replaceable><arg rep="repeat">:options</arg></arg>
......@@ -85,14 +96,6 @@
</group></arg>
<sbr>
<arg choice="req">-t<group choice="req">
<arg>diskless</arg>
<arg>file</arg>
<arg>plain</arg>
<arg>drbd</arg>
</group></arg>
<sbr>
<group choice="req">
<arg>-n <replaceable>node<optional>:secondary-node</optional></replaceable></arg>
<arg>--iallocator <replaceable>name</replaceable></arg>
......@@ -127,11 +130,20 @@
these suffixes map to mebibytes, gibibytes and tebibytes.
</para>
<para>
Alternatively, a single-disk instance can be created via the
<option>-s</option> option which takes a single argument,
the size of the disk. This is similar to the Ganeti 1.2
version (but will only create one disk).
</para>
<para>
The minimum disk specification is therefore
<userinput>--disk 0:size=20G</userinput>, and a three-disk
instance can be specified as <userinput>--disk 0:size=20G
--disk 1:size=4G --disk 2:size=100G</userinput>.
<userinput>--disk 0:size=20G</userinput> (or <userinput>-s
20G</userinput> when using the <option>-s</option> option),
and a three-disk instance can be specified as
<userinput>--disk 0:size=20G --disk 1:size=4G --disk
2:size=100G</userinput>.
</para>
<para>
......
......@@ -113,13 +113,18 @@ def ImportInstance(opts, args):
nics = [{}]
if opts.disk_template == constants.DT_DISKLESS:
if opts.disks:
if opts.disks or opts.sd_size is not None:
raise errors.OpPrereqError("Diskless instance but disk"
" information passed")
disks = []
else:
if not opts.disks:
if not opts.disks and not opts.sd_size:
raise errors.OpPrereqError("No disk information specified")
if opts.disks and opts.sd_size is not None:
raise errors.OpPrereqError("Please use either the '--disk' or"
" '-s' option")
if opts.sd_size is not None:
opts.disks = [(0, {"size": opts.sd_size})]
try:
disk_max = max(int(didx[0])+1 for didx in opts.disks)
except ValueError, err:
......@@ -137,7 +142,7 @@ def ImportInstance(opts, args):
disks[didx] = ddict
utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES)
utils.ForceDictType(opts.hvparams, constants.HVS_PARAMETER_TYPES)
utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES)
op = opcodes.OpCreateInstance(instance_name=instance,
disk_template=opts.disk_template,
......@@ -194,6 +199,10 @@ import_opts = [
default=[], dest="disks",
action="append",
type="identkeyval"),
cli_option("-s", "--os-size", dest="sd_size", help="Disk size for a"
" single-disk configuration, when not using the --disk option,"
" in MiB unless a suffix is used",
default=None, type="unit", metavar="<size>"),
ikv_option("--net", help="NIC information",
default=[], dest="nics",
action="append",
......
......@@ -332,13 +332,18 @@ def AddInstance(opts, args):
nics = [{}]
if opts.disk_template == constants.DT_DISKLESS:
if opts.disks:
if opts.disks or opts.sd_size is not None:
raise errors.OpPrereqError("Diskless instance but disk"
" information passed")
disks = []
else:
if not opts.disks:
if not opts.disks and not opts.sd_size:
raise errors.OpPrereqError("No disk information specified")
if opts.disks and opts.sd_size is not None:
raise errors.OpPrereqError("Please use either the '--disk' or"
" '-s' option")
if opts.sd_size is not None:
opts.disks = [(0, {"size": opts.sd_size})]
try:
disk_max = max(int(didx[0])+1 for didx in opts.disks)
except ValueError, err:
......@@ -1276,6 +1281,10 @@ add_opts = [
make_option("-t", "--disk-template", dest="disk_template",
help="Custom disk setup (diskless, file, plain or drbd)",
default=None, metavar="TEMPL"),
cli_option("-s", "--os-size", dest="sd_size", help="Disk size for a"
" single-disk configuration, when not using the --disk option,"
" in MiB unless a suffix is used",
default=None, type="unit", metavar="<size>"),
ikv_option("--disk", help="Disk information",
default=[], dest="disks",
action="append",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment