Exemplo n.º 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 
Exemplo n.º 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
Exemplo n.º 3
0
def genZoneAlloc(tp_alloc_name):
    node = [] 
    allocZonesInfo = TopLevelAllocationByZone.objects.filter(top_level_allocation__name__iexact = tp_alloc_name).order_by('zone__name')
    for oneZone in allocZonesInfo:
        attribute = {}
        attribute['NAME'] = str(oneZone.zone.name)
        hs06 = oneZone.hepspec
        attribute['HS06'] = str(hs06)
        attribute['KSI2K'] = str(getKSI2K(hs06))
        attribute['MEMORY'] = str(oneZone.memory)
        attribute['STORAGE'] = str(oneZone.storage)
        attribute['BANDWIDTH'] = str(oneZone.bandwidth)
        attribute['REGION'] = str(oneZone.zone.region.name)
        child = {'ZONE':attribute}
        node.append(child)
    return node
Exemplo n.º 4
0
def genTopAlloc():
    node_list = []
    tpAllocList = TopLevelAllocation.objects.select_related(depth=1)
    for alloc in tpAllocList:
        tp_alloc_name =  alloc.name
        attribute = {}
        attribute['NAME'] = tp_alloc_name
        attribute['GROUP'] = str(alloc.group.name)
        attribute['KSI2K'] = str(getKSI2K(alloc.hepspec))
        attribute['HS06'] = str(alloc.hepspec)
        attribute['MEMORY'] = str(alloc.memory)
        attribute['STORAGE'] = str(alloc.storage)
        attribute['BANDWIDTH'] = str(alloc.bandwidth)
        zone_alloc = genZoneAlloc(tp_alloc_name)
        attribute['ZONE_ALLOCATION'] = zone_alloc
        resource_type = genAllowedResourceType(tp_alloc_name)
        attribute['ALLOWED_RESOURCE_TYPE'] = resource_type
        proj_alloc = genProjAlloc(tp_alloc_name)
        attribute['PROJECT_ALLOCATION_ALL'] = proj_alloc 
        child = {'TOP_LEVEL_ALLOCATION':attribute}
        node_list.append(child)
    return node_list