Discover master(s) and decide where to connect, if SSDP is around.
        This modifies the configuration on the fly.
        :return:

def _discover_masters(self):
        '''
        Discover master(s) and decide where to connect, if SSDP is around.
        This modifies the configuration on the fly.
        :return:
        '''
        if self.opts['master'] == DEFAULT_MINION_OPTS['master'] and self.opts['discovery'] is not False:
            master_discovery_client = salt.utils.ssdp.SSDPDiscoveryClient()
            masters = {}
            for att in range(self.opts['discovery'].get('attempts', 3)):
                try:
                    att += 1
                    log.info('Attempting %s time(s) to discover masters', att)
                    masters.update(master_discovery_client.discover())
                    if not masters:
                        time.sleep(self.opts['discovery'].get('pause', 5))
                    else:
                        break
                except Exception as err:
                    log.error('SSDP discovery failure: %s', err)
                    break

            if masters:
                policy = self.opts.get('discovery', {}).get('match', 'any')
                if policy not in ['any', 'all']:
                    log.error('SSDP configuration matcher failure: unknown value "%s". '
                              'Should be "any" or "all"', policy)
                    return
                mapping = self.opts['discovery'].get('mapping', {})
                discovered = []
                for addr, mappings in masters.items():
                    for proto_data in mappings:
                        cnt = len([key for key, value in mapping.items()
                                   if proto_data.get('mapping', {}).get(key) == value])
                        if policy == 'any' and bool(cnt) or cnt == len(mapping):
                            if self.opts['discovery'].get('multimaster'):
                                discovered.append(proto_data['master'])
                            else:
                                self.opts['master'] = proto_data['master']
                                return
                self.opts['master'] = discovered