Skip to content

Commit

Permalink
Rename firmware to software
Browse files Browse the repository at this point in the history
Software is the more generic term. Also gooseBit works in
combination with SWUpdate - which has "software" in its name.

Issue: #74
  • Loading branch information
tsagadar committed Aug 26, 2024
1 parent f7be618 commit ea0c0e6
Show file tree
Hide file tree
Showing 44 changed files with 373 additions and 373 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The default login credentials for testing are `[email protected]`, `admin`.

## Current Feature Set

### Firmware repository
### Software repository

Uploading firmware images through frontend. All files should follow the format `{model}_{revision}_{version}`, where
Uploading software images through frontend. All files should follow the format `{model}_{revision}_{version}`, where
`version` is either a semantic version or a datetime version in the format `YYYYMMDD-HHmmSS`.

### Automatic device registration
Expand All @@ -32,25 +32,25 @@ First time a new device connects, its configuration data is requested. `hw_model
the configuration data (both fall back to `default` if not provided) which allows to distinguish different device
types and their revisions.

### Automatically update device to newest firmware
### Automatically update device to newest software

Once a device is registered it will get the newest available firmware from the repository based on model and revision.
Once a device is registered it will get the newest available software from the repository based on model and revision.

### Manually update device to specific firmware
### Manually update device to specific software

Frontend allows to assign specific firmware to be rolled out.
Frontend allows to assign specific software to be rolled out.

### Firmware rollout
### Software rollout

Rollouts allow a fine-grained assignment of firmwares to devices. The reported device model and revision is combined
Rollouts allow a fine-grained assignment of software to devices. The reported device model and revision is combined
with the manually set feed value on a device to determine a matching rollout.

The feed is meant to model either different environments (like: dev, qa, live) or update channels (like. candidate,
fast, stable).

### Pause updates

Device can be pinned to its current firmware.
Device can be pinned to its current software.

### Realtime update logs

Expand Down
24 changes: 12 additions & 12 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def db():

@pytest_asyncio.fixture(scope="function")
async def test_data(db):
from goosebit.models import Device, Firmware, Hardware, Rollout
from goosebit.models import Device, Hardware, Rollout, Software

# Create a temporary directory
with tempfile.TemporaryDirectory() as temp_dir:
Expand All @@ -79,41 +79,41 @@ async def test_data(db):
hardware=compatibility,
)

temp_file_path = os.path.join(temp_dir, "firmware")
temp_file_path = os.path.join(temp_dir, "software")
with open(temp_file_path, "w") as temp_file:
temp_file.write("Fake SWUpdate image")
uri = Path(temp_file_path).as_uri()

firmware_beta = await Firmware.create(
software_beta = await Software.create(
version="1.0.0-beta2+build20",
hash="dummy2",
size=800,
uri=uri,
)
await firmware_beta.compatibility.add(compatibility)
await software_beta.compatibility.add(compatibility)

firmware_release = await Firmware.create(
software_release = await Software.create(
version="1.0.0",
hash="dummy",
size=1200,
uri=uri,
)
await firmware_release.compatibility.add(compatibility)
await software_release.compatibility.add(compatibility)

firmware_rc = await Firmware.create(
software_rc = await Software.create(
version="1.0.0-rc2+build77",
hash="dummy2",
size=800,
uri=uri,
)
await firmware_rc.compatibility.add(compatibility)
await software_rc.compatibility.add(compatibility)

rollout_default = await Rollout.create(firmware_id=firmware_release.id)
rollout_default = await Rollout.create(software_id=software_release.id)

yield dict(
device_rollout=device_rollout,
firmware_release=firmware_release,
firmware_rc=firmware_rc,
firmware_beta=firmware_beta,
software_release=software_release,
software_rc=software_rc,
software_beta=software_beta,
rollout_default=rollout_default,
)
18 changes: 9 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The default login credentials for testing are `[email protected]`, `admin`.

## Current Feature Set

### Firmware repository
### Software repository

Uploading firmware images through frontend. All files should follow the format `{model}_{revision}_{version}`, where
Uploading software images through frontend. All files should follow the format `{model}_{revision}_{version}`, where
`version` is either a semantic version or a datetime version in the format `YYYYMMDD-HHmmSS`.

### Automatic device registration
Expand All @@ -32,25 +32,25 @@ First time a new device connects, its configuration data is requested. `hw_model
the configuration data (both fall back to `default` if not provided) which allows to distinguish different device
types and their revisions.

### Automatically update device to newest firmware
### Automatically update device to newest software

Once a device is registered it will get the newest available firmware from the repository based on model and revision.
Once a device is registered it will get the newest available software from the repository based on model and revision.

### Manually update device to specific firmware
### Manually update device to specific software

Frontend allows to assign specific firmware to be rolled out.
Frontend allows to assign specific software to be rolled out.

### Firmware rollout
### Software rollout

Rollouts allow a fine-grained assignment of firmwares to devices. The reported device model and revision is combined
Rollouts allow a fine-grained assignment of software to devices. The reported device model and revision is combined
with the manually set feed value on a device to determine a matching rollout.

The feed is meant to model either different environments (like: dev, qa, live) or update channels (like. candidate,
fast, stable).

### Pause updates

Device can be pinned to its current firmware.
Device can be pinned to its current software.

