Revision 802ed2aa lib/daemon.py

b/lib/daemon.py
712 712
                          default=constants.SYSLOG_USAGE,
713 713
                          choices=["no", "yes", "only"])
714 714

  
715
  family = ssconf.SimpleStore().GetPrimaryIPFamily()
716
  # family will default to AF_INET if there is no ssconf file (e.g. when
717
  # upgrading a cluster from 2.2 -> 2.3. This is intended, as Ganeti clusters
718
  # <= 2.2 can not be AF_INET6
715 719
  if daemon_name in constants.DAEMONS_PORTS:
716 720
    default_bind_address = constants.IP4_ADDRESS_ANY
717
    family = ssconf.SimpleStore().GetPrimaryIPFamily()
718
    # family will default to AF_INET if there is no ssconf file (e.g. when
719
    # upgrading a cluster from 2.2 -> 2.3. This is intended, as Ganeti clusters
720
    # <= 2.2 can not be AF_INET6
721 721
    if family == netutils.IP6Address.family:
722 722
      default_bind_address = constants.IP6_ADDRESS_ANY
723 723

  
......
731 731
                            help=("Bind address (default: '%s')" %
732 732
                                  default_bind_address),
733 733
                            default=default_bind_address, metavar="ADDRESS")
734
    optionparser.add_option("-i", "--interface", dest="bind_interface",
735
                            help=("Bind interface"), metavar="INTERFACE")
734 736

  
735 737
  if default_ssl_key is not None and default_ssl_cert is not None:
736 738
    optionparser.add_option("--no-ssl", dest="ssl",
......
753 755

  
754 756
  options, args = optionparser.parse_args()
755 757

  
758
  if getattr(options, "bind_interface", None) is not None:
759
    if options.bind_address != default_bind_address:
760
      msg = ("Can't specify both, bind address (%s) and bind interface (%s)" %
761
             (options.bind_address, options.bind_interface))
762
      print >> sys.stderr, msg
763
      sys.exit(constants.EXIT_FAILURE)
764
    interface_ip_addresses = \
765
      netutils.GetInterfaceIpAddresses(options.bind_interface)
766
    if family == netutils.IP6Address.family:
767
      if_addresses = interface_ip_addresses[constants.IP6_VERSION]
768
    else:
769
      if_addresses = interface_ip_addresses[constants.IP4_VERSION]
770
    if len(if_addresses) < 1:
771
      msg = "Failed to find IP for interface %s" % options.bind_interace
772
      print >> sys.stderr, msg
773
      sys.exit(constants.EXIT_FAILURE)
774
    options.bind_address = if_addresses[0]
775

  
756 776
  if getattr(options, "ssl", False):
757 777
    ssl_paths = {
758 778
      "certificate": options.ssl_cert,

Also available in: Unified diff