Beispiel #1
0
def genProjAlloc(tp_alloc_name,showprojectinfo=True):
    alloc_list = ProjectAllocation.objects.filter(top_level_allocation__name = tp_alloc_name).select_related(depth=1)
    prj_alloc_list = []
    for alloc in alloc_list:
        alloc_name = alloc.name
        attribute = {}
        attribute['NAME'] = alloc_name
        attribute['GROUP'] = str(alloc.group.name)
        project_name = alloc.project.name
        if showprojectinfo:
            attribute['PROJECT'] = genProject(project_name)
            attribute['PROJECT_ALLOCATION_METADATA']  = genProjectAllocMetaData(alloc_name)
        hepspec = alloc.hepspec
        tp_alloc_hepspec = alloc.top_level_allocation.hepspec
        hepspec_percent = str(getPercent(hepspec ,tp_alloc_hepspec ))
        attribute['KSI2K'] = str(getKSI2K(hepspec))
        attribute['HS06'] = str(hepspec)
        attribute['HS06PERCENT'] = str(hepspec_percent)
        attribute['MEMORY'] = str(alloc.memory)
        attribute['STORAGE'] = str(alloc.storage)
        attribute['BANDWIDTH'] = str(alloc.bandwidth)
        child = {'PROJECT_ALLOCATION':attribute}
        gp_alloc_list = genGroupAlloc(alloc_name) #get the group_allocation for this project_allocation
        attribute['GROUP_ALLOCATION_ALL'] = gp_alloc_list
        prj_alloc_list.append(child)      
    return prj_alloc_list 
Beispiel #2
0
def genGroupAlloc(alloc_name,top_group = True):
    if top_group:
        grpAllocObj_list = GroupAllocation.objects.filter(project_allocation__name = alloc_name).select_related('group')
    else:
        grpAllocObj_list = GroupAllocation.objects.filter(parent_group_allocation__name = alloc_name).select_related('group')
    grp_alloc_list = []
    for alloc in grpAllocObj_list:
        grpalloc_name = alloc.name
        hepspec = alloc.hepspec
        if top_group:
            parent_hepspec = alloc.project_allocation.hepspec
        else:
            parent_hepspec = alloc.parent_group_allocation.hepspec
        attribute  ={}
        attribute['NAME'] = grpalloc_name
        attribute['GROUP'] = str(alloc.group.name)
        attribute['KSI2K'] = str(getKSI2K(alloc.hepspec))
        attribute['HS06'] = str(alloc.hepspec)
        attribute['HS06PERCENT'] = str(getPercent(hepspec,parent_hepspec))
        attribute['MEMORY'] = str(alloc.memory)
        attribute['STORAGE'] = str(alloc.storage)
        attribute['BANDWIDTH'] = str(alloc.bandwidth)
        attribute['GROUP_ALLOCATION_METADATA'] = genGroupAllocMetaData(grpalloc_name)
        attribute['GROUP_ALLOCATION_ALL'] = genGroupAlloc(grpalloc_name,False)
        child = {'GROUP_ALLOCATION':attribute}
        grp_alloc_list.append(child)
    return grp_alloc_list