Beispiel #1
0
def main():
    sus_submission = {}
    sus_report = get_sus_install_report()

    sus_submission['facts'] = get_sus_facts()

    # Process managed items and update histories.
    sus_submission['managed_items'] = {}
    sus_submission['update_history'] = []

    for item in sus_report:
        name, version, date = item
        submission_item = {}
        submission_item['date_managed'] = date
        submission_item['status'] = 'PRESENT'
        submission_item['data'] = {
            'type': 'Apple SUS Install',
            'version': version
        }
        sus_submission['managed_items'][name] = submission_item

    pending = get_pending()
    sus_submission['managed_items'].update(pending)

    utils.set_checkin_results('Apple Software Update', sus_submission)
Beispiel #2
0
def main():
    machine_results = {'facts': {'checkin_module_version': __version__}}
    extras = {}
    extras['hostname'] = get_hostname()
    extras['os_family'] = 'Darwin'
    extras['console_user'] = get_console_user()[0]
    extras.update(process_system_profile())
    machine_results['extra_data'] = extras
    utils.set_checkin_results('Machine', machine_results)
Beispiel #3
0
def main():
    _, _, bu_key = utils.get_server_prefs()
    sal_submission = {
        'extra_data': {
            'sal_version': utils.sal_version(),
            'key': bu_key,
        },
        'facts': {
            'checkin_module_version': __version__
        }
    }
    utils.set_checkin_results('Sal', sal_submission)
Beispiel #4
0
def main():
    sus_submission = {}
    sus_submission['facts'] = get_sus_facts()

    # Process managed items and update histories.
    sus_submission['managed_items'] = get_sus_install_report()
    sus_submission['update_history'] = []

    pending = get_pending()
    sus_submission['managed_items'].update(pending)

    utils.set_checkin_results('Apple Software Update', sus_submission)
def main():
    results = {}
    if os.path.exists(PUPPET_LAST_RUN_SUMMARY):
        results["managed_items"] = get_puppet_state()
    results["facts"] = get_facter_report()
    utils.set_checkin_results("Puppet", results)
Beispiel #6
0
def main():
    # If we haven't successfully submitted to Sal, pull the existing
    # munki section rather than start from scratch, as we want to
    # keep any install/removal history that may be there.
    munki_submission = utils.get_checkin_results().get('munki', {})
    munki_report = get_managed_install_report()

    extras = {}
    extras['munki_version'] = munki_report['MachineInfo'].get('munki_version')
    extras['manifest'] = munki_report.get('ManifestName')
    extras['runtype'] = munki_report.get('RunType', 'custom')

    munki_submission['extra_data'] = extras

    munki_submission['facts'] = {
        'checkin_module_version': __version__,
        'RunType': munki_report['RunType'],
        'StartTime': munki_report['StartTime'],
        'EndTime': munki_report['EndTime'],
    }
    if munki_report.get('Conditions'):
        for condition, value in munki_report['Conditions'].items():
            # Join lists of strings into a comma-delimited string, as
            # the server wants just text.
            if hasattr(value, 'append'):
                value = ', '.join(value)
            munki_submission['facts'][condition] = value

    munki_submission['messages'] = []
    for key in ('Errors', 'Warnings'):
        for msg in munki_report[key]:
            # We need to drop the final 'S' to match Sal's message types.
            munki_submission['messages'].append({'message_type': key.upper()[:-1], 'text': msg})

    now = datetime.datetime.utcnow().isoformat() + 'Z'
    # Process managed items and update histories.
    munki_submission['managed_items'] = {}

    optional_manifest = get_optional_manifest()

    for item in munki_report.get('ManagedInstalls', []):
        submission_item = {'date_managed': now}
        submission_item['status'] = 'PRESENT' if item['installed'] else 'PENDING'

        version_key = 'version_to_install' if not item['installed'] else 'installed_version'
        version = item[version_key]
        name = '{} {}'.format(item['name'], version)
        submission_item['name'] = name

        # Pop off these two since we already used them.
        item.pop('name')
        item.pop('installed')

        item['type'] = 'ManagedInstalls'
        self_serve = 'True' if name in optional_manifest.get('managed_installs', []) else 'False'
        item['self_serve'] = self_serve
        submission_item['data'] = item
        munki_submission['managed_items'][name] = submission_item

    for item in munki_report.get('managed_uninstalls_list', []):
        submission_item = {'date_managed': now, 'status': 'ABSENT'}
        self_serve = 'True' if name in optional_manifest.get('managed_uninstalls', []) else 'False'
        submission_item['data'] = {'self_serve': self_serve, 'type': 'ManagedUninstalls'}
        munki_submission['managed_items'][item] = submission_item

    # Process InstallResults and RemovalResults into update history
    for report_key, result_type in (('InstallResults', 'PRESENT'), ('RemovalResults', 'ABSENT')):
        for item in munki_report.get(report_key, []):
            # Skip Apple software update items.
            if item.get('applesus'):
                continue
            history = {}
            # history = {'update_type': 'apple' if item.get('applesus') else 'third_party'}
            history['status'] = 'ERROR' if item.get('status') != 0 else result_type
            # Munki puts a UTC time in, but python drops the TZ info.
            # Convert to the expected submission format of ISO in UTC.
            history['date_managed'] = item['time'].isoformat() + 'Z'
            history['data'] = {'version': item.get('version', '0')}
            # Add over top of any pending items we may have already built.
            if item['name'] in munki_submission['managed_items']:
                munki_submission['managed_items'][item['name']].update(history)
            else:
                munki_submission['managed_items'][item['name']] = history

    utils.set_checkin_results('Munki', munki_submission)