예제 #1
0
def perform_update(params):
    user = kerbparse.get_kerberos()
    device = db.get_device_latest(params["id"])
    if not can_edit(user, device):
        raise Exception("no access")
    rack = db.get_rack(params["rack"])
    first, last = int(params["first"]), int(params["last"])
    assert 1 <= first <= last <= rack.height
    if not moira.is_email_valid_for_owner(params["owner"]):
        raise Exception("bad owner")
    ndevice = db.DeviceUpdates(
        id=device.id,
        name=params["devicename"],
        rack=params["rack"],
        rack_first_slot=first,
        rack_last_slot=last,
        ip=params.get("ip", ""),
        contact=params["contact"],
        owner=params["owner"],
        service_level=params.get("service", ""),
        model=params.get("model", ""),
        notes=params.get("notes", ""),
        last_updated_by=user,
    )
    db.add(ndevice)
    db.session.commit()
    send_notification(True, ndevice, user)
    print("Content-type: text/html\n")
    print(jenv.get_template("done.html").render(id=device.id).encode("utf-8"))
예제 #2
0
def perform_update_stock(params):
    user = kerbparse.get_kerberos()
    if not is_hwop(user):
        raise Exception("no access")
    update = db.Inventory(sku=params["sku"],
                          new_count=int(params["count"]),
                          comment=params.get("comment", ""),
                          submitted_by=user)
    db.add(update)
    print("Content-type: text/html\n")
    print(
        jenv.get_template("done-part.html").render(
            sku=update.sku).encode("utf-8"))
예제 #3
0
def perform_add_part(params):
    user = kerbparse.get_kerberos()
    if not is_hwop(user):
        raise Exception("no access")
    part = db.Parts(sku=params["sku"],
                    description=params.get("description", ''),
                    notes=params.get("notes", ""),
                    last_updated_by=user)
    db.add(part)
    print("Content-type: text/html\n")
    print(
        jenv.get_template("done-part.html").render(
            sku=part.sku).encode("utf-8"))
예제 #4
0
def get_auth():
    user = kerbparse.get_kerberos()
    return user, get_base_url(
        authenticate=not user) + os.environ["REQUEST_URI"]