def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h = s.listHosts() for host in h: printDBG(2, "Examining host " + host['name']) host['errata_reboot_suggested'] = False errata = s.getHostErrata(str(host['id'])) if len(errata) == 0: pass else: printDBG(3, "Host has applicable errata.") listOfHosts[host['name']] = host listOfHosts[host['name']]['errata'] = {} for erratum in errata: if erratum['reboot_suggested']: printDBG( 3, "Host will require reboot after errata application") host['errata_reboot_suggested'] = host[ 'errata_reboot_suggested'] or erratum['reboot_suggested'] erratumID = erratum['errata_id'] if erratumID in listOfErrata: pass else: listOfErrata[erratumID] = erratum listOfHosts[host['name']]['errata'][erratumID] = erratum
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h = s.listHosts() for host in h: hostItem = {} hostItem['name'] = host['name'] hostItem['subs'] = [] subItems = s.getHostSubscriptions(str(host['id'])) if (type(None) == type(subItems)): continue for item in subItems: si = {} if ('name' not in item): continue if (item['name'] in ['EPEL', 'FPLInternal']): continue si['accountNum'] = item['account_number'] si['contractNum'] = item['contract_number'] si['endDate'] = item['end_date'] si['name'] = item['name'] hostItem['subs'].append(si) listOfHosts.append(hostItem)
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) printDBG(2, "Getting initial (baseline) content view version errata") cvve1 = s.getCVVerErrata(args.initial) baselineErrata = cvve1['total'] printDBG(2, "Getting target content view version errata") cvve2 = s.getCVVerErrata(args.final) targetErrata = cvve2['total'] list1 = [] for cve in cvve1['results']: list1.append(cve['id']) for cve in cvve2['results']: if cve['id'] not in list1: finalList.append(cve) if not len(finalList) == targetErrata - baselineErrata: printDBG( 1, "Errata mis-count - length not equal to difference in sizes!") printDBG(2, "Data gathered, differential list processed")
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) printDBG(2, "Getting all content view versions") cvvs = s.getCVVersions() for ver in cvvs['results']: name = ver['name'] cVVObjects[name] = {} object = cVVObjects[name] object['id'] = ver['id'] object['cvID'] = ver['content_view_id'] object['secErrata'] = ver['errata_counts']['security'] object['bugErrata'] = ver['errata_counts']['bugfix'] object['enhErrata'] = ver['errata_counts']['enhancement'] if type(object['secErrata']) == type(None): object['secErrata'] = 0 if type(object['bugErrata']) == type(None): object['bugErrata'] = 0 if type(object['enhErrata']) == type(None): object['enhErrata'] = 0 object['created'] = ver['created_at'] object['errata'] = {} printDBG(3, 'Getting errata for CV Ver ' + name) errata = s.getCVVerErrata(object['id']) for erratum in errata['results']: eo = {} eo['id'] = erratum['id'] eo['name'] = erratum['name'] eo['type'] = erratum['type'] eo['issued'] = erratum['issued'] eo['cves'] = [] for cve in erratum['cves']: eo['cves'].append(cve['cve_id']) object['errata'][erratum['errata_id']] = eo for revName in cVVObjects.keys().sort(reverse=True): print revName
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h=s.listHosts() for name in h: hostDetail = s.getHost(name['id']) pprint.pprint(hostDetail) sys.exit(0) if hostDetail['ip'] == None: continue if not hostObjects.has_key(hostDetail['name']): hostObjects[hostDetail['name']] = {} hostName = hostDetail['name'] printDBG(2, "Processing host %s" % (hostName,)) hostObjects[hostName]['ip'] = hostDetail['ip'] if hostDetail.has_key('content_facet_attributes'): hostObjects[hostName]['lifecycleEnvironment'] = hostDetail['content_facet_attributes']['lifecycle_environment_name'] hostObjects[hostName]['contentView'] = hostDetail['content_facet_attributes']['content_view_name'] hostObjects[hostName]['secErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['security']) hostObjects[hostName]['bugErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['bugfix']) hostObjects[hostName]['enhErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['enhancement']) hostObjects[hostName]['pkgUpdates'] = str(hostDetail['content_facet_attributes']['upgradable_package_count']) hostObjects[hostName]['lastCheckin'] = str(hostDetail['content_facet_attributes']['lastCheckin']) else: hostObjects[hostName]['lifecycleEnvironment'] = 'NO DATA' hostObjects[hostName]['contentView'] = 'NO DATA' hostObjects[hostName]['secErrata'] = 'NO DATA' hostObjects[hostName]['bugErrata'] = 'NO DATA' hostObjects[hostName]['enhErrata'] = 'NO DATA' hostObjects[hostName]['pkgUpdates'] = 'NO DATA' hostObjects[hostName]['katelloAgent'] = 'NO DATA' if hostDetail.has_key('subscription_status_label'): hostObjects[hostName]['subStatus'] = hostDetail['subscription_status_label'] else: hostObjects[hostName]['subStatus'] = 'NO DATA'
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) hcs = s.listHostCollections() for hc in hcs: printDBG(2, "Examining host collection " + hc['name']) hcInfo = s.getHostCollection(hc['id']) hcInfo['errata'] = {} hcInfo['errataRebootSuggested'] = False for hcID in hcInfo['host_ids']: printDBG(3, "Examining collection member host") errata = s.getHostErrata(str(hcID)) for erratum in errata: hcInfo['errataRebootSuggested'] = hcInfo[ 'errataRebootSuggested'] or erratum['reboot_suggested'] erratumID = erratum['errata_id'] if erratumID not in listOfErrata.keys(): listOfErrata[erratumID] = erratum if erratumID not in hcInfo['errata'].keys(): hcInfo['errata'][erratumID] = erratum if hcInfo['name'] not in listOfHostCollections.keys(): listOfHostCollections[hcInfo['name']] = hcInfo