Beispiel #1
0
def perform_maintenance_hosts(cluster):
    """usage: perform_maintenance cluster [--filename=filename]
                                        [--hosts=hosts]
                                        [--batch_size=num]
                                        [--post_drain_script=path]
                                        [--grouping=function]

  Asks the scheduler to remove any running tasks from the machine and remove it
  from service temporarily, perform some action on them, then return the machines
  to service.
  """
    options = app.get_options()
    drainable_hosts = parse_hosts(options)

    if options.post_drain_script:
        if not os.path.exists(options.post_drain_script):
            die("No such file: %s" % options.post_drain_script)
        cmd = os.path.abspath(options.post_drain_script)
        drained_callback = lambda host: subprocess.Popen([cmd, host])
    else:
        drained_callback = None

    MesosMaintenance(CLUSTERS[cluster], options.verbosity).perform_maintenance(
        drainable_hosts,
        batch_size=int(options.batch_size),
        callback=drained_callback,
        grouping_function=options.grouping)
Beispiel #2
0
def end_maintenance_hosts(cluster):
    """usage: end_maintenance_hosts cluster [--filename=filename]
                                          [--hosts=hosts]
  """
    options = app.get_options()
    MesosMaintenance(CLUSTERS[cluster],
                     options.verbosity).end_maintenance(parse_hosts(options))
Beispiel #3
0
def host_maintenance_status(cluster):
    """usage: host_maintenance_status cluster [--filename=filename]
                                            [--hosts=hosts]

  Check on the schedulers maintenance status for a list of hosts in the cluster.
  """
    options = app.get_options()
    checkable_hosts = parse_hosts(options)
    statuses = MesosMaintenance(
        CLUSTERS[cluster], options.verbosity).check_status(checkable_hosts)
    for pair in statuses:
        log.info("%s is in state: %s" % pair)
 def test_start_maintenance(self, mock_api):
   mock_api.return_value = Response(responseCode=ResponseCode.OK)
   maintenance = MesosMaintenance(DEFAULT_CLUSTER, 'quiet')
   maintenance.start_maintenance(MOCK_TEST_HOSTS)