Revision eb630f50 lib/backend.py

b/lib/backend.py
2617 2617
                                  (prefix, utils.TimestampForFilename())))
2618 2618

  
2619 2619

  
2620
def StartImportExportDaemon(mode, key_name, ca, host, port, instance,
2621
                            ieio, ieioargs):
2620
def StartImportExportDaemon(mode, opts, host, port, instance, ieio, ieioargs):
2622 2621
  """Starts an import or export daemon.
2623 2622

  
2624 2623
  @param mode: Import/output mode
2625
  @type key_name: string
2626
  @param key_name: RSA key name (None to use cluster certificate)
2627
  @type ca: string:
2628
  @param ca: Remote CA in PEM format (None to use cluster certificate)
2624
  @type opts: L{objects.ImportExportOptions}
2625
  @param opts: Daemon options
2629 2626
  @type host: string
2630 2627
  @param host: Remote host for export (None for import)
2631 2628
  @type port: int
......
2651 2648
  else:
2652 2649
    _Fail("Invalid mode %r", mode)
2653 2650

  
2654
  if (key_name is None) ^ (ca is None):
2651
  if (opts.key_name is None) ^ (opts.ca_pem is None):
2655 2652
    _Fail("Cluster certificate can only be used for both key and CA")
2656 2653

  
2657 2654
  (cmd_env, cmd_prefix, cmd_suffix) = \
2658 2655
    _GetImportExportIoCommand(instance, mode, ieio, ieioargs)
2659 2656

  
2660
  if key_name is None:
2657
  if opts.key_name is None:
2661 2658
    # Use server.pem
2662 2659
    key_path = constants.NODED_CERT_FILE
2663 2660
    cert_path = constants.NODED_CERT_FILE
2664
    assert ca is None
2661
    assert opts.ca_pem is None
2665 2662
  else:
2666 2663
    (_, key_path, cert_path) = _GetX509Filenames(constants.CRYPTO_KEYS_DIR,
2667
                                                 key_name)
2668
    assert ca is not None
2664
                                                 opts.key_name)
2665
    assert opts.ca_pem is not None
2669 2666

  
2670 2667
  for i in [key_path, cert_path]:
2671 2668
    if not os.path.exists(i):
......
2677 2674
    pid_file = utils.PathJoin(status_dir, _IES_PID_FILE)
2678 2675
    ca_file = utils.PathJoin(status_dir, _IES_CA_FILE)
2679 2676

  
2680
    if ca is None:
2677
    if opts.ca_pem is None:
2681 2678
      # Use server.pem
2682 2679
      ca = utils.ReadFile(constants.NODED_CERT_FILE)
2680
    else:
2681
      ca = opts.ca_pem
2683 2682

  
2683
    # Write CA file
2684 2684
    utils.WriteFile(ca_file, data=ca, mode=0400)
2685 2685

  
2686 2686
    cmd = [

Also available in: Unified diff