Rename OpExportInstance and LUExportInstance
[ganeti-local] / lib / client / gnt_cluster.py
index 8714a21..6a6efeb 100644 (file)
@@ -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
@@ -87,6 +91,13 @@ def InitCluster(opts, args):
   nicparams = objects.FillDict(constants.NICC_DEFAULTS, nicparams)
   utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
 
+  # prepare ndparams dict
+  if opts.ndparams is None:
+    ndparams = dict(constants.NDC_DEFAULTS)
+  else:
+    ndparams = objects.FillDict(constants.NDC_DEFAULTS, opts.ndparams)
+    utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES)
+
   # prepare hvparams dict
   for hv in constants.HYPER_TYPES:
     if hv not in hvparams:
@@ -117,12 +128,13 @@ 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,
                         beparams=beparams,
                         nicparams=nicparams,
+                        ndparams=ndparams,
                         candidate_pool_size=opts.candidate_pool_size,
                         modify_etc_hosts=opts.modify_etc_hosts,
                         modify_ssh_setup=opts.modify_ssh_setup,
@@ -331,6 +343,9 @@ def ShowClusterConfig(opts, args):
   ToStdout("  - primary ip version: %d", result["primary_ip_version"])
   ToStdout("  - preallocation wipe disks: %s", result["prealloc_wipe_disks"])
 
+  ToStdout("Default node parameters:")
+  _PrintGroupedParams(result["ndparams"], roman=opts.roman_integers)
+
   ToStdout("Default instance parameters:")
   _PrintGroupedParams(result["beparams"], roman=opts.roman_integers)
 
@@ -706,7 +721,7 @@ def SetClusterParams(opts, args):
   if not (not opts.lvm_storage or opts.vg_name or
           not opts.drbd_storage or opts.drbd_helper or
           opts.enabled_hypervisors or opts.hvparams or
-          opts.beparams or opts.nicparams or
+          opts.beparams or opts.nicparams or opts.ndparams or
           opts.candidate_pool_size is not None or
           opts.uid_pool is not None or
           opts.maintain_node_health is not None or
@@ -714,6 +729,7 @@ def SetClusterParams(opts, args):
           opts.remove_uids is not None or
           opts.default_iallocator is not None or
           opts.reserved_lvs is not None or
+          opts.master_netdev is not None or
           opts.prealloc_wipe_disks is not None):
     ToStderr("Please give at least one of the parameters.")
     return 1
@@ -749,6 +765,9 @@ def SetClusterParams(opts, args):
   nicparams = opts.nicparams
   utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
 
+  ndparams = opts.ndparams
+  if ndparams is not None:
+    utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES)
 
   mnh = opts.maintain_node_health
 
@@ -777,6 +796,7 @@ def SetClusterParams(opts, args):
                                   os_hvp=None,
                                   beparams=beparams,
                                   nicparams=nicparams,
+                                  ndparams=ndparams,
                                   candidate_pool_size=opts.candidate_pool_size,
                                   maintain_node_health=mnh,
                                   uid_pool=uid_pool,
@@ -784,6 +804,7 @@ def SetClusterParams(opts, args):
                                   remove_uids=remove_uids,
                                   default_iallocator=opts.default_iallocator,
                                   prealloc_wipe_disks=opts.prealloc_wipe_disks,
+                                  master_netdev=opts.master_netdev,
                                   reserved_lvs=opts.reserved_lvs)
   SubmitOpCode(op, opts=opts)
   return 0
@@ -868,7 +889,8 @@ commands = {
      NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
      SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
      UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
-     DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT],
+     DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT,
+     NODE_PARAMS_OPT],
     "[opts...] <cluster_name>", "Initialises a new cluster configuration"),
   'destroy': (
     DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
@@ -940,11 +962,11 @@ commands = {
     "{pause <timespec>|continue|info}", "Change watcher properties"),
   'modify': (
     SetClusterParams, ARGS_NONE,
-    [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT,
+    [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, MASTER_NETDEV_OPT,
      NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
      UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT,
      NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT, RESERVED_LVS_OPT,
-     DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT],
+     DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT, NODE_PARAMS_OPT],
     "[opts...]",
     "Alters the parameters of the cluster"),
   "renew-crypto": (