def check_integrity(): s3 = Offsite.get_s3_interface() offsite_keys = s3.list_files() for key in offsite_keys: filename = key.name filename_on_disk = os.path.join(settings.NIMBUS_DEFAULT_ARCHIVE, filename) if os.path.exists(filename_on_disk): print "Checking",filename,"...", s3_md5 = key.metadata.get('nimbus-md5', None) local_md5 = outils.md5_for_large_file(filename_on_disk) is_ok = True if s3_md5: if s3_md5 != local_md5: is_ok = False else: if not '-' in key.etag: s3_md5 = key.etag.strip('"\'') if local_md5 != s3_md5: is_ok = False else: size = os.path.getsize(filename_on_disk) if size != key.size: is_ok = False if is_ok: print "Ok" else: print "Error" f = utils.filesizeformat size = os.path.getsize(filename_on_disk) print "Local file size: {0}. Remote file size: {1}".format(f(size), f(f.size)) print "Local file md5: {0}. Remote file md5: {1}".format(local_md5, s3_md5)
def detail(request): offsite = Offsite.get_instance() uploads = list(LocalUploadRequest.objects.all()) + list( RemoteUploadRequest.objects.all()) content = [] for upload in uploads: content.append({ 'type': 'ok', 'date': upload.last_attempt or upload.created_at, 'label': upload.volume.filename, 'message': "%.2f MB" % utils.bytes_to_mb(upload.volume.size) }) transferencias_em_execucao = [{ 'title': u'Transferências em execução', 'content': content }] if offsite.active: graphic = Graphics() graph_block = graphic.data_to_template()[0] else: ocupacao_offsite = 0.0 messages.error(request, "Offsite desativado") return render_to_response(request, "detail.html", locals())
def update_db(self): """Metodo obrigatorio para todas as classes Graphics""" offsite = self.offsite_if_active() if offsite: plan_total = offsite.plan_size try: s3 = Offsite.get_s3_interface() now_used = s3.get_size() except (URLError, S3AuthError), error: now_used = 0.0 new_data = OffsiteGraphicsData() new_data.total = plan_total new_data.used = now_used new_data.save()
def detail(request): offsite = Offsite.get_instance() uploads = list(LocalUploadRequest.objects.all()) + list(RemoteUploadRequest.objects.all()) content = [] for upload in uploads: content.append({'type' : 'ok', 'date' : upload.last_attempt or upload.created_at, 'label' : upload.volume.filename, 'message' : "%.2f MB" % utils.bytes_to_mb(upload.volume.size) }) transferencias_em_execucao = [{'title': u'Transferências em execução', 'content': content}] if offsite.active: graphic = Graphics() graph_block = graphic.data_to_template()[0] else: ocupacao_offsite = 0.0 messages.error(request, "Offsite desativado") return render_to_response(request, "detail.html", locals())
def ratelimit(self): self.logger.info('QueueServiceManager.ratelimit') offsite = Offsite.get_instance() return offsite.rate_limit
def offsite_if_active(self): offsite = Offsite.get_instance() if offsite.active: return offsite
def get_plan_size(self): from nimbus.offsite.models import Offsite conf = Offsite.get_instance() return conf.plan_size
def __init__(self): self.s3 = Offsite.get_s3_interface()