示例#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))
示例#2
0
 def setUp(self):
     self.testsnap = \
     AixSnap('/Users/vs/dev/confcenter/upload/testsnap/98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z_AIX/')
     self.name = '98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z'
     self.file = open('/Users/vs/dev/confcenter/upload/testsnap/98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z')
示例#3
0
class AixSnapTest(TestCase):
    def setUp(self):
        self.testsnap = \
        AixSnap('/Users/vs/dev/confcenter/upload/testsnap/98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z_AIX/')
        self.name = '98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z'
        self.file = open('/Users/vs/dev/confcenter/upload/testsnap/98e6a40e05a8334dd7a43901d08a068e_erie1.snap.pax.Z')

    def test_all_snap(self):
        """
        Full test for snap
        """
        results = detect_filetype(self.file, self.name)
        self.assertEqual(results['filetype'], 'AIX')
        data = self.testsnap.sys0_params()
        self.assertEqual(data['plat_serial'], '0284D5AF6')
        data = self.testsnap.oslevel_params()
        self.assertEqual(data['oslevel'], '7100-00-03-1115')
        data = self.testsnap.mcodes_params()
        self.assertIsNotNone(data, msg='mcodes is None')
        data = self.testsnap.dumpdev_params()
        self.assertIsNotNone(data, msg='dumpdev is None')
        data = self.testsnap.dump_params()
        self.assertIsNotNone(data, msg='dump is None')
        data = self.testsnap.emgr_params()
        self.assertIsNotNone(data, msg='emgris None')
        data = self.testsnap.errpt_params()
        self.assertIsNotNone(data, msg='errptis None')
        data = self.testsnap.swap_params()
        self.assertIsNotNone(data, msg='swap is None')
        data = self.testsnap.rpm_params()
        self.assertIsNotNone(data, msg='rpm is None')
        data = self.testsnap.ent1g_params()
        self.assertIsNotNone(data, msg='ent1g is None')
        data = self.testsnap.ent10g_params()
        self.assertIsNotNone(data, msg='ent10g is None')
        data = self.testsnap.entec_params()
        self.assertIsNotNone(data, msg='entec is None')
        data = self.testsnap.fcs_params()
        self.assertIsNotNone(data, msg='fcs is None')
        data = self.testsnap.fscsi_params()
        self.assertIsNotNone(data, msg='fscsi is None')
        data = self.testsnap.vrtspack_params()
        self.assertIsNotNone(data, msg='vrts is None')
        data = self.testsnap.smt_params()
        self.assertIsNotNone(data, msg='smt is None')
        data = self.testsnap.rmt_params()
        self.assertIsNotNone(data, msg='rmt is None')
        data = self.testsnap.limits_params()
        self.assertIsNotNone(data, msg='limits is None')
        data = self.testsnap.lpar_params()
        self.assertIsNotNone(data, msg='lpar is None')
        data = self.testsnap.hostname_params()
        self.assertEqual(data['hostname'], 'erie1')
        data = self.testsnap.hdisk_params()
        self.assertIsNotNone(data, msg='hdisk is None')
        data = self.testsnap.hacmp_params()
        self.assertIsNotNone(data, msg='hacmp is None')
        data = self.testsnap.tunables_params()
        self.assertIsNotNone(data, msg='tunables is None')
        data = self.testsnap.nfs_params()
        self.assertIsNotNone(data, msg='nfs is None')
        data = self.testsnap.dns_params()
        self.assertIsNotNone(data, msg='dns is None')
        data = self.testsnap.no_params()
        self.assertIsNotNone(data, msg='no is None')
        data = self.testsnap.hostsequiv_params()
        self.assertIsNone(data, msg='hostequiv is None')
        data = self.testsnap.vg_params()
        self.assertIsNotNone(data, msg='vg is None')
        data = self.testsnap.lv_params()
        self.assertIsNotNone(data, msg='lv is None')
        data = self.testsnap.adapters_params()
        self.assertIsNotNone(data, msg='adaoters is None')
示例#4
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()