def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize
      fail_if_shutdown(droplet)

      logger.info "Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}."

      today         = DateTime.now
      name          = "#{droplet.name}_#{today.strftime('%Y_%m_%d')}"
      # noinspection RubyResolve
      snapshot_size = api.snapshots(droplet).size

      logger.debug 'Wait until snapshot will be created.'

      api.create_snapshot droplet.id, name

      snapshot_size += 1

      logger.info "Snapshot name: #{name} created successfully."
      logger.info "Droplet id: #{droplet.id} name: #{droplet.name} snapshots: #{snapshot_size}."

      # Cleanup snapshots.
      cleanup_snapshots droplet, snapshot_size if clean
    rescue => e
      case e.class.to_s
      when 'DoSnapshot::SnapshotCleanupError'
        raise e.class, e.message, e.backtrace
      when 'DoSnapshot::DropletPowerError'
        return
      else
        raise SnapshotCreateError.new(droplet.id), e.message, e.backtrace
      end
    end
def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize
      fail_if_shutdown(droplet)

      logger.info "Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}."

      today         = DateTime.now
      name          = "#{droplet.name}_#{today.strftime('%Y_%m_%d')}"
      # noinspection RubyResolve
      snapshot_size = api.snapshots(droplet).size

      logger.debug 'Wait until snapshot will be created.'

      api.create_snapshot droplet.id, name

      snapshot_size += 1

      logger.info "Snapshot name: #{name} created successfully."
      logger.info "Droplet id: #{droplet.id} name: #{droplet.name} snapshots: #{snapshot_size}."

      # Cleanup snapshots.
      cleanup_snapshots droplet, snapshot_size if clean
    rescue => e
      case e.class.to_s
      when 'DoSnapshot::SnapshotCleanupError'
        raise e.class, e.message, e.backtrace
      when 'DoSnapshot::DropletPowerError'
        return
      else
        raise SnapshotCreateError.new(droplet.id), e.message, e.backtrace
      end
    end
Trying to create a snapshot.