Ejemplo n.º 1
0
def spec_filter(request):
    try:
        app = request.GET.get('name')
        default_boxs = standard_filter.obtain_default_boxes(app)
        ACCESS_LOGS.info('app=' + app + 'default_boxs=' + str(default_boxs))
        temp = []
        release_attrs = []
        for default_item in default_boxs:
            if default_item in ['version', 'cpu_type', 'board_type']:
                for release_attr in default_boxs[default_item]:
                    if release_attr == 'hsrp':
                        temp += default_boxs[default_item][release_attr]
                    else:
                        if release_attr not in release_attrs:
                            release_attrs.append(release_attr)
                        temp.append(release_attr)
                        temp += default_boxs[default_item][release_attr]
                default_boxs[default_item] = copy.deepcopy(temp)
                temp = []
        boxs = {
            'defaultts': default_boxs,
            'extra': standard_filter.obtain_extra_keywords(app),
            'release_attr': release_attrs
        }
        ACCESS_LOGS.info('boxs=' + str(boxs))
        response = HttpResponse(json.dumps(boxs),
                                content_type="application/json")
        response.set_cookie('app', app, 3000)
        return response
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 2
0
def filter_query_table(request):
    try:
        app = request.COOKIES.get('app', '')
        query_str = request.GET.get('query')
        query_list = query_str.split('&')
        ACCESS_LOGS.info('app=' + app + 'query_str' + str(query_str) +
                         'query_list=' + str(query_list))
        query_dict = {}
        for query in query_list:
            lists = query.split('=')
            if lists[0] not in query_dict:
                query_dict[lists[0]] = [lists[1].replace('+', ' ')]
            else:
                query_dict[lists[0]].append(lists[1].replace('+', ' '))

        if 'last_update' in query_dict:
            query_dict['last_update'] = query_dict['last_update'][0]

        results = standard_filter.obtain_query_results(query_dict, app)
        ACCESS_LOGS.info('results=' + str(results))
        return_results = OrderedDict()
        for result in results:
            length = len(results[result])
            results[result][length - 1] = str(results[result][length - 1])
            return_results['filter_table_' + str(result)] = results[result]
        ACCESS_LOGS.info('return_results=' + str(return_results))
        response = HttpResponse(json.dumps(return_results),
                                content_type="application/json")
        response.set_cookie('filter_condition', query_dict, 300)
        return response
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 3
0
    def combine_figure_data(self):
        try:
            global rel_name
            global figure_data_summary
            global figure_data_format
            global dict_name
            figure_data_format = collections.OrderedDict()
            figure_data_summary = collections.OrderedDict()
            rel_name = ''
            dict_name = ''

            self.generate_missing_figure_data(self.figure)
            WARNING_LOGS.warning(' self.figure=' + str(self.figure))
            keys = list(self.figure.keys())
            for key in keys:
                string = ''
                rel_name = copy.deepcopy(self.figure[key][self.figure_title])
                WARNING_LOGS.warning(' self.figure[key][self.figure_data_name]=' + str(
                    self.figure[key][self.figure_data_name]) + ' string' + str(string))
                self.define_data(self.figure[key][self.figure_data_name], string)
                WARNING_LOGS.warning(' self.figure[key][self.figure_data_name]=' + str(self.figure[key][self.figure_data_name]) + ' string' + str(string))
                figure_data_summary[key] = copy.deepcopy(self.x_level)
                WARNING_LOGS.warning(' self.x_level=' + str(self.x_level))
                self.x_level.clear()
            WARNING_LOGS.warning(' figure_data_summary=' + str(figure_data_summary))
            self.return_format_figure_data(figure_data_summary)
            WARNING_LOGS.warning(' figure_data_summary=' + str(figure_data_summary))
            return figure_data_format
        except Exception as e:
            ERROR_LOGS.error(e)
            raise e
Ejemplo n.º 4
0
def delete_spec_comments(request):
    try:
        result = Comment.delete_comment(request.GET.get('comment_id'))
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 5
0
def logout(request):
    try:
        response = HttpResponseRedirect('/')
        response.delete_cookie('username')
        response.delete_cookie('user_number')
        return response
    except Exception as e:
        ERROR_LOGS.error(str(e))
        raise e
