From 61be6ba4f7b5cc8442261cbf7f8d33a5d0aa44a2 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 20 Oct 2008 12:16:38 +0000
Subject: [PATCH] Fix gnt-instance modify with beparams

The gnt-instance modify didn't work correctly w.r.t the be parameters.
There was also a typo in the corresponding LU.

Reviewed-by: imsnah
---
 lib/cmdlib.py        |  2 +-
 scripts/gnt-instance | 17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 458e5b79b..2ae2c97ea 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -4557,7 +4557,7 @@ class LUSetInstanceParams(LogicalUnit):
     if constants.BE_MEMORY in self.be_new:
       args['memory'] = self.be_new[constants.BE_MEMORY]
     if constants.BE_VCPUS in self.be_new:
-      args['vcpus'] = self.be_bnew[constants.BE_VCPUS]
+      args['vcpus'] = self.be_new[constants.BE_VCPUS]
     if self.do_ip or self.do_bridge or self.mac:
       if self.do_ip:
         ip = self.ip
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 61605d560..ffcbcf24f 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -899,11 +899,15 @@ def SetInstanceParams(opts, args):
     mac - the new MAC address of the instance
 
   """
-  if not (opts.mem or opts.vcpus or opts.ip or opts.bridge or opts.mac or
-          opts.hypervisor):
+  if not (opts.ip or opts.bridge or opts.mac or
+          opts.hypervisor or opts.beparams):
     logger.ToStdout("Please give at least one of the parameters.")
     return 1
 
+  if constants.BE_MEMORY in opts.beparams:
+    opts.beparams[constants.BE_MEMORY] = utils.ParseUnit(
+      opts.beparams[constants.BE_MEMORY])
+
   op = opcodes.OpSetInstanceParams(instance_name=args[0],
                                    ip=opts.ip,
                                    bridge=opts.bridge, mac=opts.mac,
@@ -1109,12 +1113,6 @@ commands = {
                     "Replaces all disks for the instance"),
   'modify': (SetInstanceParams, ARGS_ONE,
              [DEBUG_OPT, FORCE_OPT,
-              cli_option("-m", "--memory", dest="mem",
-                         help="Memory size",
-                         default=None, type="unit", metavar="<mem>"),
-              make_option("-p", "--cpu", dest="vcpus",
-                          help="Number of virtual CPUs",
-                          default=None, type="int", metavar="<PROC>"),
               make_option("-i", "--ip", dest="ip",
                           help="IP address ('none' or numeric IP)",
                           default=None, type="string", metavar="<ADDRESS>"),
@@ -1127,6 +1125,9 @@ commands = {
               keyval_option("-H", "--hypervisor", type="keyval",
                             default={}, dest="hypervisor",
                             help="Change hypervisor parameters"),
+              keyval_option("-B", "--backend", type="keyval",
+                            default={}, dest="beparams",
+                            help="Change backend parameters"),
               SUBMIT_OPT,
               ],
              "<instance>", "Alters the parameters of an instance"),
-- 
GitLab