Пример #1
0
def registerRurallinkWirelessCard(session_id, host_asset_id, mac):
    """Called by pxe-scripts to register a new wireless card
    
    The card is also attached to the device that is used to PXE boot it
    """

    # Validate MAC address
    if not isValidMAC(mac):
        raise ccs_asset_error("Invalid MAC address!")

    try:
        asset = getAssetByMac(session_id, mac)
    except ccs_asset_error:
        # Asset does not exist
        asset = addRurallinkWirelessAsset(session_id, mac)

    # Check current location
    location = getAssetLocation(session_id, asset["asset_id"])
    if location["attached_to"] == host_asset_id:
        # Up to date
        return asset

    # Get an asset object and attach it to the host asset
    assetobj = ccs_asset(session_id, asset["asset_id"])
    assetobj.attachTo(host_asset_id)

    # Return the asset
    return asset
Пример #2
0
def setRurallinkDeviceConfig(session_id, asset_id, type):
    """Updates the device asset record to reflect the configuration type"""
    session = getSessionE(session_id)

    if asset_id == -1:
        # Called by a device itself, use the CN of the certificate to
        # lookup the mac address and find an asset ID
        mac = ":".join([session.username[(i * 2) - 2 : i * 2] for i in range(1, 7)])
        if not isValidMAC(mac):
            raise ccs_rurallink_error("Asset not specified!")
        asset = getAssetByMac(session_id, mac)
        asset_id = asset["asset_id"]

    asset = ccs_asset(session_id, asset_id)

    if type == "CPE":
        asset.updateAssetDetail("description", "RuralLink Farm Terminal")
    elif type == "Repeater":
        asset.updateAssetDetail("description", "RuralLink Farm Repeater")
    elif type == "Master":
        asset.updateAssetDetail("description", "Rurallink Farm AP (Master Node)")
    else:
        raise ccs_rurallink_error("Unknown configuration type!")

    return True
Пример #3
0
def registerRurallinkDevice(session_id, eth0mac):
    """Called by pxe-scripts to register a new rurallink device"""

    # Validate MAC address
    if not isValidMAC(eth0mac):
        raise ccs_asset_error("Invalid MAC address!")

    try:
        asset = getAssetByMac(session_id, eth0mac)
    except ccs_asset_error:
        # Asset does not exist
        asset = addRurallinkAsset(session_id, eth0mac)

    # Return the asset
    return asset