### Realtime update logs

Expand Down
2 changes: 1 addition & 1 deletion goosebit/api/v1/devices/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DevicesDeleteRequest(BaseModel):

class DevicesPatchRequest(BaseModel):
devices: list[str]
firmware: str | None = None
software: str | None = None
name: str | None = None
pinned: bool | None = None
feed: str | None = None
Expand Down
14 changes: 7 additions & 7 deletions goosebit/api/v1/devices/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from goosebit.api.responses import StatusResponse
from goosebit.auth import validate_user_permissions
from goosebit.models import Device, Firmware, UpdateModeEnum
from goosebit.models import Device, Software, UpdateModeEnum
from goosebit.permissions import Permissions
from goosebit.updater.manager import delete_devices, get_update_manager

Expand All @@ -21,7 +21,7 @@
dependencies=[Security(validate_user_permissions, scopes=[Permissions.HOME.READ])],
)
async def devices_get(_: Request) -> DevicesResponse:
return await DevicesResponse.convert(await Device.all().prefetch_related("assigned_firmware", "hardware"))
return await DevicesResponse.convert(await Device.all().prefetch_related("assigned_software", "hardware"))


@router.patch(
Expand All @@ -31,14 +31,14 @@ async def devices_get(_: Request) -> DevicesResponse:
async def devices_patch(_: Request, config: DevicesPatchRequest) -> StatusResponse:
for uuid in config.devices:
updater = await get_update_manager(uuid)
if config.firmware is not None:
if config.firmware == "rollout":
if config.software is not None:
if config.software == "rollout":
await updater.update_update(UpdateModeEnum.ROLLOUT, None)
elif config.firmware == "latest":
elif config.software == "latest":
await updater.update_update(UpdateModeEnum.LATEST, None)
else:
firmware = await Firmware.get_or_none(id=config.firmware)
await updater.update_update(UpdateModeEnum.ASSIGNED, firmware)
software = await Software.get_or_none(id=config.software)
await updater.update_update(UpdateModeEnum.ASSIGNED, software)
if config.pinned is not None:
await updater.update_update(UpdateModeEnum.PINNED, None)
if config.name is not None:
Expand Down
14 changes: 7 additions & 7 deletions goosebit/api/v1/download/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
from fastapi.requests import Request
from fastapi.responses import FileResponse, RedirectResponse

from goosebit.models import Firmware
from goosebit.models import Software

router = APIRouter(prefix="/download", tags=["download"])


@router.get("/{file_id}")
async def download_file(_: Request, file_id: int):
firmware = await Firmware.get_or_none(id=file_id)
if firmware is None:
software = await Software.get_or_none(id=file_id)
if software is None:
raise HTTPException(404)
if firmware.local:
if software.local:
return FileResponse(
firmware.path,
software.path,
media_type="application/octet-stream",
filename=firmware.path.name,
filename=software.path.name,
)
else:
return RedirectResponse(url=firmware.uri)
return RedirectResponse(url=software.uri)
16 changes: 0 additions & 16 deletions goosebit/api/v1/firmware/responses.py

This file was deleted.

46 changes: 0 additions & 46 deletions goosebit/api/v1/firmware/routes.py

This file was deleted.

2 changes: 1 addition & 1 deletion goosebit/api/v1/rollouts/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class RolloutsPutRequest(BaseModel):
name: str
feed: str
firmware_id: int
software_id: int


class RolloutsPatchRequest(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions goosebit/api/v1/rollouts/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
dependencies=[Security(validate_user_permissions, scopes=[Permissions.ROLLOUT.READ])],
)
async def rollouts_get(_: Request) -> RolloutsResponse:
return await RolloutsResponse.convert(await Rollout.all().prefetch_related("firmware"))
return await RolloutsResponse.convert(await Rollout.all().prefetch_related("software"))


@router.post(
Expand All @@ -28,7 +28,7 @@ async def rollouts_put(_: Request, rollout: RolloutsPutRequest) -> RolloutsPutRe
rollout = await Rollout.create(
name=rollout.name,
feed=rollout.feed,
firmware_id=rollout.firmware_id,
software_id=rollout.software_id,
)
return RolloutsPutResponse(success=True, id=rollout.id)

Expand Down
4 changes: 2 additions & 2 deletions goosebit/api/v1/routes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from fastapi import APIRouter

from . import devices, download, firmware, rollouts
from . import devices, download, rollouts, software

router = APIRouter(prefix="/v1")
router.include_router(firmware.router)
router.include_router(software.router)
router.include_router(devices.router)
router.include_router(rollouts.router)
router.include_router(download.router)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pydantic import BaseModel


class FirmwareDeleteRequest(BaseModel):
class SoftwareDeleteRequest(BaseModel):
files: list[int]
16 changes: 16 additions & 0 deletions goosebit/api/v1/software/responses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import annotations

import asyncio

from pydantic import BaseModel

from goosebit.models import Software
from goosebit.schema.software import SoftwareSchema


class SoftwareResponse(BaseModel):
software: list[SoftwareSchema]

@classmethod
async def convert(cls, software: list[Software]):
return cls(software=await asyncio.gather(*[SoftwareSchema.convert(f) for f in software]))
Loading

0 comments on commit ea0c0e6

Please sign in to comment.