def filesToCopy(sdFiles, agsServices, copyItemIDs=None):

    # The service definition files that should be copied are those
    # that exist for each existing ArcGIS Server serice.
    sdFilesToCopy = {}
    for i in agsServices:
        serviceInfo = agsServices[i]
        portalItemsJson = serviceInfo['portalProperties']['portalItems']
        if i in sdFiles:
            if copyItemIDs:
                if portalItemsJson:
                    for portalItemJson in portalItemsJson:
                        itemID = portalItemJson['itemID']
                        if itemID in copyItemIDs:
                            sdFilesToCopy[i] = sdFiles[i]
            else:
                sdFilesToCopy[i] = sdFiles[i]
    
    if debug:
        print '\nwithin filesToCopy function:'
        print 'sdFilesToCopy variable...'
        for key, value in sdFilesToCopy.iteritems():
            print str(key) + ' = ' + str(value)
    
    return sdFilesToCopy
Return collection of service definition files to copy
dataset/ETHPy150Open Esri/ops-server-config/SupportFiles/GetSDFiles.py/filesToCopy