def getPrimaryManifest(alternate_id):
    manifest = ""
    manifesturl = munkicommon.pref('ManifestURL') or \
                  munkicommon.pref('SoftwareRepoURL') + '/manifests/'
    if not manifesturl.endswith('?') and not manifesturl.endswith('/'):
        manifesturl = manifesturl + '/'
    munkicommon.display_debug2('Manifest base URL is: %s', manifesturl)

    clientidentifier = alternate_id or munkicommon.pref('ClientIdentifier')

    if not alternate_id and munkicommon.pref('UseClientCertificate') and \
        munkicommon.pref('UseClientCertificateCNAsClientIdentifier'):
        # we're to use the client cert CN as the clientidentifier
        if munkicommon.pref('UseClientCertificate'):
            # find the client cert
            client_cert_path = munkicommon.pref('ClientCertificatePath')
            if not client_cert_path:
                ManagedInstallDir = munkicommon.pref('ManagedInstallDir')
                for name in ['cert.pem', 'client.pem', 'munki.pem']:
                    client_cert_path = os.path.join(ManagedInstallDir,
                                                    'certs', name)
                    if os.path.exists(client_cert_path):
                        break
            if client_cert_path and os.path.exists(client_cert_path):
                fileobj = open(client_cert_path)
                data = fileobj.read()
                fileobj.close()
                x509 = load_certificate(FILETYPE_PEM, data)
                clientidentifier = x509.get_subject().commonName

    try:
        if not clientidentifier:
            # no client identifier specified, so use the hostname
            hostname = os.uname()[1]
            # there shouldn't be any characters in a hostname that need quoting,
            # but see https://code.google.com/p/munki/issues/detail?id=276
            clientidentifier = urllib2.quote(hostname)
            munkicommon.display_detail(
                'No client id specified. Requesting %s...', clientidentifier)
            manifest = getmanifest(
                manifesturl + clientidentifier, suppress_errors=True)
            if not manifest:
                # try the short hostname
                clientidentifier = urllib2.quote(hostname.split('.')[0])
                munkicommon.display_detail(
                    'Request failed. Trying %s...', clientidentifier)
                manifest = getmanifest(
                    manifesturl + clientidentifier, suppress_errors=True)
            if not manifest:
                # try the machine serial number
                clientidentifier = MACHINE['serial_number']
                if clientidentifier != 'UNKNOWN':
                    munkicommon.display_detail(
                        'Request failed. Trying %s...', clientidentifier)
                    manifest = getmanifest(
                        manifesturl + clientidentifier, suppress_errors=True)
            if not manifest:
                # last resort - try for the site_default manifest
                clientidentifier = 'site_default'
                munkicommon.display_detail(
                    'Request failed. Trying %s...', clientidentifier)

        if not manifest:
            manifest = getmanifest(
                manifesturl + urllib2.quote(clientidentifier.encode('UTF-8')))
        if manifest:
            # record this info for later
            munkicommon.report['ManifestName'] = clientidentifier
            munkicommon.display_detail('Using manifest: %s', clientidentifier)
    except ManifestException:
        # bad manifests throw an exception
        pass
    return manifest
finds the set that an object is in
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/getPrimaryManifest--crossover with--dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/moBu/core/moBuSets.py/MoBuSets.findSetFromObject