示例#1
0
def get_drivers():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_release = parameters.get_single_parameter({}, 'release_id')

    return get_drivers_internal(project_id=selected_project_id,
                                vendor=selected_vendor,
                                release_id=selected_release)
示例#2
0
def get_drivers():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_release = parameters.get_single_parameter({}, 'release_id')

    return get_drivers_internal(project_id=selected_project_id,
                                vendor=selected_vendor,
                                release_id=selected_release)
示例#3
0
def summary():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_level_id = parameters.get_single_parameter({}, 'level_id')

    drivers = api.get_drivers_internal(project_id=selected_project_id,
                                       vendor=selected_vendor,
                                       level_id=selected_level_id)
    vendors = set()
    levels_id = set()
    projects_id = set()

    for driver in api.get_drivers_internal(project_id=selected_project_id,
                                           level_id=selected_level_id):
        vendors.add(driver['vendor'])

    for driver in api.get_drivers_internal(project_id=selected_project_id,
                                           vendor=selected_vendor):
        levels_id.add(driver['level_id'])

    for driver in api.get_drivers_internal(vendor=selected_vendor,
                                           level_id=selected_level_id):
        projects_id.add(driver['project_id'])

    projects_map = vault.get_vault()['projects_map']
    projects = [{
        'project_id': project_id,
        'project_name': projects_map[project_id]['name']
    } for project_id in projects_id]

    levels_map = vault.get_vault()['levels_map']
    levels = [{
        'level_id': level_id,
        'level_name': levels_map[level_id]['level_name']
    } for level_id in levels_id]

    if selected_project_id not in projects_map:
        selected_project_id = None

    if selected_vendor not in vendors:
        selected_vendor = None

    if selected_level_id not in levels_map:
        selected_level_id = None

    return {
        'drivers': drivers,
        'vendors': sorted(vendors),
        'levels': sorted(levels, key=lambda x: x['level_name']),
        'projects': sorted(projects, key=lambda x: x['project_name']),
        'project_id': selected_project_id,
        'vendor': selected_vendor,
        'level_id': selected_level_id,
    }
示例#4
0
文件: web.py 项目: Mirantis/oscp
def summary():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_level_id = parameters.get_single_parameter({}, 'level_id')

    drivers = api.get_drivers_internal(project_id=selected_project_id,
                                       vendor=selected_vendor,
                                       level_id=selected_level_id)
    vendors = set()
    levels_id = set()
    projects_id = set()

    for driver in api.get_drivers_internal(project_id=selected_project_id,
                                           level_id=selected_level_id):
        vendors.add(driver['vendor'])

    for driver in api.get_drivers_internal(project_id=selected_project_id,
                                           vendor=selected_vendor):
        levels_id.add(driver['level_id'])

    for driver in api.get_drivers_internal(vendor=selected_vendor,
                                           level_id=selected_level_id):
        projects_id.add(driver['project_id'])

    projects_map = vault.get_vault()['projects_map']
    projects = [{'project_id': project_id,
                 'project_name': projects_map[project_id]['name']}
                for project_id in projects_id]

    levels_map = vault.get_vault()['levels_map']
    levels = [{'level_id': level_id,
               'level_name': levels_map[level_id]['level_name']}
              for level_id in levels_id]

    if selected_project_id not in projects_map:
        selected_project_id = None

    if selected_vendor not in vendors:
        selected_vendor = None

    if selected_level_id not in levels_map:
        selected_level_id = None

    return {
        'drivers': drivers,
        'vendors': sorted(vendors),
        'levels': sorted(levels, key=lambda x: x['level_name']),
        'projects': sorted(projects, key=lambda x: x['project_name']),
        'project_id': selected_project_id,
        'vendor': selected_vendor,
        'level_id': selected_level_id,
    }
