Revision 1c65840b

b/daemons/ganeti-noded
407 407
    """Promote this node to master status.
408 408

  
409 409
    """
410
    return backend.StartMaster()
410
    return backend.StartMaster(params[0])
411 411

  
412 412
  @staticmethod
413 413
  def perspective_node_stop_master(params):
414 414
    """Demote this node from master status.
415 415

  
416 416
    """
417
    return backend.StopMaster()
417
    return backend.StopMaster(params[0])
418 418

  
419 419
  @staticmethod
420 420
  def perspective_node_leave_cluster(params):
b/lib/backend.py
47 47
  return ssh.SshRunner()
48 48

  
49 49

  
50
def StartMaster():
50
def StartMaster(start_daemons):
51 51
  """Activate local node as master node.
52 52

  
53
  There are two needed steps for this:
54
    - run the master script
55
    - register the cron script
53
  The function will always try activate the IP address of the master
54
  (if someone else has it, then it won't). Then, if the start_daemons
55
  parameter is True, it will also start the master daemons
56
  (ganet-masterd and ganeti-rapi).
56 57

  
57 58
  """
58 59
  result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "start"])
......
65 66
  return True
66 67

  
67 68

  
68
def StopMaster():
69
def StopMaster(stop_daemons):
69 70
  """Deactivate this node as master.
70 71

  
71
  This runs the master stop script.
72
  The function will always try to deactivate the IP address of the
73
  master. Then, if the stop_daemons parameter is True, it will also
74
  stop the master daemons (ganet-masterd and ganeti-rapi).
72 75

  
73 76
  """
74 77
  result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "stop"])
b/lib/cmdlib.py
416 416

  
417 417
    """
418 418
    master = self.sstore.GetMasterNode()
419
    if not rpc.call_node_stop_master(master):
419
    if not rpc.call_node_stop_master(master, False):
420 420
      raise errors.OpExecError("Could not disable the master role")
421 421
    priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS)
422 422
    utils.CreateBackup(priv_key)
......
962 962

  
963 963
    # shutdown the master IP
964 964
    master = ss.GetMasterNode()
965
    if not rpc.call_node_stop_master(master):
965
    if not rpc.call_node_stop_master(master, False):
966 966
      raise errors.OpExecError("Could not disable the master role")
967 967

  
968 968
    try:
......
985 985
            logger.Error("copy of file %s to node %s failed" %
986 986
                         (fname, to_node))
987 987
    finally:
988
      if not rpc.call_node_start_master(master):
988
      if not rpc.call_node_start_master(master, False):
989 989
        logger.Error("Could not re-enable the master role on the master,"
990 990
                     " please restart manually.")
991 991

  
......
1737 1737
    logger.Info("setting master to %s, old master: %s" %
1738 1738
                (self.new_master, self.old_master))
1739 1739

  
1740
    if not rpc.call_node_stop_master(self.old_master):
1740
    if not rpc.call_node_stop_master(self.old_master, True):
1741 1741
      logger.Error("could disable the master role on the old master"
1742 1742
                   " %s, please disable manually" % self.old_master)
1743 1743

  
......
1748 1748
      logger.Error("could not distribute the new simple store master file"
1749 1749
                   " to the other nodes, please check.")
1750 1750

  
1751
    if not rpc.call_node_start_master(self.new_master):
1751
    if not rpc.call_node_start_master(self.new_master, True):
1752 1752
      logger.Error("could not start the master role on the new master"
1753 1753
                   " %s, please check" % self.new_master)
1754 1754
      feedback_fn("Error in activating the master IP on the new master,"
b/lib/rpc.py
362 362
  return c.getresult()
363 363

  
364 364

  
365
def call_node_start_master(node):
365
def call_node_start_master(node, start_daemons):
366 366
  """Tells a node to activate itself as a master.
367 367

  
368 368
  This is a single-node call.
369 369

  
370 370
  """
371
  c = Client("node_start_master", [])
371
  c = Client("node_start_master", [start_daemons])
372 372
  c.connect(node)
373 373
  c.run()
374 374
  return c.getresult().get(node, False)
375 375

  
376 376

  
377
def call_node_stop_master(node):
377
def call_node_stop_master(node, stop_daemons):
378 378
  """Tells a node to demote itself from master status.
379 379

  
380 380
  This is a single-node call.
381 381

  
382 382
  """
383
  c = Client("node_stop_master", [])
383
  c = Client("node_stop_master", [stop_daemons])
384 384
  c.connect(node)
385 385
  c.run()
386 386
  return c.getresult().get(node, False)
......
803 803
  c.connect(node)
804 804
  c.run()
805 805
  return c.getresult().get(node, False)
806

  

Also available in: Unified diff