From 25be0c756d404fd0c5891e272962d12914dfceb9 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 12 Jan 2011 11:33:39 +0000
Subject: [PATCH] Remove --master-netdev default value

Since the --master-netdev option is now used both at cluster init and at
cluster modify time, it cannot have a default value of DEFAULT_BRIDGE
(xen-br0) anymore. As such at cluster init we make the initialization
explicit if another value hasn't been passed. This fixes gnt-cluster
modify changing the master_netdev to xen-br0 if called without that
argument.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cli.py                | 7 ++++---
 lib/client/gnt_cluster.py | 6 +++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/cli.py b/lib/cli.py
index 8e577409f..e2e1e313f 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -947,10 +947,11 @@ MAC_PREFIX_OPT = cli_option("-m", "--mac-prefix", dest="mac_prefix",
 
 MASTER_NETDEV_OPT = cli_option("--master-netdev", dest="master_netdev",
                                help="Specify the node interface (cluster-wide)"
-                               " on which the master IP address will be added "
-                               " [%s]" % constants.DEFAULT_BRIDGE,
+                               " on which the master IP address will be added"
+                               " (cluster init default: %s)" %
+                               constants.DEFAULT_BRIDGE,
                                metavar="NETDEV",
-                               default=constants.DEFAULT_BRIDGE)
+                               default=None)
 
 GLOBAL_FILEDIR_OPT = cli_option("--file-storage-dir", dest="file_storage_dir",
                                 help="Specify the default directory (cluster-"
diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index 7476a00fb..91dafaba7 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -70,6 +70,10 @@ def InitCluster(opts, args):
   if opts.drbd_storage and not opts.drbd_helper:
     drbd_helper = constants.DEFAULT_DRBD_HELPER
 
+  master_netdev = opts.master_netdev
+  if master_netdev is None:
+    master_netdev = constants.DEFAULT_BRIDGE
+
   hvlist = opts.enabled_hypervisors
   if hvlist is None:
     hvlist = constants.DEFAULT_ENABLED_HYPERVISOR
@@ -124,7 +128,7 @@ def InitCluster(opts, args):
                         secondary_ip=opts.secondary_ip,
                         vg_name=vg_name,
                         mac_prefix=opts.mac_prefix,
-                        master_netdev=opts.master_netdev,
+                        master_netdev=master_netdev,
                         file_storage_dir=opts.file_storage_dir,
                         enabled_hypervisors=hvlist,
                         hvparams=hvparams,
-- 
GitLab