Revision e7323b5e

b/lib/backend.py
287 287
        logging.error(msg)
288 288
        err_msgs.append(msg)
289 289
    else:
290
      result = utils.RunCmd(["ip", "address", "add", "%s/32" % master_ip,
290
      netmask = 32
291
      if netutils.IP6Address.IsValid(master_ip):
292
        netmask = 128
293

  
294
      result = utils.RunCmd(["ip", "address", "add",
295
                             "%s/%d" % (master_ip, netmask),
291 296
                             "dev", master_netdev, "label",
292 297
                             "%s:0" % master_netdev])
293 298
      if result.failed:
......
295 300
        logging.error(msg)
296 301
        err_msgs.append(msg)
297 302

  
298
      result = utils.RunCmd(["arping", "-q", "-U", "-c 3", "-I", master_netdev,
299
                             "-s", master_ip, master_ip])
300
      # we'll ignore the exit code of arping
303
      # we ignore the exit code of the following cmds
304
      if netutils.IP4Address.IsValid(master_ip):
305
        utils.RunCmd(["arping", "-q", "-U", "-c 3", "-I", master_netdev, "-s",
306
                      master_ip, master_ip])
307
      elif netutils.IP6Address.IsValid(master_ip):
308
        utils.RunCmd(["ndisc6", "-q", "-r 3", master_ip, master_netdev])
301 309

  
302 310
  if err_msgs:
303 311
    _Fail("; ".join(err_msgs))
......
322 330
  # GetMasterInfo will raise an exception if not able to return data
323 331
  master_netdev, master_ip, _ = GetMasterInfo()
324 332

  
325
  result = utils.RunCmd(["ip", "address", "del", "%s/32" % master_ip,
333
  netmask = 32
334
  if netutils.IP6Address.IsValid(master_ip):
335
    netmask = 128
336

  
337
  result = utils.RunCmd(["ip", "address", "del",
338
                         "%s/%d" % (master_ip, netmask),
326 339
                         "dev", master_netdev])
327 340
  if result.failed:
328 341
    logging.error("Can't remove the master IP, error: %s", result.output)
b/lib/cli.py
119 119
  "OSPARAMS_OPT",
120 120
  "OS_OPT",
121 121
  "OS_SIZE_OPT",
122
  "PRIMARY_IP_VERSION_OPT",
122 123
  "RAPI_CERT_OPT",
123 124
  "READD_OPT",
124 125
  "REBOOT_TYPE_OPT",
......
1021 1022
                                action="store_false", default=True,
1022 1023
                                help="Disable support for DRBD")
1023 1024

  
1025
PRIMARY_IP_VERSION_OPT = \
1026
    cli_option("--primary-ip-version", default=constants.IP4_VERSION,
1027
               action="store", dest="primary_ip_version",
1028
               metavar="%d|%d" % (constants.IP4_VERSION,
1029
                                  constants.IP6_VERSION),
1030
               help="Cluster-wide IP version for primary IP")
1031

  
1024 1032

  
1025 1033
def _ParseArgs(argv, commands, aliases):
1026 1034
  """Parser for the command line arguments.
b/lib/cmdlib.py
2527 2527
    """Verify that the passed name is a valid one.
2528 2528

  
2529 2529
    """
2530
    hostname = netutils.GetHostname(name=self.op.name)
2530
    hostname = netutils.GetHostname(name=self.op.name,
2531
                                    family=self.cfg.GetPrimaryIPFamily())
2531 2532

  
2532 2533
    new_name = hostname.name
2533 2534
    self.ip = new_ip = hostname.ip
......
4117 4118
        if hv_name in cluster.enabled_hypervisors:
4118 4119
          os_hvp[os_name][hv_name] = hv_params
4119 4120

  
4121
    # Convert ip_family to ip_version
4122
    primary_ip_version = constants.IP4_VERSION
4123
    if cluster.primary_ip_family == netutils.IP6Address.family:
4124
      primary_ip_version = constants.IP6_VERSION
4125

  
4120 4126
    result = {
4121 4127
      "software_version": constants.RELEASE_VERSION,
4122 4128
      "protocol_version": constants.PROTOCOL_VERSION,
......
4147 4153
      "uid_pool": cluster.uid_pool,
4148 4154
      "default_iallocator": cluster.default_iallocator,
4149 4155
      "reserved_lvs": cluster.reserved_lvs,
4156
      "primary_ip_version": primary_ip_version,
4150 4157
      }
4151 4158

  
4152 4159
    return result
b/lib/daemon.py
40 40
from ganeti import constants
41 41
from ganeti import errors
42 42
from ganeti import netutils
43
from ganeti import ssconf
43 44

  
44 45

  
45 46
_DEFAULT_RUN_USER = "root"
......
542 543

  
543 544
  if daemon_name in constants.DAEMONS_PORTS:
544 545
    default_bind_address = constants.IP4_ADDRESS_ANY
546
    try:
547
      family = ssconf.SimpleStore().GetPrimaryIPFamily()
548
      if family == netutils.IP6Address.family:
549
        default_bind_address = constants.IP6_ADDRESS_ANY
550
    except errors.ConfigurationError:
551
      # This case occurs when adding a node, as there is no ssconf available
552
      # when noded is first started. In that case, however, the correct
553
      # bind_address must be passed
554
      pass
555

  
545 556
    default_port = netutils.GetDaemonPort(daemon_name)
546 557

  
547 558
    # For networked daemons we allow choosing the port and bind address
......
549 560
                            help="Network port (default: %s)" % default_port,
550 561
                            default=default_port, type="int")
551 562
    optionparser.add_option("-b", "--bind", dest="bind_address",
552
                            help=("Bind address (default: %s)" %
563
                            help=("Bind address (default: '%s')" %
553 564
                                  default_bind_address),
554 565
                            default=default_bind_address, metavar="ADDRESS")
555 566

  
b/scripts/gnt-cluster
105 105
  if uid_pool is not None:
106 106
    uid_pool = uidpool.ParseUidPool(uid_pool)
107 107

  
108
  try:
109
    primary_ip_version = int(opts.primary_ip_version)
110
  except (ValueError, TypeError), err:
111
    ToStderr("Invalid primary ip version value: %s" % str(err))
112
    return 1
113

  
108 114
  bootstrap.InitCluster(cluster_name=args[0],
109 115
                        secondary_ip=opts.secondary_ip,
110 116
                        vg_name=vg_name,
......
122 128
                        drbd_helper=drbd_helper,
123 129
                        uid_pool=uid_pool,
124 130
                        default_iallocator=opts.default_iallocator,
125
                        primary_ip_version=constants.IP4_VERSION,
131
                        primary_ip_version=primary_ip_version,
126 132
                        )
127 133
  op = opcodes.OpPostInitCluster()
128 134
  SubmitOpCode(op, opts=opts)
......
318 324
            uidpool.FormatUidPool(result["uid_pool"],
319 325
                                  roman=opts.roman_integers))
320 326
  ToStdout("  - default instance allocator: %s", result["default_iallocator"])
327
  ToStdout("  - primary ip version: %d", result["primary_ip_version"])
321 328

  
322 329
  ToStdout("Default instance parameters:")
323 330
  _PrintGroupedParams(result["beparams"], roman=opts.roman_integers)
......
849 856
     NOLVM_STORAGE_OPT, NOMODIFY_ETCHOSTS_OPT, NOMODIFY_SSH_SETUP_OPT,
850 857
     SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
851 858
     UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
852
     DEFAULT_IALLOCATOR_OPT],
859
     DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT],
853 860
    "[opts...] <cluster_name>", "Initialises a new cluster configuration"),
854 861
  'destroy': (
855 862
    DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],

Also available in: Unified diff