def action(self, **kwa):
        stack = self.stack.value
        if stack and isinstance(stack, RoadStack):
            refresh_masters = (self.opts.value.get('raet_clear_remote_masters',
                                       True) or not stack.remotes)

            refresh_all = (self.opts.value.get('raet_clear_remotes', True) or
                       not stack.remotes)

            if refresh_masters:  # clear all remote masters
                for remote in list(stack.remotes.values()):
                    if remote.kind == kinds.applKinds.master:
                        stack.removeRemote(remote, clear=True)

            if refresh_all:  # clear all remotes
                for remote in list(stack.remotes.values()):
                    stack.removeRemote(remote, clear=True)

            if refresh_all or refresh_masters:
                stack.puid = stack.Uid  # reset puid so reuse same uid each time

                ex = SaltException('Unable to connect to any master')
                for master in self.ushers.value:
                    try:
                        mha = master['external']
                        stack.addRemote(RemoteEstate(stack=stack,
                                                     fuid=0,  # vacuous join
                                                     sid=0,  # always 0 for join
                                                     ha=mha,
                                                     kind=kinds.applKinds.master))
                    except gaierror as ex:
                        log.warning("Unable to connect to master {0}: {1}".format(mha, ex))
                        if self.opts.value.get('master_type') != 'failover':
                            raise ex
                if not stack.remotes:
                    raise ex

            for remote in list(stack.remotes.values()):
                if remote.kind == kinds.applKinds.master:
                    stack.join(uid=remote.uid, timeout=0.0)
Join with all masters
dataset/ETHPy150Open saltstack/salt/salt/daemons/flo/core.py/SaltRaetRoadStackJoiner.action