Ejemplo n.º 6
0
def appname_reflect_func():
    try:
        global appname_reflect
        pwd = os.getcwd()
        with open(pwd + '/conf/appname.json', 'r') as appname_json:
            appname_reflect = json.load(appname_json)
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 7
0
def file_download(request, filename):
    try:
        file = open('static/file/download/' + filename, 'rb')
        response = HttpResponse(file)
        response['Content-Disposition'] = 'attachment;filename=' + filename
        return response
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 8
0
def get_envir():
    try:
        cf = configparser.ConfigParser()
        pwd = os.getcwd()
        cf.read(pwd + '/conf/performance.conf')
        appname_reflect_func()
        return cf.get('filter_key_condition', 'special_filter_condition')
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 9
0
def home_page(request):
    try:
        username = request.COOKIES.get('username', '')
        return render(
            request, 'home.html', {
                'username': username,
                'release_newest': obtain_summary.obtain_latest_release()
            })
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 10
0
def standard(request):
    try:
        parameters = request.GET
        full_path = request.get_full_path()
        username = request.COOKIES.get('username', '')
        ACCESS_LOGS.info('User='******' parameter=' + str(parameters) +
                         ' full_path=' + full_path)
        result = testname.get_testcases_relation('standard')
        ACCESS_LOGS.info(str(result))
        if 'SpecCPU' in result['standard']:
            result['standard']['SpecCPU'] = []
        standard_result = result['standard']
        sql = "select version from release_version"
        conn = obtain_summary.connect_database()
        cursor = conn.cursor()
        count = cursor.execute(sql)
        releases = []
        if count != 0:
            for result in cursor.fetchall():
                releases.append(result[0].upper())
        ACCESS_LOGS.info('release=' + str(releases))
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e

    try:
        release_newest = obtain_summary.obtain_latest_release()
        ACCESS_LOGS.info('release_newest=' + str(release_newest))
        response = render(
            request, 'spec/standard.html', {
                'standard_app': standard_result,
                'releases': releases,
                'username': username,
                'release_newest': release_newest
            })
        query_dict = {}
        for param in parameters:
            if param != 'app' or param != 'query_item':
                param_list = parameters.getlist(param, default=None)
                query_dict[param] = param_list
        response.set_cookie('filter_condition', query_dict, 300)

        if '?' in full_path:
            path = full_path.split('?')
            app = request.GET.get('app')
            response.set_cookie('copy_path', path[1], 300)
            response.set_cookie('app', app, 3000)
            ACCESS_LOGS.info('parameters=' + str(parameters) + 'query_dict=' +
                             str(query_dict) + 'path=' + str(path) + 'app=' +
                             app)
        return response
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 11
0
    def auth(self):
        l = ldap.initialize(self.ldap_Server)
        l.protocol_version = ldap.VERSION3
        try:
            l.simple_bind_s(self.ldap_Bind_Dn, self.ldap_Bind_Pd)
        except ldap.SERVER_DOWN as ex:
            ERROR_LOGS.error(ex)
            return None
        except ldap.INVALID_CREDENTIALS as ex:
            ERROR_LOGS.error(ex)
            return None
        except Exception as ex:
            ERROR_LOGS.error(ex)
            return None

        try:
            ldap_result_id = l.search(self.ldap_User_Dn, ldap.SCOPE_SUBTREE,
                                      '(sAMAccountName' + '=' + self.username+')', None)
            result_type, result_data = l.result(ldap_result_id, 1)
            if not len(result_data) == 0:
                r_a, r_b = result_data[0]
                dn = r_b["distinguishedName"][0]
                user_number = r_b["description"][0]
                user_name = r_b["name"][0]
                email = r_b["mail"][0]
                department = r_b["department"][0]
            else:
                return None
        except ldap.LDAPError as e:
            ERROR_LOGS.error(e)
            return None

        dn = str(dn, encoding="utf8")
        user_number = str(user_number, encoding="utf8")
        user_name = str(user_name, encoding="utf8")
        email = str(email, encoding="utf8")
        department = str(department, encoding="utf8")

        l2 = ldap.initialize(self.ldap_Server)
        result = l2.simple_bind_s(dn, self.password)

        if result[0] == 97:
            try:
                check_user.insert_role(user_number, user_name, email, department)
                ACCESS_LOGS.info('User:'******' Number:' + user_number + ' Login in PDP')
                # Insert_Role(user_number, user_name, email, department)
                return user_name, user_number
                # return self.username
            except Exception as e:
                ERROR_LOGS.error(e)
                return None
        else:
            return None
