(self, old_node_name)
Generic node switchover.
Generic node switchover.
Generic node switchover .
def cmd_takeover(self, old_node_name):
        """Generic node switchover."""
        self.log.info("old: %s", old_node_name)
        self.load_local_info()
        new_node_name = self.options.node
        if not new_node_name:
            worker = self.options.consumer
            if not worker:
                raise UsageError('old node not given')
            if self.queue_info.local_node.worker_name != worker:
                raise UsageError('old node not given')
            new_node_name = self.local_node
        if not old_node_name:
            raise UsageError('old node not given')

        if old_node_name not in self.queue_info.member_map:
            raise UsageError('Unknown node: %s' % old_node_name)

        if self.options.dead_root:
            otype = 'root'
            failover = True
        elif self.options.dead_branch:
            otype = 'branch'
            failover = True
        else:
            onode = self.get_node_info(old_node_name)
            otype = onode.type
            failover = False

        if failover:
            self.cmd_tag_dead(old_node_name)

        new_node = self.get_node_info(new_node_name)
        if old_node_name == new_node.name:
            self.log.info("same node?")
            return

        if otype == 'root':
            self.takeover_root(old_node_name, new_node_name, failover)
        else:
            self.takeover_nonroot(old_node_name, new_node_name, failover)

        # switch subscribers around
        if self.options.all or failover:
            for n in self.find_subscribers_for(old_node_name):
                if n != new_node_name:
                    self.node_change_provider(n, new_node_name)
def cmd_takeover ( self , old_node_name ) : self . log . info ( "old: %s" , old_node_name ) self . load_local_info ( ) new_node_name = self . options . node if not new_node_name : worker = self . options . consumer if not worker : raise UsageError ( 'old node not given' ) if self . queue_info . local_node . worker_name != worker : raise UsageError ( 'old node not given' ) new_node_name = self . local_node if not old_node_name : raise UsageError ( 'old node not given' ) if old_node_name not in self . queue_info . member_map : raise UsageError ( 'Unknown node: %s' % old_node_name ) if self . options . dead_root : otype = 'root' failover = True elif self . options . dead_branch : otype = 'branch' failover = True else : onode = self . get_node_info ( old_node_name ) otype = onode . type failover = False if failover : self . cmd_tag_dead ( old_node_name ) new_node = self . get_node_info ( new_node_name ) if old_node_name == new_node . name : self . log . info ( "same node?" ) return if otype == 'root' : self . takeover_root ( old_node_name , new_node_name , failover ) else : self . takeover_nonroot ( old_node_name , new_node_name , failover ) # switch subscribers around if self . options . all or failover : for n in self . find_subscribers_for ( old_node_name ) : if n != new_node_name : self . node_change_provider ( n , new_node_name )