Creates/updates all errand job instances
 @return [void]
9056
def update_instances
      instance_group_updater = InstanceGroupUpdater.new(
        ip_provider: @deployment_planner.ip_provider,
        instance_group: @instance_group,
        disk_manager: @disk_manager,
        template_blob_cache: @template_blob_cache,
        dns_encoder: @dns_encoder,
        link_provider_intents: @deployment_planner.link_provider_intents,
      )
      instance_group_updater.update
    end
120328
def resumable(self):
        ''''''
        # First, find the jids of all the jobs registered to this client.
        # Then, get the corresponding job objects
        jids = self.client.workers[self.client.worker_name]['jobs']
        jobs = self.client.jobs.get(*jids)

        # We'll filter out all the jobs that aren't in any of the queues
        # we're working on.
        queue_names = set([queue.name for queue in self.queues])
        return [job for job in jobs if job.queue_name in queue_names]
218517
def build_blast_jobs
      @job ||= Job.new
      @job.build_blastn_job  if @job.blastn_job.nil?
      @job.build_blastx_job  if @job.blastx_job.nil?
      @job.build_tblastn_job if @job.tblastn_job.nil?
      @job.build_blastp_job  if @job.blastp_job.nil?
    end
1039057
def poll_queue
      @job = reserve_job
      if @job.nil?
        @log.info('No job found')
      else
        @log.info('Job starting')
        begin
          @current_job_start_time = Time.now
          execute_job
        rescue => e
          @log.info("Error running test: #{e.message}\n : #{e.backtrace.join("\n :")}")
        end
        cleanup
      end
    end
741467
def register_jobs(commands, callable)
      commands.each do |command|
        register_job do
          JobWrapper.call(command,callable)
        end
      end
    end
473629
def _create_job(self, func, args=None, kwargs=None, commit=True,
                    result_ttl=None, ttl=None, id=None, description=None,
                    queue_name=None, timeout=None, meta=None):
        
        if args is None:
            args = ()
        if kwargs is None:
            kwargs = {}
        job = self.job_class.create(
                func, args=args, connection=self.connection,
                kwargs=kwargs, result_ttl=result_ttl, ttl=ttl, id=id,
                description=description, timeout=timeout, meta=meta)
        if self._queue is not None:
            job.origin = self._queue.name
        else:
            job.origin = queue_name or self.queue_name
        if commit:
            job.save()
        return job
910576
def create_or_update(options) #:nodoc:
                                  #      puts 'create_or_update'
      ret = true
      run_callbacks :save do
        result = new_record? ? create(options) : update(options)
#        puts 'save_callbacks result=' + result.inspect
        ret = result
      end
      ret
    end
1030753
def bulk_update_batches(aggregations)
      en = Enumerator.new do |e|
        i = 1
        batch = []
        aggregations.each do |agg|
          batch << agg
          if i % @bulk_update_size == 0
            e.yield batch
            batch = []
          end
          i += 1
        end
        e.yield batch if batch.count > 0  # last one
      end
      en.lazy
    end
585912
def process(job = nil, &block)
      return unless job ||= reserve

      job.worker = self
      working_on job
      perform(job, &block)
    ensure
      done_working
    end
783866
def update(bulk = false)
      caught = catch(:halt)  do
        if self.new?
          save(bulk)
        else
          _run_update_callbacks do
            _run_save_callbacks do
              save_without_callbacks(bulk)
            end
          end
        end
      end
    end
287109
def reset
      self.level = :normal
      flush
      close_log(@last_file)
      @last_file = nil
      close_log(@job_file)
      @job_file = nil
      @custom_logs.each do |name, log|
        close_log(log)
      end
      @custom_logs = {}
    end
418371
def at(time, callable=nil, opts={}, &block)

      do_schedule(:once, time, callable, opts, opts[:job], block)
    end
398112
def load_tasks(app = self)
      if Rails::VERSION::MAJOR < 4
        railties.all { |r| r.load_tasks(app) }
      end

      extend Rake::DSL if defined? Rake::DSL
      self.class.rake_tasks.each { |block| instance_exec(app, &block) }
      paths['lib/tasks'].existent.sort.each { |ext| load(ext) }
      self
    end
1027673
def queue_future_jobs
      tasks.each do |task|
        # Schedule the new run times using the future job wrapper.
        new_run_times = task.future_run_times - task.existing_run_times
        new_run_times.each do |time|
          SimpleScheduler::FutureJob.set(queue: @queue_name, wait_until: time)
                                    .perform_later(task.params, time.to_i)
        end
      end
    end
