mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 20:35:55 +00:00
Add snapshot feature (#88)
* Add API layout for snapshot
* Update api
* Add support for export/import docker images
* Move restore into addon
* Add restore to addon
* Fix lint
* fix lint
* cleanup
* init object
* fix executor
* cleanup
* Change flow of init
* Revert "Change flow of init"
This reverts commit 6b3215e44c.
* allow restore from none
* forward working
* add size
* add context for snapshot
* add init function to set meta data
* update local addon on load
* add more validate and optimaze code
* Optimaze code for restore data
* add validate layer
* Add more function to snapshot / cleanup others
* finish snapshot function
* Cleanup config / optimaze code
* Finish snapshot on core
* Some improvments first object for api
* finish
* fix lint p1
* fix lint p2
* fix lint p3
* fix async with
* fix lint p4
* fix lint p5
* fix p6
* make staticmethod
* fix schema
* fix parse system data
* fix bugs
* fix get function
* extend snapshot/restore
* add type
* fix lint
* move to gz / xz is to slow
* move to gz / xz is to slow p2
* Fix config folder
* small compresslevel for more speed
* fix lint
* fix load
* fix tar stream
* fix tar stream p2
* fix parse
* fix partial
* fix start hass
* fix rep
* fix set
* fix real
* fix generator
* Cleanup old image
* add log
* fix lint
* fix lint p2
* fix load from tar
This commit is contained in:
@@ -10,7 +10,7 @@ from ..const import (
|
||||
HASSIO_VERSION, ATTR_ADDONS_REPOSITORIES, ATTR_REPOSITORIES,
|
||||
ATTR_REPOSITORY, ATTR_DESCRIPTON, ATTR_NAME, ATTR_SLUG, ATTR_INSTALLED,
|
||||
ATTR_DETACHED, ATTR_SOURCE, ATTR_MAINTAINER, ATTR_URL, ATTR_ARCH,
|
||||
ATTR_BUILD, ATTR_TIMEZONE)
|
||||
ATTR_BUILD, ATTR_TIMEZONE, ATTR_DATE, ATTR_SNAPSHOTS)
|
||||
from ..tools import validate_timezone
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -30,13 +30,14 @@ SCHEMA_VERSION = vol.Schema({
|
||||
class APISupervisor(object):
|
||||
"""Handle rest api for supervisor functions."""
|
||||
|
||||
def __init__(self, config, loop, supervisor, addons, host_control,
|
||||
websession):
|
||||
def __init__(self, config, loop, supervisor, snapshots, addons,
|
||||
host_control, websession):
|
||||
"""Initialize supervisor rest api part."""
|
||||
self.config = config
|
||||
self.loop = loop
|
||||
self.supervisor = supervisor
|
||||
self.addons = addons
|
||||
self.snapshots = snapshots
|
||||
self.host_control = host_control
|
||||
self.websession = websession
|
||||
|
||||
@@ -76,6 +77,18 @@ class APISupervisor(object):
|
||||
|
||||
return data
|
||||
|
||||
def _snapshots_list(self):
|
||||
"""Return a list of available snapshots."""
|
||||
data = []
|
||||
for snapshot in self.snapshots.list_snapshots:
|
||||
data.append({
|
||||
ATTR_SLUG: snapshot.slug,
|
||||
ATTR_NAME: snapshot.name,
|
||||
ATTR_DATE: snapshot.date,
|
||||
})
|
||||
|
||||
return data
|
||||
|
||||
@api_process
|
||||
async def ping(self, request):
|
||||
"""Return ok for signal that the api is ready."""
|
||||
@@ -92,6 +105,7 @@ class APISupervisor(object):
|
||||
ATTR_TIMEZONE: self.config.timezone,
|
||||
ATTR_ADDONS: self._addons_list(only_installed=True),
|
||||
ATTR_ADDONS_REPOSITORIES: self.config.addons_repositories,
|
||||
ATTR_SNAPSHOTS: self._snapshots_list(),
|
||||
}
|
||||
|
||||
@api_process
|
||||
@@ -136,6 +150,7 @@ class APISupervisor(object):
|
||||
"""Reload addons, config ect."""
|
||||
tasks = [
|
||||
self.addons.reload(),
|
||||
self.snapshots.reload(),
|
||||
self.config.fetch_update_infos(self.websession),
|
||||
self.host_control.load()
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user