commit c0e4a2c3d28e2a7d534d36d4b57c0e8481712b73
Author: Iustin Pop <iustin@google.com>
Date:   Fri Feb 13 15:34:48 2009 +0000

    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

diff --git a/man/gnt-backup.sgml b/man/gnt-backup.sgml
index fec4091..da01af2 100644
--- a/man/gnt-backup.sgml
+++ b/man/gnt-backup.sgml
@@ -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>
diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml
index c6c511c..d50fb65 100644
--- a/man/gnt-instance.sgml
+++ b/man/gnt-instance.sgml
@@ -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>
@@ -128,10 +131,19 @@
         </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>
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index 774e696..c6ef4c9 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -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",
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index a5c30c8..fd8a455 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -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",
