Class: VCAP::Services::Base::SnapshotV2::BaseDeleteSnapshotJob

Inherits:
SnapshotJob show all
Defined in:
lib/base/snapshot_v2/snapshot.rb

Instance Attribute Summary

Attributes inherited from SnapshotJob

#name, #snapshot_id

Instance Method Summary collapse

Methods inherited from SnapshotJob

#cleanup, #create_lock, #fmt_error, #get_dump_path, #handle_error, #init_worker_logger, #initialize, #parse_config, queue_lookup_key, #required_options, select_queue

Constructor Details

This class inherits a constructor from VCAP::Services::Base::SnapshotV2::SnapshotJob

Instance Method Details

#executeObject



184
185
186
# File 'lib/base/snapshot_v2/snapshot.rb', line 184

def execute
  cleanup(name, snapshot_id)
end

#performObject



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/base/snapshot_v2/snapshot.rb', line 159

def perform
  begin
    required_options :service_id, :snapshot_id
    @name = options["service_id"]
    @snapshot_id = options["snapshot_id"]
    @logger.info("Launch job: #{self.class} for #{name}")

    lock = create_lock

    lock.lock do
      result = execute
      @logger.info("Results of delete snapshot: #{result}")

      delete_snapshot(name, snapshot_id)

      completed(Yajl::Encoder.encode({:result => :ok}))
      @logger.info("Complete job: #{self.class} for #{name}")
    end
  rescue => e
    handle_error(e)
  ensure
    set_status({:complete_time => Time.now.to_s})
  end
end