Skip to content

Commit

Permalink
api: prefer profile directly over mapped one
Browse files Browse the repository at this point in the history
Within OpenWrt the profile does not always matches the `board_name`,
which is determined via device tree files. As a workaround ASU
automatically parsed the "supported" devices and mapped incomming
requests to profiles. In some rare cases (#319) the support profile is
actually a different profile than the one installed, in this case a
device that support images with and without nand storage.

To fix this, first check if a profile with the device tree model exists
(by replacing `,` with `_`) and only use the *supported mapping* if it
does not.

Fixes: #319

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Feb 28, 2022
1 parent 42c69bf commit b321575
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions asu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,25 @@ def validate_request(req):
current_app.logger.debug("Use generic profile for {req['target']}")
req["profile"] = "generic"
else:
mapped_profile = r.hget(
f"mapping-{req['branch']}-{req['version']}-{req['target']}",
req["profile"],
)

if mapped_profile:
req["profile"] = mapped_profile.decode()

current_app.logger.debug("Profile after mapping " + req["profile"])

if not r.sismember(
if r.sismember(
f"profiles-{req['branch']}-{req['version']}-{req['target']}",
req["profile"],
req["profile"].replace(",", "_"),
):
return (
{"detail": f"Unsupported profile: {req['profile']}", "status": 400},
400,
req["profile"] = req["profile"].replace(",", "_")
else:
mapped_profile = r.hget(
f"mapping-{req['branch']}-{req['version']}-{req['target']}",
req["profile"],
)

if mapped_profile:
req["profile"] = mapped_profile.decode()
else:
return (
{"detail": f"Unsupported profile: {req['profile']}", "status": 400},
400,
)

package_problems = validate_packages(req)
if package_problems:
return package_problems
Expand Down

0 comments on commit b321575

Please sign in to comment.