Esempio n. 1
0
def device_inventory(device_id: int):
    """Enqueue ALL inventory commands to refresh the device's entire inventory.
    
    :statuscode 200: OK
    """
    d = db.session.query(Device).filter(Device.id == device_id).one()

    # DeviceInformation
    di = commands.DeviceInformation.for_platform(d.platform, d.os_version)
    db_command = Command.from_model(di)
    db_command.device = d
    db.session.add(db_command)

    # InstalledApplicationList - Pretty taxing so don't run often
    # ial = commands.InstalledApplicationList()
    # db_command_ial = Command.from_model(ial)
    # db_command_ial.device = d
    # db.session.add(db_command_ial)

    # CertificateList
    cl = commands.CertificateList()
    dbc = Command.from_model(cl)
    dbc.device = d
    db.session.add(dbc)

    # SecurityInfo
    si = commands.SecurityInfo()
    dbsi = Command.from_model(si)
    dbsi.device = d
    db.session.add(dbsi)

    # ProfileList
    pl = commands.ProfileList()
    db_pl = Command.from_model(pl)
    db_pl.device = d
    db.session.add(db_pl)

    # AvailableOSUpdates
    au = commands.AvailableOSUpdates()
    au_pl = Command.from_model(au)
    au_pl.device = d
    db.session.add(au_pl)

    mal = commands.ManagedApplicationList()
    mal_pl = Command.from_model(mal)
    mal_pl.device = d
    db.session.add(mal_pl)

    db.session.commit()

    return 'OK'
Esempio n. 2
0
def device_inventory(device_id: int):
    """Tell a device to produce a full inventory immediately.
    
    This is mostly for testing right now.
    
    :statuscode 200: OK
    """
    d = db.session.query(Device).filter(Device.id == device_id).one()

    # DeviceInformation
    di = commands.DeviceInformation.for_platform(d.platform, d.os_version)
    db_command = Command.from_model(di)
    db_command.device = d
    db.session.add(db_command)

    # InstalledApplicationList - Pretty taxing so don't run often
    ial = commands.InstalledApplicationList()
    db_command_ial = Command.from_model(ial)
    db_command_ial.device = d
    db.session.add(db_command_ial)

    # CertificateList
    cl = commands.CertificateList()
    dbc = Command.from_model(cl)
    dbc.device = d
    db.session.add(dbc)

    # SecurityInfo
    si = commands.SecurityInfo()
    dbsi = Command.from_model(si)
    dbsi.device = d
    db.session.add(dbsi)

    # ProfileList
    pl = commands.ProfileList()
    db_pl = Command.from_model(pl)
    db_pl.device = d
    db.session.add(db_pl)

    # AvailableOSUpdates
    au = commands.AvailableOSUpdates()
    au_pl = Command.from_model(au)
    au_pl.device = d
    db.session.add(au_pl)

    db.session.commit()

    return 'OK'
Esempio n. 3
0
def queue_full_inventory(device: Device):
    """Enqueue all inventory commands for a device.

    Typically run at first check-in

    Args:
          device (Device): The device
    """
    # DeviceInformation
    di = commands.DeviceInformation.for_platform(device.platform,
                                                 device.os_version)
    db_command = Command.from_model(di)
    db_command.device = device
    db.session.add(db_command)

    # InstalledApplicationList - Pretty taxing so don't run often
    ial = commands.InstalledApplicationList()
    db_command_ial = Command.from_model(ial)
    db_command_ial.device = device
    db.session.add(db_command_ial)

    # CertificateList
    cl = commands.CertificateList()
    dbc = Command.from_model(cl)
    dbc.device = device
    db.session.add(dbc)

    # SecurityInfo
    si = commands.SecurityInfo()
    dbsi = Command.from_model(si)
    dbsi.device = device
    db.session.add(dbsi)

    # ProfileList
    pl = commands.ProfileList()
    db_pl = Command.from_model(pl)
    db_pl.device = device
    db.session.add(db_pl)

    # AvailableOSUpdates
    au = commands.AvailableOSUpdates()
    au_pl = Command.from_model(au)
    au_pl.device = device
    db.session.add(au_pl)

    db.session.commit()