Ejemplo n.º 12
0
def add_filters(request):
    try:
        condition = request.GET.get('condition')
        app = request.COOKIES.get('app', '')
        filters = standard_filter.obtain_extra_box(app, condition)
        ACCESS_LOGS.info('app=' + app + 'condition' + str(condition) +
                         'filters=' + str(filters))
        return HttpResponse(json.dumps(filters),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 13
0
def modify_spec_comments(request):
    try:
        comment = {
            'comment_id': request.GET.get('comment_id'),
            'content': request.GET.get('content')
        }
        result = Comment.update_comment(comment)
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 14
0
def home_table(request):
    try:
        home_list = home_server.get_home_info()
        #home_list = sorted(home_list.items(), key=lambda x:x[0], reverse=True)
        result = []
        for list in home_list:
            result.append(home_list[list])
            #result.append(list[1])
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 15
0
def summary(request, name):
    try:
        username = request.COOKIES.get('username', '')
        response = render(
            request, 'summary.html', {
                'releases': obtain_summary.obtain_all_releases(),
                'username': username,
                'release_name': name,
                'release_newest': obtain_summary.obtain_latest_release()
            })
        return response
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 16
0
 def combine_release_hard_config(self, standard_hard_config):
     try:
         first = self.keys[0]
         result = self.data[first][standard_hard_config]
         for key in self.keys:
             if key == first:
                 continue
             temp = self.data[key][standard_hard_config]
             WARNING_LOGS.warning(' result=' + str(result) + ' standard_hard_config=' + str(temp))
             self.obtain_config(result, temp)
             WARNING_LOGS.warning(' result=' + str(result) + ' standard_hard_config=' + str(temp))
             self.count += 1
         self.count = 1
         return self.data[first][standard_hard_config]
     except Exception as e:
         ERROR_LOGS.error(e)
         raise e
Ejemplo n.º 17
0
def update_tune(request):
    try:
        ids = request.GET
        update_ids = {}
        result = {'flag': 'Update End!'}
        for id in ids:
            update_ids[id] = ids[id]
        standard_filter.update_tune_customization(update_ids)
        result = {'flag': 'Update End!'}
        ACCESS_LOGS.info('update_ids=' + str(update_ids))
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as err:
        result = {'flag': str(err)}
        ERROR_LOGS.error(err)
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
Ejemplo n.º 18
0
def spec_delete(request):
    try:
        release_ids_format = request.GET.get('delete_list')
        release_ids = release_ids_format.split('&')
        user = request.COOKIES.get('user_number', '')
        ACCESS_LOGS.info('user='******'release_ids' + str(release_ids) +
                         'release_ids_format=' + str(release_ids_format))
        release_ids.pop()
        if user == '1680505' or user == '1680342':
            result = delete_release.delete_by_release(release_ids)
        else:
            result = {'flag': "Failed: Permission denied"}
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 19
0
def insert_spec_comments(request):
    try:
        comment = {
            'username': request.COOKIES.get('username', ''),
            'testcase_exec_id': request.GET.get('comment_id'),
            'content': request.GET.get('content')
        }
        result = Comment.insert_comment(comment)
        ACCESS_LOGS.info(result)
        id_string = request.GET.get('standard_ids')
        standard_ids = id_string.split(',')
        print(standard_ids)
        print(Comment.get_comment(standard_ids))
        return HttpResponse(json.dumps(Comment.get_comment(standard_ids)),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 20
0
 def combine_release_data(self, standard_data_form):
     try:
         first = self.keys[0]
         result = self.data[first][standard_data_form]
         for key in self.keys:
             if key == first:
                 continue
             temp = self.data[key][standard_data_form]
             WARNING_LOGS.warning(' result=' + str(result) + ' temp=' + str(temp))
             self.dict_selected(result, temp)
             WARNING_LOGS.warning(' result=' + str(result) + ' temp=' + str(temp))
             self.count += 1
         self.count = 1
         WARNING_LOGS.warning(' standard_data_form=' + str(self.data[first][standard_data_form]))
         return self.data[first][standard_data_form]
     except Exception as e:
         ERROR_LOGS.error(e)
         raise e
Ejemplo n.º 21
0
def login(request):
    try:
        username = request.POST.get('username')
        password = request.POST.get('password')
        username, user_number = LdapAuth(username, password).auth()
        if username:
            request.session['username'] = username
            response = HttpResponseRedirect('/home')
            response.set_cookie('username', username, 3000)
            response.set_cookie('user_number', user_number, 3000)
            return response
        else:
            return render(request, 'login.html',
                          {'message': 'Wrong username or password'})
    except Exception as e:
        ERROR_LOGS.error(e)
        return render(request, 'login.html',
                      {'message': 'Wrong username or password'})
Ejemplo n.º 22
0
def snapshots(request):
    try:
        snapshots = request.POST.get('snapshots').split(',')
        filetype = request.POST.get('filetype')
        source = request.POST.get('source')
        app = request.COOKIES.get('app', '')
        ACCESS_LOGS.info(' app=' + app + ' snapshots' + str(snapshots) +
                         ' filetype=' + str(filetype))
        export = {}
        for snapshot in snapshots:
            item = request.POST.get(snapshot)
            if snapshot == 'system-setting':
                snapshot = 'tune'
            if item != 'data:,':
                image = item.replace('data:image/jpeg;base64,', '')
                try:
                    new_file = open(
                        os.path.join('static/file/snapshots/',
                                     snapshot + '.jpeg'), 'wb')
                    new_file.write(base64.b64decode(image))
                    new_file.close()
                except Exception as e:
                    ERROR_LOGS.error('Write file failed:' + e)

                way = 'static/file/snapshots/' + snapshot + '.jpeg'
                if snapshot in export:
                    export[snapshot].append(way)
                else:
                    try:
                        export[snapshot] = [way]
                    except Exception as e:
                        ERROR_LOGS.error(e)
            else:
                export[snapshot] = []

        if source == 'standard':
            export['testname'] = configuration.appname_reflect[app]
            export['version'] = 'hsrp'
            link = report.export_report(export, source)
        if source == 'summary':
            export['version'] = 'hsrp'
            hsrp = request.POST.get('hsrp')
            export['version'] = hsrp.replace('_', ' ')
            link = report.export_report(export, source)
        # image = "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABaAPoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dn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lLdSFAAz+VWKACviDx3/wAlD8S/9hW6/wDRrV9v18QeO/8AkofiX/sK3X/o1qAPr/wJ/wAk88Nf9gq1/wDRS10FfDkHjTxVa28Vvb+JdZhgiQJHHHfyqqKBgAANgADjFSf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/RXxB/wAJ34w/6GvXP/BjN/8AFUf8J34w/wChr1z/AMGM3/xVAH2/XxB47/5KH4l/7Ct1/wCjWo/4Tvxh/wBDXrn/AIMZv/iqw555rq4luLiWSaeVy8kkjFmdickknkknnNAH"
        # fh = open(os.path.join('static/file/snapshots/', 'chart.jpeg'), "wb")
        # fh.write(base64.b64decode(image))
        # fh.close()
        paths = link[filetype].split('/')
        filename = paths[len(paths) - 1]
        result = {'link': filename}
        ACCESS_LOGS.info(' filename=' + filename + ' paths' + str(paths) +
                         ' result=' + str(result))
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 23
0
def upload(request):
    try:
        files = request.FILES.getlist('filename')
        release = request.POST.get('release')
        name = request.COOKIES.get('user_number', '')
        tune = request.POST.get('tune')
        ACCESS_LOGS.info(' name=' + name + ' release' + str(release) +
                         ' tune=' + str(tune))
        filenames = {'csv': '', 'ini': '', '7z': ''}
        count = 0
        for file in files:
            if '.csv' in file.name:
                filenames['csv'] = 'static/file/upload/' + file.name
            elif '.ini' in file.name:
                filenames['ini'] = 'static/file/upload/' + file.name
            else:
                filenames['7z'] = 'static/file/upload/' + file.name
            count = count + 1
            try:
                new_file = open(os.path.join('static/file/upload/', file.name),
                                'wb')
                for chunk in file.chunks():
                    new_file.write(chunk)
                new_file.close()
            except Exception as e:
                ERROR_LOGS.error('Upload Exception:' + e)
                raise e
        result1 = import_standard_data.import_data(filenames['csv'],
                                                   filenames['ini'],
                                                   filenames['7z'], tune, name,
                                                   release)
        result1['message'] = 'Info: ' + str(result1['message'])
        return HttpResponse(json.dumps(result1),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 24
0
def query_release(request):
    try:
        releases = request.GET.getlist('release')
        ACCESS_LOGS.info(' result=' + str(releases))
        if len(releases):
            # summary_data = {
            #     'benchmark': {'items': [2]},
            #     'speccpu_2006': {'int': [1], 'float': [4]},
            #     'specjbb_2015': {'max-jobs': [3], 'critical-jobs': [5]},
            #     'lmbench': {'latency': [3]},
            # }
            # summary_soft_config = {
            #     'os': ['1.2.3'],
            #     'kernel': ['1.2.3.4'],
            #     'network': ['eth0,<speed>,<driver>,<vendor>,<Bus>;eth1,<speed>,<driver>,<vendor>,<Bus>'],
            # }
            # summary_hard_config = {
            #     'cpu': ['47'],
            #     'disk': ['sda,<size>,<type>,<interface>,<io_scheduler>,<vendor>;sdb,<size>,<type>,<interface>,<io_scheduler>,<vendor>']
            # }
            #
            # hsrp1 = {
            #     'summary_data': summary_data,
            #     'summary_soft_config': summary_soft_config,
            #     'summary_hard_config': summary_hard_config,
            #     'summary_title': 'HSRP1.1'
            # }
            #
            # summary_data1 = {
            #     # 'benchmark': {'items': [2]},
            #     'speccpu_2006': {'int': [1], 'float': [4]},
            #     'specjbb_2015': {'max-jobs': [3], 'critical-jobs': [5]},
            #     'lmbench': {'latency': [3]},
            #     'fio': {
            #         'SSD': {
            #             'sequency-read': [1],
            #             'sequency-write': [2],
            #             'random-read': [3],
            #             'random-write': [4],
            #         },
            #         'NVMe': {
            #             'sequency-read': [5],
            #             'sequency-write': [6],
            #             'random-read': [7],
            #             'random-write': [8],
            #         }
            #     }
            # }
            #
            # summary_soft_config1 = {
            #     'os': ['1.2.3'],
            #     'network': ['eth0,<speed>,<driver>,<vendor>,<Bus>'],
            #     'kernel': ['1.2.3.4']
            # }
            #
            # summary_hard_config1 = {
            #     'cpu': ['47'],
            #     'disk': ['sda,<size>,<type>,<interface>,<io_scheduler>,<vendor>']
            # }
            #
            # hsrp2 = {
            #     'summary_data': summary_data1,
            #     'summary_soft_config': summary_soft_config1,
            #     'summary_hard_config': summary_hard_config1,
            #     'summary_title': 'HSRP1.2'
            # }
            #
            # summary_data2 = {
            #     # 'benchmark': {'items': [2]},
            #     'specjbb_2015': {'max-jobs': [3], 'critical-jobs': [5]},
            #     'lmbench': {'latency': [3]},
            #     'fio': {
            #         'SSD': {
            #             'sequency-read': [1],
            #             'sequency-write': [2],
            #             'random-read': [3],
            #             'random-write': [4],
            #         },
            #         'NVMe': {
            #             'sequency-read': [5],
            #             'sequency-write': [6],
            #             'random-read': [7],
            #             'random-write': [8],
            #         }
            #     }
            # }
            #
            # summary_soft_config2 = {
            #     'os': ['1.2.3'],
            #     'network': ['eth0,<speed>,<driver>,<vendor>,<Bus>;eth1,<speed>,<driver>,<vendor>,<Bus>'],
            #     'kernel': ['1.2.3.4']
            # }
            #
            # summary_hard_config2 = {
            #     'cpu': ['47'],
            #     'disk': ['sda,<size>,<type>,<interface>,<io_scheduler>,<vendor>']
            # }
            #
            # hsrp3 = {
            #     'summary_data': summary_data2,
            #     'summary_soft_config': summary_soft_config2,
            #     'summary_hard_config': summary_hard_config2,
            #     'summary_title': 'HSRP1.3'
            # }
            #
            # summary = {
            #     'hsrp1': hsrp1,
            #     'hsrp2': hsrp2,
            #     'hsrp3': hsrp3
            # }
            summary = obtain_summary.obtain_summary(releases)
            summary_data = 'summary_data'
            summary_soft_config = 'summary_soft_config'
            summary_hard_config = 'summary_hard_config'
            summary_tune = 'summary_tune'
            keys = list(summary.keys())
            if len(keys):
                result = AutoGenTable(summary,
                                      keys).combine_release_data(summary_data)
                soft_config = AutoGenTable(
                    summary,
                    keys).combine_release_soft_config(summary_soft_config)
                hard_config = AutoGenTable(
                    summary,
                    keys).combine_release_hard_config(summary_hard_config)
                tune = AutoGenTable(summary,
                                    keys).combine_release_tune(summary_tune)

                last = {
                    'summary_data': result,
                    'summary_soft_config': soft_config,
                    'summary_hard_config': hard_config,
                    'summary_tune': tune,
                    'summary_title': keys
                }
            else:
                last = {'flag': False}
            ACCESS_LOGS.info(' last=' + str(last))
            return HttpResponse(json.dumps(last),
                                content_type="application/json")
        result = {'flag': False}
        ACCESS_LOGS.info(' result=' + str(result))
        return HttpResponse(json.dumps(result),
                            content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 25
0
def standard_query(request):
    try:
        global no_order
        release_ids = request.GET.getlist('query_item')
        app = request.COOKIES.get('app', '')
        filter_condition = eval(request.COOKIES.get('filter_condition', ''))
        ACCESS_LOGS.info('app=' + app + 'release_ids' + str(release_ids) +
                         'filter_condition=' + str(filter_condition))
        special_filter_condition = {}

        for key in list(eval(configuration.filter_condition_key)):
            if key in filter_condition:
                special_filter_condition[key] = filter_condition[key]
        if len(special_filter_condition) == 0:
            special_filter_condition = None

        data_no_deep = standard_filter.obtain_detail_data(
            release_ids, app, conditions_dict=special_filter_condition)
        data = copy.deepcopy(data_no_deep)
        ACCESS_LOGS.info('data=' + str(data))

        standard_title = 'standard_title'
        standard_data_figure = 'standard_data_figure'
        standard_data_form = 'standard_data_form'
        standard_soft_config = 'standard_soft_config'
        standard_hard_config = 'standard_hard_config'
        standard_tune = 'standard_tune'
        standard_tune_customization = 'standard_tune_customization'

        keys = list(data.keys())
        result = AutoGenTable(data_no_deep,
                              keys).combine_release_data(standard_data_form)
        ACCESS_LOGS.info('result=' + str(result))
        tmp_result = collections.OrderedDict()
        if app in ['lmbench-stream', 'lmbench-latency']:
            if app == 'lmbench-stream':
                for key in list(result.keys()):
                    tmp_result[key + '(MB/s)'] = copy.deepcopy(result[key])
            if app == 'lmbench-latency':
                for key in list(result.keys()):
                    tmp_result[key + '(ns)'] = copy.deepcopy(result[key])
            result = copy.deepcopy(tmp_result)
        result = {app: result}
        ACCESS_LOGS.info('result=' + str(result))
        soft_config = AutoGenTable(
            data_no_deep,
            keys).combine_release_soft_config(standard_soft_config)
        hard_config = AutoGenTable(
            data_no_deep,
            keys).combine_release_hard_config(standard_hard_config)
        tune = AutoGenTable(data_no_deep,
                            keys).combine_release_tune(standard_tune)
        ACCESS_LOGS.info('soft_config=' + str(soft_config))
        ACCESS_LOGS.info('hard_config=' + str(hard_config))
        ACCESS_LOGS.info('tune=' + str(tune))

        figure_data = collections.OrderedDict()
        titles = []
        customization = []
        dataset_ids = []
        app_dict = {
            'lmbench-stream': 'lmbench-stream(MB/s)',
            'lmbench-latency': 'lmbench-latency(ns)',
            'specjbb': 'specjbb'
        }
        for key in keys:
            dataset_ids.append(key)
            titles.append(data[key][standard_title])
            customization.append(
                data[key][standard_tune_customization]['Customization'][0])
            figure_data[key] = collections.OrderedDict()
            if app == 'specjbb' or app == 'lmbench-stream' or app == 'lmbench-latency':
                figure_data[key][
                    standard_data_figure] = collections.OrderedDict()
                figure_data[key][standard_data_figure][
                    app_dict[app]] = data[key][standard_data_figure]
            else:
                figure_data[key][standard_data_figure] = data[key][
                    standard_data_figure]
            figure_data[key][standard_title] = data[key][standard_title]
        figure = AutoGenEcharts(figure_data, standard_title,
                                standard_data_figure).combine_figure_data()
        ACCESS_LOGS.info('figure=' + str(figure))
        comments = Comment.get_comment(release_ids)
        print(comments)
        last = {
            'standard_data_form': result,
            'standard_data_figure': figure,
            'standard_soft_config': soft_config,
            'standard_hard_config': hard_config,
            'standard_tune': tune,
            'standard_title': titles,
            'standard_tune_customization': customization,
            'standard_ids': dataset_ids,
            'standard_comments': comments
        }
        ACCESS_LOGS.info('last=' + str(last))
        return HttpResponse(json.dumps(last), content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e
Ejemplo n.º 26
0
def standard_latest(request):
    try:
        app = request.COOKIES.get('app', '')
        data_no_deep = standard_filter.obtain_latest_data(app)
        ACCESS_LOGS.info('app=' + app + 'data_no_deep=' + str(data_no_deep))
        if data_no_deep == OrderedDict():
            return
        data = copy.deepcopy(data_no_deep)

        standard_title = 'standard_title'
        standard_data_figure = 'standard_data_figure'
        standard_data_form = 'standard_data_form'
        standard_soft_config = 'standard_soft_config'
        standard_hard_config = 'standard_hard_config'
        standard_tune = 'standard_tune'
        standard_tune_customization = 'standard_tune_customization'

        keys = list(data.keys())
        result = AutoGenTable(data_no_deep,
                              keys).combine_release_data(standard_data_form)
        ACCESS_LOGS.info('result=' + str(result))
        tmp_result = collections.OrderedDict()
        if app in ['lmbench-stream', 'lmbench-latency']:
            if app == 'lmbench-stream':
                for key in list(result.keys()):
                    tmp_result[key + '(MB/s)'] = copy.deepcopy(result[key])
            if app == 'lmbench-latency':
                for key in list(result.keys()):
                    tmp_result[key + '(ns)'] = copy.deepcopy(result[key])
            result = copy.deepcopy(tmp_result)
        result = {app: result}
        ACCESS_LOGS.info('result=' + str(result))

        soft_config = AutoGenTable(
            data_no_deep,
            keys).combine_release_soft_config(standard_soft_config)
        hard_config = AutoGenTable(
            data_no_deep,
            keys).combine_release_hard_config(standard_hard_config)
        tune = AutoGenTable(data_no_deep,
                            keys).combine_release_tune(standard_tune)
        ACCESS_LOGS.info('soft_config=' + str(soft_config))
        ACCESS_LOGS.info('hard_config=' + str(hard_config))
        ACCESS_LOGS.info('tune=' + str(tune))

        figure_data = collections.OrderedDict()
        titles = []
        customization = []
        dataset_ids = []
        release_id = []
        app_dict = {
            'lmbench-stream': 'lmbench-stream(MB/s)',
            'lmbench-latency': 'lmbench-latency(ns)',
            'specjbb': 'specjbb'
        }
        for key in keys:
            release_id.append(key)
            dataset_ids.append(key)
            titles.append(data[key][standard_title])
            customization.append(
                data[key][standard_tune_customization]['Customization'][0])
            figure_data[key] = collections.OrderedDict()
            if app in app_dict:
                figure_data[key][
                    standard_data_figure] = collections.OrderedDict()
                figure_data[key][standard_data_figure][
                    app_dict[app]] = data[key][standard_data_figure]
            else:
                figure_data[key][standard_data_figure] = data[key][
                    standard_data_figure]
            figure_data[key][standard_title] = data[key][standard_title]

        figure = AutoGenEcharts(figure_data, standard_title,
                                standard_data_figure).combine_figure_data()
        ACCESS_LOGS.info('figure=' + str(figure))

        comments = Comment.get_comment(release_id)

        last = {
            'standard_data_form': result,
            'standard_data_figure': figure,
            'standard_soft_config': soft_config,
            'standard_hard_config': hard_config,
            'standard_tune': tune,
            'standard_title': titles,
            'standard_tune_customization': customization,
            'standard_ids': dataset_ids,
            'standard_comments': comments
        }
        ACCESS_LOGS.info('last=' + str(last))
        return HttpResponse(json.dumps(last), content_type="application/json")
    except Exception as e:
        ERROR_LOGS.error(e)
        raise e