How to use the patchman.arch.models.MachineArchitecture.objects function in patchman

To help you get started, we’ve selected a few patchman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github furlongm / patchman / patchman / reports / models.py View on Github external
def process(self):
        if self.os and self.kernel and self.arch:
            os, c = OS.objects.get_or_create(name=self.os)
            arch, c = MachineArchitecture.objects.get_or_create(name=self.arch)

            if not self.domain:
                self.domain = 'unknown'

            domain, c = Domain.objects.get_or_create(name=self.domain)

            if not self.host:
                try:
                    self.host = str(gethostbyaddr(self.report_ip)[0])
                except:
                    self.host = self.report_ip

            host, c = Host.objects.get_or_create(
                hostname=self.host,
                defaults={
                    'ipaddress': self.report_ip,
github furlongm / patchman / sbin / patchman.py View on Github external
"""

    parches = PackageArchitecture.objects.filter(package__isnull=True)
    plen = parches.count()

    if plen == 0:
        if verbose:
            print 'No orphaned package architectures found.'
    else:
        create_pbar('Removing {0!s} orphaned p arches:'.format(plen), plen)
        for i, p in enumerate(parches):
            a = PackageArchitecture.objects.get(name=p.name)
            a.delete()
            update_pbar(i + 1)

    marches = MachineArchitecture.objects.filter(host__isnull=True,
                                                 repository__isnull=True)
    mlen = marches.count()

    if mlen == 0:
        if verbose:
            print 'No orphaned machine architectures found.'
    else:
        create_pbar('Removing {0!s} orphaned m arches:'.format(mlen), mlen)
        for i, m in enumerate(marches):
            a = MachineArchitecture.objects.get(name=m.name)
            a.delete()
            update_pbar(i + 1)
github furlongm / patchman / scripts / import-pakiti2-data.py View on Github external
def import_arch(conn):

    cursor = conn.cursor(MySQLdb.cursors.DictCursor)

    cursor.execute('SELECT * FROM arch')
    rows = cursor.fetchall()

    plength = len(rows)
    pbar = progress_bar('Machine Architectures', plength)
    i = 0

    for row in rows:
        pbar.update(i+1)
        i += 1 
        try:
            arch, c = MachineArchitecture.objects.get_or_create(id=row['id'], name=row['arch'])
        except(IntegrityError):
            print "IntegrityError"
            continue

    cursor.close()

    cursor = conn.cursor(MySQLdb.cursors.DictCursor)

    cursor.execute('SELECT DISTINCT arch FROM act_version')
    rows = cursor.fetchall()

    plength = len(rows)
    pbar = progress_bar('Package Architectures', plength)
    i = 0

    for row in rows: