示例#1
0
        item["uw_tag"] = segments[5]
        item["os"] = segments[2]
        item["type"] = segments[1]
        item["mac"] = get_mac(segments[3])
        item["mac2"] = get_mac(segments[4])

        it = InventoryType.objects.filter(name="Machine")
        type = Type.objects.filter(name=item["type"])
        platform = Platform.objects.filter(name=item["os"])

        type = Type.objects.filter(name=item["type"] + " " + item["os"])

        if type.count() < 1:
            platform = Platform.objects.filter(name=item["os"])
            if platform.count() < 1:
                platform = Platform(name=item["os"], description=item["os"])
                platform.save()
            else:
                platform = platform.get(name=item["os"])

            type = Type(
                name=item["type"] + " " + item["os"], platform=platform, model_name=item["type"], specs="Unknown"
            )
            type.save()
        else:
            type = type.get(name=item["type"] + " " + item["os"])

        if it.count() < 1:
            it = InventoryType(name="Machine", namespace="Machine", description="Computers and Workstations")
            it.save()
        else:
示例#2
0
if not sys.argv[1]:
    print "Argument: file containing machine data to load into LabTracker."
    sys.exit(1)

file = open(sys.argv[1], "r")

if not file:
    print "Error: file could not be opened."
    sys.exit(1)

it = InventoryType.objects.filter(name="Machine")
type = Type.objects.filter(name="Unknown")
platform = Platform.objects.filter(name="Unknown")

if platform.count() < 1:
    platform = Platform(name="Unknown", description="Unknown platform type")
    platform.save()
else:
    platform = platform.get(name="Unknown")

if type.count() < 1:
    type = Type(name="Unknown", platform=platform, model_name="Unknown", specs="Unknown")
    type.save()
else:
    type = type.get(name="Unknown")

if it.count() < 1:
    it = InventoryType(name="Machine", namespace="Machine", description="Computers and Workstations")
    it.save()
else:
    it = it.get(name="Machine")