Ejemplo n.º 1
0
def upload_file(request):
    """
        Function upload_file starts form for confupload_form.html
    """
    if request.method == 'POST':
        form = ConfUploadForm(request.POST, request.FILES)
        if form.is_valid():
            UF_FORM = form.cleaned_data
            if 'X-Progress-ID' in request.GET:
                request.session['X-Progress-ID'] = request.GET['X-Progress-ID']
            logger.info("Starting file  %s proccessing in %s for user from %s" % (request.FILES['file'].name, whoami(),
                                                                               get_client_ip(request)))
            fileattr = handle_uploaded_file(request.FILES['file'], get_session_key(request) + '_' +
                                                                    request.FILES['file'].name, UF_FORM['ostype'])
            if not ( fileattr == None ):
                request.session['archpath'] = fileattr['archpath']
                logger.info("Sucsessfully handeled file  %s in %s" % (request.FILES['file'].name, whoami()))
                if fileattr['archpath'] == 'counfdump none':
                    with open(fileattr['dumpfilename']) as infile:
                        AIXSNAP = load(infile)
                else:
                    snap = AixSnap(fileattr['archpath'])
                    AIXSNAP = snap.snap_analyze(request.FILES['file'].name)
                    snap.dump_snap_to_json(request.FILES['file'].name, fileattr['dumpfilename'])
                    snap.snap_destroy()
                request.session['AIXSNAP'] = AIXSNAP
                request.session['dumpfilename'] = fileattr['dumpfilename']

                return redirect('/upload/anal_acc/')
            else:
                logger.info("File type %s is not good, reported from %s" % (request.FILES['file'].name, whoami()))
                return HttpResponse(_('Bad file type or file corrupted'))

    else:
        logger.info("Empty upload form prepared from %s for user from %s, "
                    "session id %s" % (whoami(), get_client_ip(request), get_session_key(request)))
        form = ConfUploadForm() # A empty, unbound form

    return render_to_response('confupload_form.html', {'form': form, 'MEDIA_URL' : MEDIA_URL},
        context_instance=RequestContext(request))
Ejemplo n.º 2
0
from aixsnap import AixSnap

#snap = AixSnap('/Users/vs/dev/confcenter/confcenter/confuploads/98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z_AIX/')
#print snap.smt_new()
#print snap.LVM_SNAP.closed
#print snap.FS_SNAP.closed

from django.core.files.uploadhandler import TemporaryFileUploadHandler

#def full_snap_test():
#current_snap = AixSnap('/Users/vs/dev/confcenter/confcenter/confuploads/08fbb839476f26469c6087121133feae_snap_valday2_060712.pax.Z_AIX/')
#current_snap = AixSnap('/Users/vs/dev/confcenter/confcenter/confuploads/dac0b33d7b88a2b27b3ba50d0aa0b1a7_snap_valday2_060712.pax.Z_AIX/')
snap = AixSnap(
    '/Users/vs/dev/confcenter/confcenter/confuploads/d32cb43aca57a20d12e246e262d52b01_snap_dubna-t3.pax.Z_AIX/')
snap.dump_snap_to_json('snap_dubna-t3.pax', 'test.json')
snap.load_snap_from_json('test.json')
xxx = AixSnap('')
DATA = xxx.load_snap_from_json('test.json')
print snap.adapters_params()
print DATA
#print snap.entec_params()
#snap.sys0_params()
#snap.oslevel_params()
#snap.mcodes_params()
#snap.dumpdev_params()
#snap.dump_params()
#snap.emgr_params()
#snap.errpt_params()
#snap.bootinfok_params()
#snap.swap_params()
#snap.rpm_params()