960193
def perform
      job = payload_class
      job_args = args || []
      job_was_performed = false

      begin
        # Execute before_perform hook. Abort the job gracefully if
        # Resque::DontPerform is raised.
        begin
          before_hooks.each do |hook|
            job.send(hook, *job_args)
          end
        rescue DontPerform
          return false
        end

        # Execute the job. Do it in an around_perform hook if available.
        if around_hooks.empty?
          job.perform(*job_args)
          job_was_performed = true
        else
          # We want to nest all around_perform plugins, with the last one
          # finally calling perform
          stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
            if last_hook
              lambda do
                job.send(hook, *job_args) { last_hook.call }
              end
            else
              lambda do
                job.send(hook, *job_args) do
                  result = job.perform(*job_args)
                  job_was_performed = true
                  result
                end
              end
            end
          end
          stack.call
        end

        # Execute after_perform hook
        after_hooks.each do |hook|
          job.send(hook, *job_args)
        end

        # Return true if the job was performed
        return job_was_performed

      # If an exception occurs during the job execution, look for an
      # on_failure hook then re-raise.
      rescue Object => e
        run_failure_hooks(e)
        raise e
      end
    end
474222
def reload(self, schedule):
        '''
        
        '''
        # Remove all jobs from self.intervals
        self.intervals = {}

        if 'schedule' in schedule:
            schedule = schedule['schedule']
        self.opts.setdefault('schedule', {}).update(schedule)
32574
def generate_jobs(queue_servers, queue_template, queue_executable)
      counter = 0
      tasks = []
      Log.debug "[#{Chimp.get_job_uuid}] Loading queue..."
      #
      # Configure group
      #
      if not ChimpQueue[@group]
        ChimpQueue.instance.create_group(@group, @group_type, @group_concurrency)
      end

      #
      # Process Server selection
      #
      Log.debug("[#{Chimp.get_job_uuid}] Processing server selection for task creation")

      queue_servers.sort! { |a,b| a['name'] <=> b['name'] }
      queue_servers.each do |server|
        #
        # Handle limiting options
        #
        counter += 1
        next if @limit_start.to_i > 0 and counter < @limit_start.to_i
        break if @limit_end.to_i > 0 and counter > @limit_end.to_i

        #
        # Construct the Server object
        #
        s = Server.new

        s.params['href']                  = server['href']

        s.params['current_instance_href'] = s.params['href']
        s.params['current-instance-href'] = s.params['href']

        s.params['name']                  = server['name']
        s.params['nickname']              = s.params['name']

        s.params['ip_address']            = server['public_ip_addresses'].first
        s.params['ip-address']            = s.params['ip_address']

        s.params['private-ip-address']    = server['private_ip_addresses'].first
        s.params['private_ip_address']    = s.params['private-ip-address']

        s.params['resource_uid']          = server['resource_uid']
        s.params['resource-uid']          = s.params['resource_uid']

        s.params['instance-type']         = server['links']['instance_type']['name']
        s.params['instance_type']         = s.params['instance-type']
        s.params['ec2_instance_type']     = s.params['instance-type']
        s.params['ec2-instance-type']     = s.params['instance-type']

        s.params['dns-name']              = server['public_dns_names'].first
        s.params['dns_name']              = s.params['dns-name']

        s.params['locked']                = server['locked']
        s.params['state']                 = server['state']
        s.params['datacenter']            = server['links']['datacenter']['name']

        # This will be useful for later on when we need to run scripts
        Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (SERVER) for task creation"
        begin
          tries ||= 3
          s.object = Connection.client.resource(server['href'])
          Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.resource (SERVER) for task creation COMPLETE"
        rescue
          Log.error "[#{Chimp.get_job_uuid}] Failed to load server href via API1.5 for task creation (retrying)"
          sleep 30
          retry unless (tries -= 1).zero?
          Log.error "[#{Chimp.get_job_uuid}] Failed to load server href via API1.5 for task creation (giving up)"
        end

        e = nil

        # If @script has been passed
        if queue_executable
          e = ExecRightScript.new(
            :server => s,
            :exec => queue_executable,
            :job_uuid => @job_uuid,
            :job_notes => @job_notes,
            :inputs => @inputs,
            :timeout => @timeout,
            :delay => @delay,
            :concurrency => @concurrency,
            :verbose => @@verbose,
            :quiet => @@quiet
          )
        elsif @ssh
          e = ExecSSH.new(
            :server => s,
            :ssh_user => @ssh_user,
            :exec => @ssh,
            :verbose => @@verbose,
            :quiet => @@quiet
          )
        elsif @report
          if s.href
            e = ExecReport.new(:server => s, :verbose => @@verbose, :quiet => @@quiet)
            e.fields = @report
          end
        elsif @set_tags.size > 0
          e = ExecSetTags.new(:server => s, :verbose => @@verbose, :quiet => @@quiet)
          e.tags = set_tags
        end

        if e != nil
          e.dry_run = @dry_run
          e.quiet   = @@quiet
          e.status  = Executor::STATUS_HOLDING if @hold

          Log.debug "[#{Chimp.get_job_uuid}] Pushing task (end of control)"
          tasks.push(e)
        end
      end
      return(tasks)
    end