示例#5
0
def get_vendors():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_release_id = parameters.get_single_parameter({}, 'release_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    vendors = set()
    for driver in get_drivers_internal(project_id=selected_project_id,
                                       release_id=selected_release_id):
        if driver['vendor'].lower().find(query) >= 0:
            vendors.add(driver['vendor'])

    vendors = [{'id': vendor, 'text': vendor} for vendor in vendors]
    return sorted(vendors, key=lambda x: x['text'])
示例#6
0
def get_vendors():
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    selected_release_id = parameters.get_single_parameter({}, 'release_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    vendors = set()
    for driver in get_drivers_internal(project_id=selected_project_id,
                                       release_id=selected_release_id):
        if driver['vendor'].lower().find(query) >= 0:
            vendors.add(driver['vendor'])

    vendors = [{'id': vendor, 'text': vendor} for vendor in vendors]
    return sorted(vendors, key=lambda x: x['text'])
示例#7
0
def get_releases():
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    releases = set()
    for driver in get_drivers_internal(vendor=selected_vendor,
                                       project_id=selected_project_id):
        for release in driver['releases_info']:
            if release['name'].lower().find(query) >= 0:
                releases.add(release['name'])

    releases = [{'id': release.lower(), 'text': release.capitalize()}
                for release in releases]

    return sorted(releases, key=lambda x: x['text'], reverse=True)
示例#8
0
def get_project_ids():
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_release_id = parameters.get_single_parameter({}, 'release_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    projects_map = vault.get_vault()['projects_map']
    project_ids = set()
    for driver in get_drivers_internal(vendor=selected_vendor,
                                       release_id=selected_release_id):
        if projects_map[driver['project_id']]['name'].lower().find(query) >= 0:
            project_ids.add(driver['project_id'])

    projects = [{'id': project_id,
                 'text': projects_map[project_id]['name']}
                for project_id in project_ids]

    return sorted(projects, key=lambda x: x['text'])
示例#9
0
def _get_time_filter(kwargs):
    start_date = parameters.get_single_parameter(kwargs, 'start_date')
    if start_date:
        start_date = utils.date_to_timestamp_ext(start_date)
    else:
        start_date = 0
    end_date = parameters.get_single_parameter(kwargs, 'end_date')
    if end_date:
        end_date = utils.date_to_timestamp_ext(end_date)
    else:
        end_date = utils.date_to_timestamp_ext('now')

    def time_filter(records):
        for record in records:
            if start_date <= record['date'] <= end_date:
                yield record

    return time_filter
示例#10
0
def get_project_ids():
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_release_id = parameters.get_single_parameter({}, 'release_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    projects_map = vault.get_vault()['projects_map']
    project_ids = set()
    for driver in get_drivers_internal(vendor=selected_vendor,
                                       release_id=selected_release_id):
        if projects_map[driver['project_id']]['name'].lower().find(query) >= 0:
            project_ids.add(driver['project_id'])

    projects = [{
        'id': project_id,
        'text': projects_map[project_id]['name']
    } for project_id in project_ids]

    return sorted(projects, key=lambda x: x['text'])
示例#11
0
def get_releases():
    selected_vendor = parameters.get_single_parameter({}, 'vendor')
    selected_project_id = parameters.get_single_parameter({}, 'project_id')
    query = (parameters.get_single_parameter({}, 'query') or '').lower()

    releases = set()
    for driver in get_drivers_internal(vendor=selected_vendor,
                                       project_id=selected_project_id):
        for release in driver['releases_info']:
            if release['name'].lower().find(query) >= 0:
                releases.add(release['name'])

    releases = [{
        'id': release.lower(),
        'text': release.capitalize()
    } for release in releases]

    return sorted(releases, key=lambda x: x['text'], reverse=True)
示例#12
0
def _get_time_filter(kwargs):
    start_date = parameters.get_single_parameter(kwargs, 'start_date')
    if start_date:
        start_date = utils.date_to_timestamp_ext(start_date)
    else:
        start_date = 0
    end_date = parameters.get_single_parameter(kwargs, 'end_date')
    if end_date:
        end_date = utils.date_to_timestamp_ext(end_date)
    else:
        end_date = utils.date_to_timestamp_ext('now')

    def time_filter(records):
        for record in records:
            if start_date <= record['date'] <= end_date:
                yield record

    return time_filter