Example #1
0
def get_masters_for_host(desired_state, build_dir, hostname):
    """Identify which masters on this host should be managed.

  Returns triggered_masters and ignored_masters (a list and a set respectively).

  triggered_masters are masters on this host which have a corresponding entry in
  the desired_master_state file. Any master running assigned to this host that 
  does *not* have an entry in the desired_master_state file is considered
  'ignored.'

  triggered_masters is a list of dicts. Each dict is the full dict from
  mastermap.py with two extra keys: 'fulldir' (the absolute path to the master
  directory), and 'states' (a list of desired states sorted by transition time,
  pulled from the desired states file).

  ignored_masters is a set of 'dirname' strings (ex: master.chromium).
  """
    triggered_masters = []
    ignored_masters = set()
    for master_dict in master.get_mastermap_for_host(build_dir, hostname):
        if master_dict['dirname'] in desired_state:
            if master_dict['internal']:
                master_dir = os.path.abspath(
                    os.path.join(build_dir, os.pardir, 'build_internal',
                                 'masters', master_dict['dirname']))
            else:
                master_dir = os.path.abspath(
                    os.path.join(build_dir, 'masters', master_dict['dirname']))
            master_dict['fulldir'] = master_dir
            master_dict['states'] = desired_state[master_dict['dirname']]

            triggered_masters.append(master_dict)
        else:
            ignored_masters.add(master_dict['dirname'])
    return triggered_masters, ignored_masters
Example #2
0
def create_from_mastermap(build_dir, hostname,
                          cloudtail_path):  # pragma: no cover
  logging.info('Creating monitors from mastermap for host %s', hostname)
  return _create_from_mastermap(
      build_dir,
      master.get_mastermap_for_host(build_dir, hostname),
      cloudtail_path)
Example #3
0
  def testMastermapHost(self):
    masters = [
        {'fullhost': 'bananas.cool'},
        {'fullhost': 'bananas.cool'},
        {'fullhost': 'bananas_dos.cool'},
    ]
    self.mock(master, '_call_mastermap', lambda _x: masters)

    self.assertEqual(
        len(master.get_mastermap_for_host('fake', 'bananas.cool')),
        2)
Example #4
0
  def testMastermapHost(self):
    masters = [
        {'fullhost': 'bananas.cool'},
        {'fullhost': 'bananas.cool'},
        {'fullhost': 'bananas_dos.cool'},
    ]
    self.mock(master, '_call_mastermap', lambda _x: masters)

    self.assertEqual(
        len(master.get_mastermap_for_host('fake', 'bananas.cool')),
        2)
Example #5
0
def get_masters_for_host(desired_state, build_dir, hostname):
  """Identify which masters on this host should be managed.

  Returns triggered_masters and ignored_masters (a list and a set respectively).

  triggered_masters are masters on this host which have a corresponding entry in
  the desired_master_state file. Any master running assigned to this host that
  does *not* have an entry in the desired_master_state file is considered
  'ignored.'

  triggered_masters is a list of dicts. Each dict is the full dict from
  mastermap.py with two extra keys:
    - 'fulldir': the absolute path to the master directory
    - 'states': the state configuration for that master
    - 'params': any configured parameters for that master

  ignored_masters is a set of 'dirname' strings (ex: master.chromium).
  """
  master_states = desired_state.get('master_states', {})
  master_params = desired_state.get('master_params', {})

  triggered_masters = []
  ignored_masters = set()
  for master_dict in master.get_mastermap_for_host(
      build_dir, hostname):
    mastername = master_dict['dirname']
    if mastername in master_states:
      if master_dict['internal']:
        master_dir = os.path.abspath(os.path.join(
          build_dir, os.pardir, 'build_internal', 'masters',
          mastername))
      else:
        master_dir = os.path.abspath(os.path.join(
          build_dir, 'masters', mastername))
      master_dict['fulldir'] = master_dir
      master_dict['states'] = master_states[mastername]
      master_dict['params'] = master_params.get(mastername, {})

      triggered_masters.append(master_dict)
    else:
      ignored_masters.add(mastername)
  return triggered_masters, ignored_masters
Example #6
0
def get_masters_for_host(desired_state, build_dir, hostname):
    """Identify which masters on this host should be managed.

  Returns triggered_masters and ignored_masters (a list and a set respectively).

  triggered_masters are masters on this host which have a corresponding entry in
  the desired_master_state file. Any master running assigned to this host that
  does *not* have an entry in the desired_master_state file is considered
  'ignored.'

  triggered_masters is a list of dicts. Each dict is the full dict from
  mastermap.py with two extra keys:
    - 'fulldir': the absolute path to the master directory
    - 'states': the state configuration for that master
    - 'params': any configured parameters for that master

  ignored_masters is a set of 'dirname' strings (ex: master.chromium).
  """
    master_states = desired_state.get('master_states', {})
    master_params = desired_state.get('master_params', {})

    triggered_masters = []
    ignored_masters = set()
    for master_dict in master.get_mastermap_for_host(build_dir, hostname):
        mastername = master_dict['dirname']
        if mastername in master_states:
            if master_dict['internal']:
                master_dir = os.path.abspath(
                    os.path.join(build_dir, os.pardir, 'build_internal',
                                 'masters', mastername))
            else:
                master_dir = os.path.abspath(
                    os.path.join(build_dir, 'masters', mastername))
            master_dict['fulldir'] = master_dir
            master_dict['states'] = master_states[mastername]
            master_dict['params'] = master_params.get(mastername, {})

            triggered_masters.append(master_dict)
        else:
            ignored_masters.add(mastername)
    return triggered_masters, ignored_masters
def get_masters_for_host(desired_state, build_dir, hostname):
  """Identify which masters on this host should be managed.

  Returns triggered_masters and ignored_masters (a list and a set respectively).

  triggered_masters are masters on this host which have a corresponding entry in
  the desired_master_state file. Any master running assigned to this host that
  does *not* have an entry in the desired_master_state file is considered
  'ignored.'

  triggered_masters is a list of dicts. Each dict is the full dict from
  mastermap.py with two extra keys: 'fulldir' (the absolute path to the master
  directory), and 'states' (a list of desired states sorted by transition time,
  pulled from the desired states file).

  ignored_masters is a set of 'dirname' strings (ex: master.chromium).
  """
  triggered_masters = []
  ignored_masters = set()
  for master_dict in master.get_mastermap_for_host(
      build_dir, hostname):
    if master_dict['dirname'] in desired_state:
      if master_dict['internal']:
        master_dir = os.path.abspath(os.path.join(
          build_dir, os.pardir, 'build_internal', 'masters',
          master_dict['dirname']))
      else:
        master_dir = os.path.abspath(os.path.join(
          build_dir, 'masters', master_dict['dirname']))
      master_dict['fulldir'] = master_dir
      master_dict['states'] = desired_state[master_dict['dirname']]

      triggered_masters.append(master_dict)
    else:
      ignored_masters.add(master_dict['dirname'])
  return triggered_masters, ignored_masters