code: def _init(self, state, initiate_arg):
          '''
          Set initial state of the task. Called from initiate.
          @param initiate_arg: either the PartnerClass object (StartTask)
                               or an agent_id (RestartTask)
          '''
          state.descriptor = None
          state.hosts = state.agent.query_partners('hosts')
          state.current_index = -1
  
          self.log('%s task initiated, will be trying to start a '
                   '%r on one of the hosts: %r', str(self.__class__.__name__),
                   initiate_arg, state.hosts)
          if len(state.hosts) == 0:
              # FIXME: Here would be a good idea to put an alert
              return self._fail('Shard Agent cannot start partner %r as it has '
                                'no Host Partners!' % (initiate_arg, )f _init(self, state, initiate_arg):
          '''
          Set initial state of the task. Called from initiate.
          @param initiate_arg: either the PartnerClass object (StartTask)
                               or an agent_id (RestartTask)
          '''
          state.descriptor = None
          state.hosts = state.agent.query_partners('hosts')
          state.current_index = -1
  
          self.log('%s task initiated, will be trying to start a '
                   '%r on one of the hosts: %r', str(self.__class__.__name__),
                   initiate_arg, state.hosts)
          if len(state.hosts) == 0:
              # FIXME: Here would be a good idea to put an alert
              return self._fail('Shard Agent cannot start partner %r as it has '
                                'no Host Partners!' % (initiate_arg, ))
docs: Set initial state of the task. Called from initiate.
          @param initiate_arg: either the PartnerClass object (StartTask)
                               or an agent_id (RestartTask)